This source file includes following definitions.
- dcn20_wait_for_vmid_ready
- dcn20_vmid_setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #include <linux/delay.h>
27
28 #include "dcn20_vmid.h"
29 #include "reg_helper.h"
30
31 #define REG(reg)\
32 vmid->regs->reg
33
34 #define CTX \
35 vmid->ctx
36
37 #undef FN
38 #define FN(reg_name, field_name) \
39 vmid->shifts->field_name, vmid->masks->field_name
40
41 static void dcn20_wait_for_vmid_ready(struct dcn20_vmid *vmid)
42 {
43
44
45
46
47
48
49
50
51 int max_times = 10000;
52 int delay_us = 5;
53 int i;
54
55 for (i = 0; i < max_times; ++i) {
56 uint32_t entry_lo32;
57
58 REG_GET(PAGE_TABLE_BASE_ADDR_LO32,
59 VM_CONTEXT0_PAGE_DIRECTORY_ENTRY_LO32,
60 &entry_lo32);
61
62 if (entry_lo32 & 0x1)
63 return;
64
65 udelay(delay_us);
66 }
67
68
69 DC_LOG_WARNING("Timeout while waiting for GPUVM context update\n");
70 ASSERT(0);
71 }
72
73 void dcn20_vmid_setup(struct dcn20_vmid *vmid, const struct dcn_vmid_page_table_config *config)
74 {
75 REG_SET(PAGE_TABLE_START_ADDR_HI32, 0,
76 VM_CONTEXT0_START_LOGICAL_PAGE_NUMBER_HI4, (config->page_table_start_addr >> 32) & 0xF);
77 REG_SET(PAGE_TABLE_START_ADDR_LO32, 0,
78 VM_CONTEXT0_START_LOGICAL_PAGE_NUMBER_LO32, config->page_table_start_addr & 0xFFFFFFFF);
79
80 REG_SET(PAGE_TABLE_END_ADDR_HI32, 0,
81 VM_CONTEXT0_END_LOGICAL_PAGE_NUMBER_HI4, (config->page_table_end_addr >> 32) & 0xF);
82 REG_SET(PAGE_TABLE_END_ADDR_LO32, 0,
83 VM_CONTEXT0_END_LOGICAL_PAGE_NUMBER_LO32, config->page_table_end_addr & 0xFFFFFFFF);
84
85 REG_SET_2(CNTL, 0,
86 VM_CONTEXT0_PAGE_TABLE_DEPTH, config->depth,
87 VM_CONTEXT0_PAGE_TABLE_BLOCK_SIZE, config->block_size);
88
89 REG_SET(PAGE_TABLE_BASE_ADDR_HI32, 0,
90 VM_CONTEXT0_PAGE_DIRECTORY_ENTRY_HI32, (config->page_table_base_addr >> 32) & 0xFFFFFFFF);
91
92 REG_SET(PAGE_TABLE_BASE_ADDR_LO32, 0,
93 VM_CONTEXT0_PAGE_DIRECTORY_ENTRY_LO32, config->page_table_base_addr & 0xFFFFFFFF);
94
95 dcn20_wait_for_vmid_ready(vmid);
96 }