2 * Copyright 2019 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
25 #include "mmhub_v2_0.h"
27 #include "mmhub/mmhub_2_0_0_offset.h"
28 #include "mmhub/mmhub_2_0_0_sh_mask.h"
29 #include "mmhub/mmhub_2_0_0_default.h"
30 #include "navi10_enum.h"
32 #include "soc15_common.h"
34 void mmhub_v2_0_setup_vm_pt_regs(struct amdgpu_device
*adev
, uint32_t vmid
,
35 uint64_t page_table_base
)
37 /* two registers distance between mmMMVM_CONTEXT0_* to mmMMVM_CONTEXT1_* */
38 int offset
= mmMMVM_CONTEXT1_PAGE_TABLE_BASE_ADDR_LO32
39 - mmMMVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LO32
;
41 WREG32_SOC15_OFFSET(MMHUB
, 0, mmMMVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LO32
,
42 offset
* vmid
, lower_32_bits(page_table_base
));
44 WREG32_SOC15_OFFSET(MMHUB
, 0, mmMMVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_HI32
,
45 offset
* vmid
, upper_32_bits(page_table_base
));
48 static void mmhub_v2_0_init_gart_aperture_regs(struct amdgpu_device
*adev
)
50 uint64_t pt_base
= amdgpu_gmc_pd_addr(adev
->gart
.bo
);
52 mmhub_v2_0_setup_vm_pt_regs(adev
, 0, pt_base
);
54 WREG32_SOC15(MMHUB
, 0, mmMMVM_CONTEXT0_PAGE_TABLE_START_ADDR_LO32
,
55 (u32
)(adev
->gmc
.gart_start
>> 12));
56 WREG32_SOC15(MMHUB
, 0, mmMMVM_CONTEXT0_PAGE_TABLE_START_ADDR_HI32
,
57 (u32
)(adev
->gmc
.gart_start
>> 44));
59 WREG32_SOC15(MMHUB
, 0, mmMMVM_CONTEXT0_PAGE_TABLE_END_ADDR_LO32
,
60 (u32
)(adev
->gmc
.gart_end
>> 12));
61 WREG32_SOC15(MMHUB
, 0, mmMMVM_CONTEXT0_PAGE_TABLE_END_ADDR_HI32
,
62 (u32
)(adev
->gmc
.gart_end
>> 44));
65 static void mmhub_v2_0_init_system_aperture_regs(struct amdgpu_device
*adev
)
71 WREG32_SOC15(MMHUB
, 0, mmMMMC_VM_AGP_BASE
, 0);
72 WREG32_SOC15(MMHUB
, 0, mmMMMC_VM_AGP_TOP
, 0);
73 WREG32_SOC15(MMHUB
, 0, mmMMMC_VM_AGP_BOT
, 0x00FFFFFF);
75 /* Program the system aperture low logical page number. */
76 WREG32_SOC15(MMHUB
, 0, mmMMMC_VM_SYSTEM_APERTURE_LOW_ADDR
,
77 adev
->gmc
.vram_start
>> 18);
78 WREG32_SOC15(MMHUB
, 0, mmMMMC_VM_SYSTEM_APERTURE_HIGH_ADDR
,
79 adev
->gmc
.vram_end
>> 18);
81 /* Set default page address. */
82 value
= adev
->vram_scratch
.gpu_addr
- adev
->gmc
.vram_start
+
83 adev
->vm_manager
.vram_base_offset
;
84 WREG32_SOC15(MMHUB
, 0, mmMMMC_VM_SYSTEM_APERTURE_DEFAULT_ADDR_LSB
,
86 WREG32_SOC15(MMHUB
, 0, mmMMMC_VM_SYSTEM_APERTURE_DEFAULT_ADDR_MSB
,
89 /* Program "protection fault". */
90 WREG32_SOC15(MMHUB
, 0, mmMMVM_L2_PROTECTION_FAULT_DEFAULT_ADDR_LO32
,
91 (u32
)(adev
->dummy_page_addr
>> 12));
92 WREG32_SOC15(MMHUB
, 0, mmMMVM_L2_PROTECTION_FAULT_DEFAULT_ADDR_HI32
,
93 (u32
)((u64
)adev
->dummy_page_addr
>> 44));
95 tmp
= RREG32_SOC15(MMHUB
, 0, mmMMVM_L2_PROTECTION_FAULT_CNTL2
);
96 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_PROTECTION_FAULT_CNTL2
,
97 ACTIVE_PAGE_MIGRATION_PTE_READ_RETRY
, 1);
98 WREG32_SOC15(MMHUB
, 0, mmMMVM_L2_PROTECTION_FAULT_CNTL2
, tmp
);
101 static void mmhub_v2_0_init_tlb_regs(struct amdgpu_device
*adev
)
105 /* Setup TLB control */
106 tmp
= RREG32_SOC15(MMHUB
, 0, mmMMMC_VM_MX_L1_TLB_CNTL
);
108 tmp
= REG_SET_FIELD(tmp
, MMMC_VM_MX_L1_TLB_CNTL
, ENABLE_L1_TLB
, 1);
109 tmp
= REG_SET_FIELD(tmp
, MMMC_VM_MX_L1_TLB_CNTL
, SYSTEM_ACCESS_MODE
, 3);
110 tmp
= REG_SET_FIELD(tmp
, MMMC_VM_MX_L1_TLB_CNTL
,
111 ENABLE_ADVANCED_DRIVER_MODEL
, 1);
112 tmp
= REG_SET_FIELD(tmp
, MMMC_VM_MX_L1_TLB_CNTL
,
113 SYSTEM_APERTURE_UNMAPPED_ACCESS
, 0);
114 tmp
= REG_SET_FIELD(tmp
, MMMC_VM_MX_L1_TLB_CNTL
, ECO_BITS
, 0);
115 tmp
= REG_SET_FIELD(tmp
, MMMC_VM_MX_L1_TLB_CNTL
,
116 MTYPE
, MTYPE_UC
); /* UC, uncached */
118 WREG32_SOC15(MMHUB
, 0, mmMMMC_VM_MX_L1_TLB_CNTL
, tmp
);
121 static void mmhub_v2_0_init_cache_regs(struct amdgpu_device
*adev
)
126 tmp
= RREG32_SOC15(MMHUB
, 0, mmMMVM_L2_CNTL
);
127 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_CNTL
, ENABLE_L2_CACHE
, 1);
128 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_CNTL
, ENABLE_L2_FRAGMENT_PROCESSING
, 0);
129 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_CNTL
,
130 ENABLE_DEFAULT_PAGE_OUT_TO_SYSTEM_MEMORY
, 1);
131 /* XXX for emulation, Refer to closed source code.*/
132 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_CNTL
, L2_PDE0_CACHE_TAG_GENERATION_MODE
,
134 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_CNTL
, PDE_FAULT_CLASSIFICATION
, 0);
135 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_CNTL
, CONTEXT1_IDENTITY_ACCESS_MODE
, 1);
136 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_CNTL
, IDENTITY_MODE_FRAGMENT_SIZE
, 0);
137 WREG32_SOC15(MMHUB
, 0, mmMMVM_L2_CNTL
, tmp
);
139 tmp
= RREG32_SOC15(MMHUB
, 0, mmMMVM_L2_CNTL2
);
140 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_CNTL2
, INVALIDATE_ALL_L1_TLBS
, 1);
141 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_CNTL2
, INVALIDATE_L2_CACHE
, 1);
142 WREG32_SOC15(MMHUB
, 0, mmMMVM_L2_CNTL2
, tmp
);
144 tmp
= mmMMVM_L2_CNTL3_DEFAULT
;
145 if (adev
->gmc
.translate_further
) {
146 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_CNTL3
, BANK_SELECT
, 12);
147 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_CNTL3
,
148 L2_CACHE_BIGK_FRAGMENT_SIZE
, 9);
150 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_CNTL3
, BANK_SELECT
, 9);
151 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_CNTL3
,
152 L2_CACHE_BIGK_FRAGMENT_SIZE
, 6);
154 WREG32_SOC15(MMHUB
, 0, mmMMVM_L2_CNTL3
, tmp
);
156 tmp
= mmMMVM_L2_CNTL4_DEFAULT
;
157 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_CNTL4
, VMC_TAP_PDE_REQUEST_PHYSICAL
, 0);
158 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_CNTL4
, VMC_TAP_PTE_REQUEST_PHYSICAL
, 0);
159 WREG32_SOC15(MMHUB
, 0, mmMMVM_L2_CNTL4
, tmp
);
162 static void mmhub_v2_0_enable_system_domain(struct amdgpu_device
*adev
)
166 tmp
= RREG32_SOC15(MMHUB
, 0, mmMMVM_CONTEXT0_CNTL
);
167 tmp
= REG_SET_FIELD(tmp
, MMVM_CONTEXT0_CNTL
, ENABLE_CONTEXT
, 1);
168 tmp
= REG_SET_FIELD(tmp
, MMVM_CONTEXT0_CNTL
, PAGE_TABLE_DEPTH
, 0);
169 tmp
= REG_SET_FIELD(tmp
, MMVM_CONTEXT0_CNTL
,
170 RETRY_PERMISSION_OR_INVALID_PAGE_FAULT
, 0);
171 WREG32_SOC15(MMHUB
, 0, mmMMVM_CONTEXT0_CNTL
, tmp
);
174 static void mmhub_v2_0_disable_identity_aperture(struct amdgpu_device
*adev
)
176 WREG32_SOC15(MMHUB
, 0,
177 mmMMVM_L2_CONTEXT1_IDENTITY_APERTURE_LOW_ADDR_LO32
,
179 WREG32_SOC15(MMHUB
, 0,
180 mmMMVM_L2_CONTEXT1_IDENTITY_APERTURE_LOW_ADDR_HI32
,
183 WREG32_SOC15(MMHUB
, 0,
184 mmMMVM_L2_CONTEXT1_IDENTITY_APERTURE_HIGH_ADDR_LO32
, 0);
185 WREG32_SOC15(MMHUB
, 0,
186 mmMMVM_L2_CONTEXT1_IDENTITY_APERTURE_HIGH_ADDR_HI32
, 0);
188 WREG32_SOC15(MMHUB
, 0, mmMMVM_L2_CONTEXT_IDENTITY_PHYSICAL_OFFSET_LO32
,
190 WREG32_SOC15(MMHUB
, 0, mmMMVM_L2_CONTEXT_IDENTITY_PHYSICAL_OFFSET_HI32
,
194 static void mmhub_v2_0_setup_vmid_config(struct amdgpu_device
*adev
)
199 for (i
= 0; i
<= 14; i
++) {
200 tmp
= RREG32_SOC15_OFFSET(MMHUB
, 0, mmMMVM_CONTEXT1_CNTL
, i
);
201 tmp
= REG_SET_FIELD(tmp
, MMVM_CONTEXT1_CNTL
, ENABLE_CONTEXT
, 1);
202 tmp
= REG_SET_FIELD(tmp
, MMVM_CONTEXT1_CNTL
, PAGE_TABLE_DEPTH
,
203 adev
->vm_manager
.num_level
);
204 tmp
= REG_SET_FIELD(tmp
, MMVM_CONTEXT1_CNTL
,
205 RANGE_PROTECTION_FAULT_ENABLE_DEFAULT
, 1);
206 tmp
= REG_SET_FIELD(tmp
, MMVM_CONTEXT1_CNTL
,
207 DUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT
,
209 tmp
= REG_SET_FIELD(tmp
, MMVM_CONTEXT1_CNTL
,
210 PDE0_PROTECTION_FAULT_ENABLE_DEFAULT
, 1);
211 tmp
= REG_SET_FIELD(tmp
, MMVM_CONTEXT1_CNTL
,
212 VALID_PROTECTION_FAULT_ENABLE_DEFAULT
, 1);
213 tmp
= REG_SET_FIELD(tmp
, MMVM_CONTEXT1_CNTL
,
214 READ_PROTECTION_FAULT_ENABLE_DEFAULT
, 1);
215 tmp
= REG_SET_FIELD(tmp
, MMVM_CONTEXT1_CNTL
,
216 WRITE_PROTECTION_FAULT_ENABLE_DEFAULT
, 1);
217 tmp
= REG_SET_FIELD(tmp
, MMVM_CONTEXT1_CNTL
,
218 EXECUTE_PROTECTION_FAULT_ENABLE_DEFAULT
, 1);
219 tmp
= REG_SET_FIELD(tmp
, MMVM_CONTEXT1_CNTL
,
220 PAGE_TABLE_BLOCK_SIZE
,
221 adev
->vm_manager
.block_size
- 9);
222 /* Send no-retry XNACK on fault to suppress VM fault storm. */
223 tmp
= REG_SET_FIELD(tmp
, MMVM_CONTEXT1_CNTL
,
224 RETRY_PERMISSION_OR_INVALID_PAGE_FAULT
,
226 WREG32_SOC15_OFFSET(MMHUB
, 0, mmMMVM_CONTEXT1_CNTL
, i
, tmp
);
227 WREG32_SOC15_OFFSET(MMHUB
, 0, mmMMVM_CONTEXT1_PAGE_TABLE_START_ADDR_LO32
, i
*2, 0);
228 WREG32_SOC15_OFFSET(MMHUB
, 0, mmMMVM_CONTEXT1_PAGE_TABLE_START_ADDR_HI32
, i
*2, 0);
229 WREG32_SOC15_OFFSET(MMHUB
, 0, mmMMVM_CONTEXT1_PAGE_TABLE_END_ADDR_LO32
, i
*2,
230 lower_32_bits(adev
->vm_manager
.max_pfn
- 1));
231 WREG32_SOC15_OFFSET(MMHUB
, 0, mmMMVM_CONTEXT1_PAGE_TABLE_END_ADDR_HI32
, i
*2,
232 upper_32_bits(adev
->vm_manager
.max_pfn
- 1));
236 static void mmhub_v2_0_program_invalidation(struct amdgpu_device
*adev
)
240 for (i
= 0; i
< 18; ++i
) {
241 WREG32_SOC15_OFFSET(MMHUB
, 0, mmMMVM_INVALIDATE_ENG0_ADDR_RANGE_LO32
,
243 WREG32_SOC15_OFFSET(MMHUB
, 0, mmMMVM_INVALIDATE_ENG0_ADDR_RANGE_HI32
,
248 int mmhub_v2_0_gart_enable(struct amdgpu_device
*adev
)
250 if (amdgpu_sriov_vf(adev
)) {
252 * MMMC_VM_FB_LOCATION_BASE/TOP is NULL for VF, becuase they are
253 * VF copy registers so vbios post doesn't program them, for
254 * SRIOV driver need to program them
256 WREG32_SOC15(MMHUB
, 0, mmMMMC_VM_FB_LOCATION_BASE
,
257 adev
->gmc
.vram_start
>> 24);
258 WREG32_SOC15(MMHUB
, 0, mmMMMC_VM_FB_LOCATION_TOP
,
259 adev
->gmc
.vram_end
>> 24);
263 mmhub_v2_0_init_gart_aperture_regs(adev
);
264 mmhub_v2_0_init_system_aperture_regs(adev
);
265 mmhub_v2_0_init_tlb_regs(adev
);
266 mmhub_v2_0_init_cache_regs(adev
);
268 mmhub_v2_0_enable_system_domain(adev
);
269 mmhub_v2_0_disable_identity_aperture(adev
);
270 mmhub_v2_0_setup_vmid_config(adev
);
271 mmhub_v2_0_program_invalidation(adev
);
276 void mmhub_v2_0_gart_disable(struct amdgpu_device
*adev
)
281 /* Disable all tables */
282 for (i
= 0; i
< 16; i
++)
283 WREG32_SOC15_OFFSET(MMHUB
, 0, mmMMVM_CONTEXT0_CNTL
, i
, 0);
285 /* Setup TLB control */
286 tmp
= RREG32_SOC15(MMHUB
, 0, mmMMMC_VM_MX_L1_TLB_CNTL
);
287 tmp
= REG_SET_FIELD(tmp
, MMMC_VM_MX_L1_TLB_CNTL
, ENABLE_L1_TLB
, 0);
288 tmp
= REG_SET_FIELD(tmp
, MMMC_VM_MX_L1_TLB_CNTL
,
289 ENABLE_ADVANCED_DRIVER_MODEL
, 0);
290 WREG32_SOC15(MMHUB
, 0, mmMMMC_VM_MX_L1_TLB_CNTL
, tmp
);
293 tmp
= RREG32_SOC15(MMHUB
, 0, mmMMVM_L2_CNTL
);
294 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_CNTL
, ENABLE_L2_CACHE
, 0);
295 WREG32_SOC15(MMHUB
, 0, mmMMVM_L2_CNTL
, tmp
);
296 WREG32_SOC15(MMHUB
, 0, mmMMVM_L2_CNTL3
, 0);
300 * mmhub_v2_0_set_fault_enable_default - update GART/VM fault handling
302 * @adev: amdgpu_device pointer
303 * @value: true redirects VM faults to the default page
305 void mmhub_v2_0_set_fault_enable_default(struct amdgpu_device
*adev
, bool value
)
308 tmp
= RREG32_SOC15(MMHUB
, 0, mmMMVM_L2_PROTECTION_FAULT_CNTL
);
309 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_PROTECTION_FAULT_CNTL
,
310 RANGE_PROTECTION_FAULT_ENABLE_DEFAULT
, value
);
311 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_PROTECTION_FAULT_CNTL
,
312 PDE0_PROTECTION_FAULT_ENABLE_DEFAULT
, value
);
313 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_PROTECTION_FAULT_CNTL
,
314 PDE1_PROTECTION_FAULT_ENABLE_DEFAULT
, value
);
315 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_PROTECTION_FAULT_CNTL
,
316 PDE2_PROTECTION_FAULT_ENABLE_DEFAULT
, value
);
317 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_PROTECTION_FAULT_CNTL
,
318 TRANSLATE_FURTHER_PROTECTION_FAULT_ENABLE_DEFAULT
,
320 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_PROTECTION_FAULT_CNTL
,
321 NACK_PROTECTION_FAULT_ENABLE_DEFAULT
, value
);
322 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_PROTECTION_FAULT_CNTL
,
323 DUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT
, value
);
324 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_PROTECTION_FAULT_CNTL
,
325 VALID_PROTECTION_FAULT_ENABLE_DEFAULT
, value
);
326 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_PROTECTION_FAULT_CNTL
,
327 READ_PROTECTION_FAULT_ENABLE_DEFAULT
, value
);
328 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_PROTECTION_FAULT_CNTL
,
329 WRITE_PROTECTION_FAULT_ENABLE_DEFAULT
, value
);
330 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_PROTECTION_FAULT_CNTL
,
331 EXECUTE_PROTECTION_FAULT_ENABLE_DEFAULT
, value
);
333 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_PROTECTION_FAULT_CNTL
,
334 CRASH_ON_NO_RETRY_FAULT
, 1);
335 tmp
= REG_SET_FIELD(tmp
, MMVM_L2_PROTECTION_FAULT_CNTL
,
336 CRASH_ON_RETRY_FAULT
, 1);
338 WREG32_SOC15(MMHUB
, 0, mmMMVM_L2_PROTECTION_FAULT_CNTL
, tmp
);
341 void mmhub_v2_0_init(struct amdgpu_device
*adev
)
343 struct amdgpu_vmhub
*hub
= &adev
->vmhub
[AMDGPU_MMHUB_0
];
345 hub
->ctx0_ptb_addr_lo32
=
346 SOC15_REG_OFFSET(MMHUB
, 0,
347 mmMMVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LO32
);
348 hub
->ctx0_ptb_addr_hi32
=
349 SOC15_REG_OFFSET(MMHUB
, 0,
350 mmMMVM_CONTEXT0_PAGE_TABLE_BASE_ADDR_HI32
);
351 hub
->vm_inv_eng0_sem
=
352 SOC15_REG_OFFSET(MMHUB
, 0, mmMMVM_INVALIDATE_ENG0_SEM
);
353 hub
->vm_inv_eng0_req
=
354 SOC15_REG_OFFSET(MMHUB
, 0, mmMMVM_INVALIDATE_ENG0_REQ
);
355 hub
->vm_inv_eng0_ack
=
356 SOC15_REG_OFFSET(MMHUB
, 0, mmMMVM_INVALIDATE_ENG0_ACK
);
357 hub
->vm_context0_cntl
=
358 SOC15_REG_OFFSET(MMHUB
, 0, mmMMVM_CONTEXT0_CNTL
);
359 hub
->vm_l2_pro_fault_status
=
360 SOC15_REG_OFFSET(MMHUB
, 0, mmMMVM_L2_PROTECTION_FAULT_STATUS
);
361 hub
->vm_l2_pro_fault_cntl
=
362 SOC15_REG_OFFSET(MMHUB
, 0, mmMMVM_L2_PROTECTION_FAULT_CNTL
);
366 static void mmhub_v2_0_update_medium_grain_clock_gating(struct amdgpu_device
*adev
,
369 uint32_t def
, data
, def1
, data1
;
371 def
= data
= RREG32_SOC15(MMHUB
, 0, mmMM_ATC_L2_MISC_CG
);
373 def1
= data1
= RREG32_SOC15(MMHUB
, 0, mmDAGB0_CNTL_MISC2
);
375 if (enable
&& (adev
->cg_flags
& AMD_CG_SUPPORT_MC_MGCG
)) {
376 data
|= MM_ATC_L2_MISC_CG__ENABLE_MASK
;
378 data1
&= ~(DAGB0_CNTL_MISC2__DISABLE_WRREQ_CG_MASK
|
379 DAGB0_CNTL_MISC2__DISABLE_WRRET_CG_MASK
|
380 DAGB0_CNTL_MISC2__DISABLE_RDREQ_CG_MASK
|
381 DAGB0_CNTL_MISC2__DISABLE_RDRET_CG_MASK
|
382 DAGB0_CNTL_MISC2__DISABLE_TLBWR_CG_MASK
|
383 DAGB0_CNTL_MISC2__DISABLE_TLBRD_CG_MASK
);
386 data
&= ~MM_ATC_L2_MISC_CG__ENABLE_MASK
;
388 data1
|= (DAGB0_CNTL_MISC2__DISABLE_WRREQ_CG_MASK
|
389 DAGB0_CNTL_MISC2__DISABLE_WRRET_CG_MASK
|
390 DAGB0_CNTL_MISC2__DISABLE_RDREQ_CG_MASK
|
391 DAGB0_CNTL_MISC2__DISABLE_RDRET_CG_MASK
|
392 DAGB0_CNTL_MISC2__DISABLE_TLBWR_CG_MASK
|
393 DAGB0_CNTL_MISC2__DISABLE_TLBRD_CG_MASK
);
397 WREG32_SOC15(MMHUB
, 0, mmMM_ATC_L2_MISC_CG
, data
);
400 WREG32_SOC15(MMHUB
, 0, mmDAGB0_CNTL_MISC2
, data1
);
403 static void mmhub_v2_0_update_medium_grain_light_sleep(struct amdgpu_device
*adev
,
408 def
= data
= RREG32_SOC15(MMHUB
, 0, mmMM_ATC_L2_MISC_CG
);
410 if (enable
&& (adev
->cg_flags
& AMD_CG_SUPPORT_MC_LS
))
411 data
|= MM_ATC_L2_MISC_CG__MEM_LS_ENABLE_MASK
;
413 data
&= ~MM_ATC_L2_MISC_CG__MEM_LS_ENABLE_MASK
;
416 WREG32_SOC15(MMHUB
, 0, mmMM_ATC_L2_MISC_CG
, data
);
419 int mmhub_v2_0_set_clockgating(struct amdgpu_device
*adev
,
420 enum amd_clockgating_state state
)
422 if (amdgpu_sriov_vf(adev
))
425 switch (adev
->asic_type
) {
429 mmhub_v2_0_update_medium_grain_clock_gating(adev
,
430 state
== AMD_CG_STATE_GATE
? true : false);
431 mmhub_v2_0_update_medium_grain_light_sleep(adev
,
432 state
== AMD_CG_STATE_GATE
? true : false);
441 void mmhub_v2_0_get_clockgating(struct amdgpu_device
*adev
, u32
*flags
)
445 if (amdgpu_sriov_vf(adev
))
448 data
= RREG32_SOC15(MMHUB
, 0, mmMM_ATC_L2_MISC_CG
);
450 data1
= RREG32_SOC15(MMHUB
, 0, mmDAGB0_CNTL_MISC2
);
452 /* AMD_CG_SUPPORT_MC_MGCG */
453 if ((data
& MM_ATC_L2_MISC_CG__ENABLE_MASK
) &&
454 !(data1
& (DAGB0_CNTL_MISC2__DISABLE_WRREQ_CG_MASK
|
455 DAGB0_CNTL_MISC2__DISABLE_WRRET_CG_MASK
|
456 DAGB0_CNTL_MISC2__DISABLE_RDREQ_CG_MASK
|
457 DAGB0_CNTL_MISC2__DISABLE_RDRET_CG_MASK
|
458 DAGB0_CNTL_MISC2__DISABLE_TLBWR_CG_MASK
|
459 DAGB0_CNTL_MISC2__DISABLE_TLBRD_CG_MASK
)))
460 *flags
|= AMD_CG_SUPPORT_MC_MGCG
;
462 /* AMD_CG_SUPPORT_MC_LS */
463 if (data
& MM_ATC_L2_MISC_CG__MEM_LS_ENABLE_MASK
)
464 *flags
|= AMD_CG_SUPPORT_MC_LS
;