2 * Copyright 2014 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.
24 #include <linux/firmware.h>
25 #include <linux/module.h>
26 #include <linux/pci.h>
28 #include <drm/drm_cache.h>
31 #include "amdgpu_ucode.h"
32 #include "amdgpu_amdkfd.h"
33 #include "amdgpu_gem.h"
35 #include "gmc/gmc_8_1_d.h"
36 #include "gmc/gmc_8_1_sh_mask.h"
38 #include "bif/bif_5_0_d.h"
39 #include "bif/bif_5_0_sh_mask.h"
41 #include "oss/oss_3_0_d.h"
42 #include "oss/oss_3_0_sh_mask.h"
44 #include "dce/dce_10_0_d.h"
45 #include "dce/dce_10_0_sh_mask.h"
50 #include "amdgpu_atombios.h"
52 #include "ivsrcid/ivsrcid_vislands30.h"
54 static void gmc_v8_0_set_gmc_funcs(struct amdgpu_device *adev);
55 static void gmc_v8_0_set_irq_funcs(struct amdgpu_device *adev);
56 static int gmc_v8_0_wait_for_idle(void *handle);
58 MODULE_FIRMWARE("amdgpu/tonga_mc.bin");
59 MODULE_FIRMWARE("amdgpu/polaris11_mc.bin");
60 MODULE_FIRMWARE("amdgpu/polaris10_mc.bin");
61 MODULE_FIRMWARE("amdgpu/polaris12_mc.bin");
62 MODULE_FIRMWARE("amdgpu/polaris12_32_mc.bin");
63 MODULE_FIRMWARE("amdgpu/polaris11_k_mc.bin");
64 MODULE_FIRMWARE("amdgpu/polaris10_k_mc.bin");
65 MODULE_FIRMWARE("amdgpu/polaris12_k_mc.bin");
67 static const u32 golden_settings_tonga_a11[] =
69 mmMC_ARB_WTM_GRPWT_RD, 0x00000003, 0x00000000,
70 mmMC_HUB_RDREQ_DMIF_LIMIT, 0x0000007f, 0x00000028,
71 mmMC_HUB_WDP_UMC, 0x00007fb6, 0x00000991,
72 mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0x0fffffff,
73 mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff,
74 mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff,
75 mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff,
78 static const u32 tonga_mgcg_cgcg_init[] =
80 mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104
83 static const u32 golden_settings_fiji_a10[] =
85 mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0x0fffffff,
86 mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff,
87 mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff,
88 mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff,
91 static const u32 fiji_mgcg_cgcg_init[] =
93 mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104
96 static const u32 golden_settings_polaris11_a11[] =
98 mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0x0fffffff,
99 mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff,
100 mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff,
101 mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff
104 static const u32 golden_settings_polaris10_a11[] =
106 mmMC_ARB_WTM_GRPWT_RD, 0x00000003, 0x00000000,
107 mmVM_PRT_APERTURE0_LOW_ADDR, 0x0fffffff, 0x0fffffff,
108 mmVM_PRT_APERTURE1_LOW_ADDR, 0x0fffffff, 0x0fffffff,
109 mmVM_PRT_APERTURE2_LOW_ADDR, 0x0fffffff, 0x0fffffff,
110 mmVM_PRT_APERTURE3_LOW_ADDR, 0x0fffffff, 0x0fffffff
113 static const u32 cz_mgcg_cgcg_init[] =
115 mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104
118 static const u32 stoney_mgcg_cgcg_init[] =
120 mmATC_MISC_CG, 0xffffffff, 0x000c0200,
121 mmMC_MEM_POWER_LS, 0xffffffff, 0x00000104
124 static const u32 golden_settings_stoney_common[] =
126 mmMC_HUB_RDREQ_UVD, MC_HUB_RDREQ_UVD__PRESCALE_MASK, 0x00000004,
127 mmMC_RD_GRP_OTH, MC_RD_GRP_OTH__UVD_MASK, 0x00600000
130 static void gmc_v8_0_init_golden_registers(struct amdgpu_device *adev)
132 switch (adev->asic_type) {
134 amdgpu_device_program_register_sequence(adev,
136 ARRAY_SIZE(fiji_mgcg_cgcg_init));
137 amdgpu_device_program_register_sequence(adev,
138 golden_settings_fiji_a10,
139 ARRAY_SIZE(golden_settings_fiji_a10));
142 amdgpu_device_program_register_sequence(adev,
143 tonga_mgcg_cgcg_init,
144 ARRAY_SIZE(tonga_mgcg_cgcg_init));
145 amdgpu_device_program_register_sequence(adev,
146 golden_settings_tonga_a11,
147 ARRAY_SIZE(golden_settings_tonga_a11));
152 amdgpu_device_program_register_sequence(adev,
153 golden_settings_polaris11_a11,
154 ARRAY_SIZE(golden_settings_polaris11_a11));
157 amdgpu_device_program_register_sequence(adev,
158 golden_settings_polaris10_a11,
159 ARRAY_SIZE(golden_settings_polaris10_a11));
162 amdgpu_device_program_register_sequence(adev,
164 ARRAY_SIZE(cz_mgcg_cgcg_init));
167 amdgpu_device_program_register_sequence(adev,
168 stoney_mgcg_cgcg_init,
169 ARRAY_SIZE(stoney_mgcg_cgcg_init));
170 amdgpu_device_program_register_sequence(adev,
171 golden_settings_stoney_common,
172 ARRAY_SIZE(golden_settings_stoney_common));
179 static void gmc_v8_0_mc_stop(struct amdgpu_device *adev)
183 gmc_v8_0_wait_for_idle(adev);
185 blackout = RREG32(mmMC_SHARED_BLACKOUT_CNTL);
186 if (REG_GET_FIELD(blackout, MC_SHARED_BLACKOUT_CNTL, BLACKOUT_MODE) != 1) {
187 /* Block CPU access */
188 WREG32(mmBIF_FB_EN, 0);
189 /* blackout the MC */
190 blackout = REG_SET_FIELD(blackout,
191 MC_SHARED_BLACKOUT_CNTL, BLACKOUT_MODE, 1);
192 WREG32(mmMC_SHARED_BLACKOUT_CNTL, blackout);
194 /* wait for the MC to settle */
198 static void gmc_v8_0_mc_resume(struct amdgpu_device *adev)
202 /* unblackout the MC */
203 tmp = RREG32(mmMC_SHARED_BLACKOUT_CNTL);
204 tmp = REG_SET_FIELD(tmp, MC_SHARED_BLACKOUT_CNTL, BLACKOUT_MODE, 0);
205 WREG32(mmMC_SHARED_BLACKOUT_CNTL, tmp);
206 /* allow CPU access */
207 tmp = REG_SET_FIELD(0, BIF_FB_EN, FB_READ_EN, 1);
208 tmp = REG_SET_FIELD(tmp, BIF_FB_EN, FB_WRITE_EN, 1);
209 WREG32(mmBIF_FB_EN, tmp);
213 * gmc_v8_0_init_microcode - load ucode images from disk
215 * @adev: amdgpu_device pointer
217 * Use the firmware interface to load the ucode images into
218 * the driver (not loaded into hw).
219 * Returns 0 on success, error on failure.
221 static int gmc_v8_0_init_microcode(struct amdgpu_device *adev)
223 const char *chip_name;
229 switch (adev->asic_type) {
234 if (ASICID_IS_P21(adev->pdev->device, adev->pdev->revision) ||
235 ASICID_IS_P31(adev->pdev->device, adev->pdev->revision))
236 chip_name = "polaris11_k";
238 chip_name = "polaris11";
241 if (ASICID_IS_P30(adev->pdev->device, adev->pdev->revision))
242 chip_name = "polaris10_k";
244 chip_name = "polaris10";
247 if (ASICID_IS_P23(adev->pdev->device, adev->pdev->revision)) {
248 chip_name = "polaris12_k";
250 WREG32(mmMC_SEQ_IO_DEBUG_INDEX, ixMC_IO_DEBUG_UP_159);
251 /* Polaris12 32bit ASIC needs a special MC firmware */
252 if (RREG32(mmMC_SEQ_IO_DEBUG_DATA) == 0x05b4dc40)
253 chip_name = "polaris12_32";
255 chip_name = "polaris12";
266 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mc.bin", chip_name);
267 err = amdgpu_ucode_request(adev, &adev->gmc.fw, fw_name);
269 pr_err("mc: Failed to load firmware \"%s\"\n", fw_name);
270 amdgpu_ucode_release(&adev->gmc.fw);
276 * gmc_v8_0_tonga_mc_load_microcode - load tonga MC ucode into the hw
278 * @adev: amdgpu_device pointer
280 * Load the GDDR MC ucode into the hw (VI).
281 * Returns 0 on success, error on failure.
283 static int gmc_v8_0_tonga_mc_load_microcode(struct amdgpu_device *adev)
285 const struct mc_firmware_header_v1_0 *hdr;
286 const __le32 *fw_data = NULL;
287 const __le32 *io_mc_regs = NULL;
289 int i, ucode_size, regs_size;
291 /* Skip MC ucode loading on SR-IOV capable boards.
292 * vbios does this for us in asic_init in that case.
293 * Skip MC ucode loading on VF, because hypervisor will do that
296 if (amdgpu_sriov_bios(adev))
302 hdr = (const struct mc_firmware_header_v1_0 *)adev->gmc.fw->data;
303 amdgpu_ucode_print_mc_hdr(&hdr->header);
305 adev->gmc.fw_version = le32_to_cpu(hdr->header.ucode_version);
306 regs_size = le32_to_cpu(hdr->io_debug_size_bytes) / (4 * 2);
307 io_mc_regs = (const __le32 *)
308 (adev->gmc.fw->data + le32_to_cpu(hdr->io_debug_array_offset_bytes));
309 ucode_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4;
310 fw_data = (const __le32 *)
311 (adev->gmc.fw->data + le32_to_cpu(hdr->header.ucode_array_offset_bytes));
313 running = REG_GET_FIELD(RREG32(mmMC_SEQ_SUP_CNTL), MC_SEQ_SUP_CNTL, RUN);
316 /* reset the engine and set to writable */
317 WREG32(mmMC_SEQ_SUP_CNTL, 0x00000008);
318 WREG32(mmMC_SEQ_SUP_CNTL, 0x00000010);
320 /* load mc io regs */
321 for (i = 0; i < regs_size; i++) {
322 WREG32(mmMC_SEQ_IO_DEBUG_INDEX, le32_to_cpup(io_mc_regs++));
323 WREG32(mmMC_SEQ_IO_DEBUG_DATA, le32_to_cpup(io_mc_regs++));
325 /* load the MC ucode */
326 for (i = 0; i < ucode_size; i++)
327 WREG32(mmMC_SEQ_SUP_PGM, le32_to_cpup(fw_data++));
329 /* put the engine back into the active state */
330 WREG32(mmMC_SEQ_SUP_CNTL, 0x00000008);
331 WREG32(mmMC_SEQ_SUP_CNTL, 0x00000004);
332 WREG32(mmMC_SEQ_SUP_CNTL, 0x00000001);
334 /* wait for training to complete */
335 for (i = 0; i < adev->usec_timeout; i++) {
336 if (REG_GET_FIELD(RREG32(mmMC_SEQ_TRAIN_WAKEUP_CNTL),
337 MC_SEQ_TRAIN_WAKEUP_CNTL, TRAIN_DONE_D0))
341 for (i = 0; i < adev->usec_timeout; i++) {
342 if (REG_GET_FIELD(RREG32(mmMC_SEQ_TRAIN_WAKEUP_CNTL),
343 MC_SEQ_TRAIN_WAKEUP_CNTL, TRAIN_DONE_D1))
352 static int gmc_v8_0_polaris_mc_load_microcode(struct amdgpu_device *adev)
354 const struct mc_firmware_header_v1_0 *hdr;
355 const __le32 *fw_data = NULL;
356 const __le32 *io_mc_regs = NULL;
358 int i, ucode_size, regs_size;
360 /* Skip MC ucode loading on SR-IOV capable boards.
361 * vbios does this for us in asic_init in that case.
362 * Skip MC ucode loading on VF, because hypervisor will do that
365 if (amdgpu_sriov_bios(adev))
371 hdr = (const struct mc_firmware_header_v1_0 *)adev->gmc.fw->data;
372 amdgpu_ucode_print_mc_hdr(&hdr->header);
374 adev->gmc.fw_version = le32_to_cpu(hdr->header.ucode_version);
375 regs_size = le32_to_cpu(hdr->io_debug_size_bytes) / (4 * 2);
376 io_mc_regs = (const __le32 *)
377 (adev->gmc.fw->data + le32_to_cpu(hdr->io_debug_array_offset_bytes));
378 ucode_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4;
379 fw_data = (const __le32 *)
380 (adev->gmc.fw->data + le32_to_cpu(hdr->header.ucode_array_offset_bytes));
382 data = RREG32(mmMC_SEQ_MISC0);
384 WREG32(mmMC_SEQ_MISC0, data);
386 /* load mc io regs */
387 for (i = 0; i < regs_size; i++) {
388 WREG32(mmMC_SEQ_IO_DEBUG_INDEX, le32_to_cpup(io_mc_regs++));
389 WREG32(mmMC_SEQ_IO_DEBUG_DATA, le32_to_cpup(io_mc_regs++));
392 WREG32(mmMC_SEQ_SUP_CNTL, 0x00000008);
393 WREG32(mmMC_SEQ_SUP_CNTL, 0x00000010);
395 /* load the MC ucode */
396 for (i = 0; i < ucode_size; i++)
397 WREG32(mmMC_SEQ_SUP_PGM, le32_to_cpup(fw_data++));
399 /* put the engine back into the active state */
400 WREG32(mmMC_SEQ_SUP_CNTL, 0x00000008);
401 WREG32(mmMC_SEQ_SUP_CNTL, 0x00000004);
402 WREG32(mmMC_SEQ_SUP_CNTL, 0x00000001);
404 /* wait for training to complete */
405 for (i = 0; i < adev->usec_timeout; i++) {
406 data = RREG32(mmMC_SEQ_MISC0);
415 static void gmc_v8_0_vram_gtt_location(struct amdgpu_device *adev,
416 struct amdgpu_gmc *mc)
420 if (!amdgpu_sriov_vf(adev))
421 base = RREG32(mmMC_VM_FB_LOCATION) & 0xFFFF;
424 amdgpu_gmc_vram_location(adev, mc, base);
425 amdgpu_gmc_gart_location(adev, mc);
429 * gmc_v8_0_mc_program - program the GPU memory controller
431 * @adev: amdgpu_device pointer
433 * Set the location of vram, gart, and AGP in the GPU's
434 * physical address space (VI).
436 static void gmc_v8_0_mc_program(struct amdgpu_device *adev)
442 for (i = 0, j = 0; i < 32; i++, j += 0x6) {
443 WREG32((0xb05 + j), 0x00000000);
444 WREG32((0xb06 + j), 0x00000000);
445 WREG32((0xb07 + j), 0x00000000);
446 WREG32((0xb08 + j), 0x00000000);
447 WREG32((0xb09 + j), 0x00000000);
449 WREG32(mmHDP_REG_COHERENCY_FLUSH_CNTL, 0);
451 if (gmc_v8_0_wait_for_idle((void *)adev)) {
452 dev_warn(adev->dev, "Wait for MC idle timedout !\n");
454 if (adev->mode_info.num_crtc) {
455 /* Lockout access through VGA aperture*/
456 tmp = RREG32(mmVGA_HDP_CONTROL);
457 tmp = REG_SET_FIELD(tmp, VGA_HDP_CONTROL, VGA_MEMORY_DISABLE, 1);
458 WREG32(mmVGA_HDP_CONTROL, tmp);
460 /* disable VGA render */
461 tmp = RREG32(mmVGA_RENDER_CONTROL);
462 tmp = REG_SET_FIELD(tmp, VGA_RENDER_CONTROL, VGA_VSTATUS_CNTL, 0);
463 WREG32(mmVGA_RENDER_CONTROL, tmp);
465 /* Update configuration */
466 WREG32(mmMC_VM_SYSTEM_APERTURE_LOW_ADDR,
467 adev->gmc.vram_start >> 12);
468 WREG32(mmMC_VM_SYSTEM_APERTURE_HIGH_ADDR,
469 adev->gmc.vram_end >> 12);
470 WREG32(mmMC_VM_SYSTEM_APERTURE_DEFAULT_ADDR,
471 adev->mem_scratch.gpu_addr >> 12);
473 if (amdgpu_sriov_vf(adev)) {
474 tmp = ((adev->gmc.vram_end >> 24) & 0xFFFF) << 16;
475 tmp |= ((adev->gmc.vram_start >> 24) & 0xFFFF);
476 WREG32(mmMC_VM_FB_LOCATION, tmp);
477 /* XXX double check these! */
478 WREG32(mmHDP_NONSURFACE_BASE, (adev->gmc.vram_start >> 8));
479 WREG32(mmHDP_NONSURFACE_INFO, (2 << 7) | (1 << 30));
480 WREG32(mmHDP_NONSURFACE_SIZE, 0x3FFFFFFF);
483 WREG32(mmMC_VM_AGP_BASE, 0);
484 WREG32(mmMC_VM_AGP_TOP, 0x0FFFFFFF);
485 WREG32(mmMC_VM_AGP_BOT, 0x0FFFFFFF);
486 if (gmc_v8_0_wait_for_idle((void *)adev)) {
487 dev_warn(adev->dev, "Wait for MC idle timedout !\n");
490 WREG32(mmBIF_FB_EN, BIF_FB_EN__FB_READ_EN_MASK | BIF_FB_EN__FB_WRITE_EN_MASK);
492 tmp = RREG32(mmHDP_MISC_CNTL);
493 tmp = REG_SET_FIELD(tmp, HDP_MISC_CNTL, FLUSH_INVALIDATE_CACHE, 0);
494 WREG32(mmHDP_MISC_CNTL, tmp);
496 tmp = RREG32(mmHDP_HOST_PATH_CNTL);
497 WREG32(mmHDP_HOST_PATH_CNTL, tmp);
501 * gmc_v8_0_mc_init - initialize the memory controller driver params
503 * @adev: amdgpu_device pointer
505 * Look up the amount of vram, vram width, and decide how to place
506 * vram and gart within the GPU's physical address space (VI).
507 * Returns 0 for success.
509 static int gmc_v8_0_mc_init(struct amdgpu_device *adev)
514 adev->gmc.vram_width = amdgpu_atombios_get_vram_width(adev);
515 if (!adev->gmc.vram_width) {
516 int chansize, numchan;
518 /* Get VRAM informations */
519 tmp = RREG32(mmMC_ARB_RAMCFG);
520 if (REG_GET_FIELD(tmp, MC_ARB_RAMCFG, CHANSIZE)) {
525 tmp = RREG32(mmMC_SHARED_CHMAP);
526 switch (REG_GET_FIELD(tmp, MC_SHARED_CHMAP, NOOFCHAN)) {
556 adev->gmc.vram_width = numchan * chansize;
558 /* size in MB on si */
559 tmp = RREG32(mmCONFIG_MEMSIZE);
560 /* some boards may have garbage in the upper 16 bits */
561 if (tmp & 0xffff0000) {
562 DRM_INFO("Probable bad vram size: 0x%08x\n", tmp);
566 adev->gmc.mc_vram_size = tmp * 1024ULL * 1024ULL;
567 adev->gmc.real_vram_size = adev->gmc.mc_vram_size;
569 if (!(adev->flags & AMD_IS_APU)) {
570 r = amdgpu_device_resize_fb_bar(adev);
574 adev->gmc.aper_base = pci_resource_start(adev->pdev, 0);
575 adev->gmc.aper_size = pci_resource_len(adev->pdev, 0);
578 if ((adev->flags & AMD_IS_APU) && !amdgpu_passthrough(adev)) {
579 adev->gmc.aper_base = ((u64)RREG32(mmMC_VM_FB_OFFSET)) << 22;
580 adev->gmc.aper_size = adev->gmc.real_vram_size;
584 adev->gmc.visible_vram_size = adev->gmc.aper_size;
586 /* set the gart size */
587 if (amdgpu_gart_size == -1) {
588 switch (adev->asic_type) {
589 case CHIP_POLARIS10: /* all engines support GPUVM */
590 case CHIP_POLARIS11: /* all engines support GPUVM */
591 case CHIP_POLARIS12: /* all engines support GPUVM */
592 case CHIP_VEGAM: /* all engines support GPUVM */
594 adev->gmc.gart_size = 256ULL << 20;
596 case CHIP_TONGA: /* UVD, VCE do not support GPUVM */
597 case CHIP_FIJI: /* UVD, VCE do not support GPUVM */
598 case CHIP_CARRIZO: /* UVD, VCE do not support GPUVM, DCE SG support */
599 case CHIP_STONEY: /* UVD does not support GPUVM, DCE SG support */
600 adev->gmc.gart_size = 1024ULL << 20;
604 adev->gmc.gart_size = (u64)amdgpu_gart_size << 20;
607 adev->gmc.gart_size += adev->pm.smu_prv_buffer_size;
608 gmc_v8_0_vram_gtt_location(adev, &adev->gmc);
614 * gmc_v8_0_flush_gpu_tlb_pasid - tlb flush via pasid
616 * @adev: amdgpu_device pointer
617 * @pasid: pasid to be flush
618 * @flush_type: type of flush
619 * @all_hub: flush all hubs
621 * Flush the TLB for the requested pasid.
623 static int gmc_v8_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,
624 uint16_t pasid, uint32_t flush_type,
630 if (amdgpu_in_reset(adev))
633 for (vmid = 1; vmid < 16; vmid++) {
635 tmp = RREG32(mmATC_VMID0_PASID_MAPPING + vmid);
636 if ((tmp & ATC_VMID0_PASID_MAPPING__VALID_MASK) &&
637 (tmp & ATC_VMID0_PASID_MAPPING__PASID_MASK) == pasid) {
638 WREG32(mmVM_INVALIDATE_REQUEST, 1 << vmid);
639 RREG32(mmVM_INVALIDATE_RESPONSE);
650 * VMID 0 is the physical GPU addresses as used by the kernel.
651 * VMIDs 1-15 are used for userspace clients and are handled
652 * by the amdgpu vm/hsa code.
656 * gmc_v8_0_flush_gpu_tlb - gart tlb flush callback
658 * @adev: amdgpu_device pointer
659 * @vmid: vm instance to flush
660 * @vmhub: which hub to flush
661 * @flush_type: type of flush
663 * Flush the TLB for the requested page table (VI).
665 static void gmc_v8_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,
666 uint32_t vmhub, uint32_t flush_type)
668 /* bits 0-15 are the VM contexts0-15 */
669 WREG32(mmVM_INVALIDATE_REQUEST, 1 << vmid);
672 static uint64_t gmc_v8_0_emit_flush_gpu_tlb(struct amdgpu_ring *ring,
673 unsigned vmid, uint64_t pd_addr)
678 reg = mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR + vmid;
680 reg = mmVM_CONTEXT8_PAGE_TABLE_BASE_ADDR + vmid - 8;
681 amdgpu_ring_emit_wreg(ring, reg, pd_addr >> 12);
683 /* bits 0-15 are the VM contexts0-15 */
684 amdgpu_ring_emit_wreg(ring, mmVM_INVALIDATE_REQUEST, 1 << vmid);
689 static void gmc_v8_0_emit_pasid_mapping(struct amdgpu_ring *ring, unsigned vmid,
692 amdgpu_ring_emit_wreg(ring, mmIH_VMID_0_LUT + vmid, pasid);
698 * 39:12 4k physical page base address
709 * 63:59 block fragment size
711 * 39:1 physical base address of PTE
712 * bits 5:1 must be 0.
716 static void gmc_v8_0_get_vm_pde(struct amdgpu_device *adev, int level,
717 uint64_t *addr, uint64_t *flags)
719 BUG_ON(*addr & 0xFFFFFF0000000FFFULL);
722 static void gmc_v8_0_get_vm_pte(struct amdgpu_device *adev,
723 struct amdgpu_bo_va_mapping *mapping,
726 *flags &= ~AMDGPU_PTE_EXECUTABLE;
727 *flags |= mapping->flags & AMDGPU_PTE_EXECUTABLE;
728 *flags &= ~AMDGPU_PTE_PRT;
732 * gmc_v8_0_set_fault_enable_default - update VM fault handling
734 * @adev: amdgpu_device pointer
735 * @value: true redirects VM faults to the default page
737 static void gmc_v8_0_set_fault_enable_default(struct amdgpu_device *adev,
742 tmp = RREG32(mmVM_CONTEXT1_CNTL);
743 tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
744 RANGE_PROTECTION_FAULT_ENABLE_DEFAULT, value);
745 tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
746 DUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT, value);
747 tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
748 PDE0_PROTECTION_FAULT_ENABLE_DEFAULT, value);
749 tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
750 VALID_PROTECTION_FAULT_ENABLE_DEFAULT, value);
751 tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
752 READ_PROTECTION_FAULT_ENABLE_DEFAULT, value);
753 tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
754 WRITE_PROTECTION_FAULT_ENABLE_DEFAULT, value);
755 tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL,
756 EXECUTE_PROTECTION_FAULT_ENABLE_DEFAULT, value);
757 WREG32(mmVM_CONTEXT1_CNTL, tmp);
761 * gmc_v8_0_set_prt - set PRT VM fault
763 * @adev: amdgpu_device pointer
764 * @enable: enable/disable VM fault handling for PRT
766 static void gmc_v8_0_set_prt(struct amdgpu_device *adev, bool enable)
770 if (enable && !adev->gmc.prt_warning) {
771 dev_warn(adev->dev, "Disabling VM faults because of PRT request!\n");
772 adev->gmc.prt_warning = true;
775 tmp = RREG32(mmVM_PRT_CNTL);
776 tmp = REG_SET_FIELD(tmp, VM_PRT_CNTL,
777 CB_DISABLE_READ_FAULT_ON_UNMAPPED_ACCESS, enable);
778 tmp = REG_SET_FIELD(tmp, VM_PRT_CNTL,
779 CB_DISABLE_WRITE_FAULT_ON_UNMAPPED_ACCESS, enable);
780 tmp = REG_SET_FIELD(tmp, VM_PRT_CNTL,
781 TC_DISABLE_READ_FAULT_ON_UNMAPPED_ACCESS, enable);
782 tmp = REG_SET_FIELD(tmp, VM_PRT_CNTL,
783 TC_DISABLE_WRITE_FAULT_ON_UNMAPPED_ACCESS, enable);
784 tmp = REG_SET_FIELD(tmp, VM_PRT_CNTL,
785 L2_CACHE_STORE_INVALID_ENTRIES, enable);
786 tmp = REG_SET_FIELD(tmp, VM_PRT_CNTL,
787 L1_TLB_STORE_INVALID_ENTRIES, enable);
788 tmp = REG_SET_FIELD(tmp, VM_PRT_CNTL,
789 MASK_PDE0_FAULT, enable);
790 WREG32(mmVM_PRT_CNTL, tmp);
793 uint32_t low = AMDGPU_VA_RESERVED_SIZE >> AMDGPU_GPU_PAGE_SHIFT;
794 uint32_t high = adev->vm_manager.max_pfn -
795 (AMDGPU_VA_RESERVED_SIZE >> AMDGPU_GPU_PAGE_SHIFT);
797 WREG32(mmVM_PRT_APERTURE0_LOW_ADDR, low);
798 WREG32(mmVM_PRT_APERTURE1_LOW_ADDR, low);
799 WREG32(mmVM_PRT_APERTURE2_LOW_ADDR, low);
800 WREG32(mmVM_PRT_APERTURE3_LOW_ADDR, low);
801 WREG32(mmVM_PRT_APERTURE0_HIGH_ADDR, high);
802 WREG32(mmVM_PRT_APERTURE1_HIGH_ADDR, high);
803 WREG32(mmVM_PRT_APERTURE2_HIGH_ADDR, high);
804 WREG32(mmVM_PRT_APERTURE3_HIGH_ADDR, high);
806 WREG32(mmVM_PRT_APERTURE0_LOW_ADDR, 0xfffffff);
807 WREG32(mmVM_PRT_APERTURE1_LOW_ADDR, 0xfffffff);
808 WREG32(mmVM_PRT_APERTURE2_LOW_ADDR, 0xfffffff);
809 WREG32(mmVM_PRT_APERTURE3_LOW_ADDR, 0xfffffff);
810 WREG32(mmVM_PRT_APERTURE0_HIGH_ADDR, 0x0);
811 WREG32(mmVM_PRT_APERTURE1_HIGH_ADDR, 0x0);
812 WREG32(mmVM_PRT_APERTURE2_HIGH_ADDR, 0x0);
813 WREG32(mmVM_PRT_APERTURE3_HIGH_ADDR, 0x0);
818 * gmc_v8_0_gart_enable - gart enable
820 * @adev: amdgpu_device pointer
822 * This sets up the TLBs, programs the page tables for VMID0,
823 * sets up the hw for VMIDs 1-15 which are allocated on
824 * demand, and sets up the global locations for the LDS, GDS,
825 * and GPUVM for FSA64 clients (VI).
826 * Returns 0 for success, errors for failure.
828 static int gmc_v8_0_gart_enable(struct amdgpu_device *adev)
834 if (adev->gart.bo == NULL) {
835 dev_err(adev->dev, "No VRAM object for PCIE GART.\n");
838 amdgpu_gtt_mgr_recover(&adev->mman.gtt_mgr);
839 table_addr = amdgpu_bo_gpu_offset(adev->gart.bo);
841 /* Setup TLB control */
842 tmp = RREG32(mmMC_VM_MX_L1_TLB_CNTL);
843 tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_L1_TLB, 1);
844 tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_L1_FRAGMENT_PROCESSING, 1);
845 tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, SYSTEM_ACCESS_MODE, 3);
846 tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_ADVANCED_DRIVER_MODEL, 1);
847 tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, SYSTEM_APERTURE_UNMAPPED_ACCESS, 0);
848 WREG32(mmMC_VM_MX_L1_TLB_CNTL, tmp);
850 tmp = RREG32(mmVM_L2_CNTL);
851 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_CACHE, 1);
852 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_FRAGMENT_PROCESSING, 1);
853 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_PTE_CACHE_LRU_UPDATE_BY_WRITE, 1);
854 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_PDE0_CACHE_LRU_UPDATE_BY_WRITE, 1);
855 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, EFFECTIVE_L2_QUEUE_SIZE, 7);
856 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, CONTEXT1_IDENTITY_ACCESS_MODE, 1);
857 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_DEFAULT_PAGE_OUT_TO_SYSTEM_MEMORY, 1);
858 WREG32(mmVM_L2_CNTL, tmp);
859 tmp = RREG32(mmVM_L2_CNTL2);
860 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL2, INVALIDATE_ALL_L1_TLBS, 1);
861 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL2, INVALIDATE_L2_CACHE, 1);
862 WREG32(mmVM_L2_CNTL2, tmp);
864 field = adev->vm_manager.fragment_size;
865 tmp = RREG32(mmVM_L2_CNTL3);
866 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, L2_CACHE_BIGK_ASSOCIATIVITY, 1);
867 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, BANK_SELECT, field);
868 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL3, L2_CACHE_BIGK_FRAGMENT_SIZE, field);
869 WREG32(mmVM_L2_CNTL3, tmp);
870 /* XXX: set to enable PTE/PDE in system memory */
871 tmp = RREG32(mmVM_L2_CNTL4);
872 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_CONTEXT0_PDE_REQUEST_PHYSICAL, 0);
873 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_CONTEXT0_PDE_REQUEST_SHARED, 0);
874 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_CONTEXT0_PDE_REQUEST_SNOOP, 0);
875 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_CONTEXT0_PTE_REQUEST_PHYSICAL, 0);
876 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_CONTEXT0_PTE_REQUEST_SHARED, 0);
877 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_CONTEXT0_PTE_REQUEST_SNOOP, 0);
878 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_CONTEXT1_PDE_REQUEST_PHYSICAL, 0);
879 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_CONTEXT1_PDE_REQUEST_SHARED, 0);
880 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_CONTEXT1_PDE_REQUEST_SNOOP, 0);
881 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_CONTEXT1_PTE_REQUEST_PHYSICAL, 0);
882 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_CONTEXT1_PTE_REQUEST_SHARED, 0);
883 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL4, VMC_TAP_CONTEXT1_PTE_REQUEST_SNOOP, 0);
884 WREG32(mmVM_L2_CNTL4, tmp);
886 WREG32(mmVM_CONTEXT0_PAGE_TABLE_START_ADDR, adev->gmc.gart_start >> 12);
887 WREG32(mmVM_CONTEXT0_PAGE_TABLE_END_ADDR, adev->gmc.gart_end >> 12);
888 WREG32(mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR, table_addr >> 12);
889 WREG32(mmVM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR,
890 (u32)(adev->dummy_page_addr >> 12));
891 WREG32(mmVM_CONTEXT0_CNTL2, 0);
892 tmp = RREG32(mmVM_CONTEXT0_CNTL);
893 tmp = REG_SET_FIELD(tmp, VM_CONTEXT0_CNTL, ENABLE_CONTEXT, 1);
894 tmp = REG_SET_FIELD(tmp, VM_CONTEXT0_CNTL, PAGE_TABLE_DEPTH, 0);
895 tmp = REG_SET_FIELD(tmp, VM_CONTEXT0_CNTL, RANGE_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
896 WREG32(mmVM_CONTEXT0_CNTL, tmp);
898 WREG32(mmVM_L2_CONTEXT1_IDENTITY_APERTURE_LOW_ADDR, 0);
899 WREG32(mmVM_L2_CONTEXT1_IDENTITY_APERTURE_HIGH_ADDR, 0);
900 WREG32(mmVM_L2_CONTEXT_IDENTITY_PHYSICAL_OFFSET, 0);
902 /* empty context1-15 */
903 /* FIXME start with 4G, once using 2 level pt switch to full
906 /* set vm size, must be a multiple of 4 */
907 WREG32(mmVM_CONTEXT1_PAGE_TABLE_START_ADDR, 0);
908 WREG32(mmVM_CONTEXT1_PAGE_TABLE_END_ADDR, adev->vm_manager.max_pfn - 1);
909 for (i = 1; i < AMDGPU_NUM_VMID; i++) {
911 WREG32(mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR + i,
914 WREG32(mmVM_CONTEXT8_PAGE_TABLE_BASE_ADDR + i - 8,
918 /* enable context1-15 */
919 WREG32(mmVM_CONTEXT1_PROTECTION_FAULT_DEFAULT_ADDR,
920 (u32)(adev->dummy_page_addr >> 12));
921 WREG32(mmVM_CONTEXT1_CNTL2, 4);
922 tmp = RREG32(mmVM_CONTEXT1_CNTL);
923 tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, ENABLE_CONTEXT, 1);
924 tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, PAGE_TABLE_DEPTH, 1);
925 tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, RANGE_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
926 tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, DUMMY_PAGE_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
927 tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, PDE0_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
928 tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, VALID_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
929 tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, READ_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
930 tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, WRITE_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
931 tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, EXECUTE_PROTECTION_FAULT_ENABLE_DEFAULT, 1);
932 tmp = REG_SET_FIELD(tmp, VM_CONTEXT1_CNTL, PAGE_TABLE_BLOCK_SIZE,
933 adev->vm_manager.block_size - 9);
934 WREG32(mmVM_CONTEXT1_CNTL, tmp);
935 if (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_ALWAYS)
936 gmc_v8_0_set_fault_enable_default(adev, false);
938 gmc_v8_0_set_fault_enable_default(adev, true);
940 gmc_v8_0_flush_gpu_tlb(adev, 0, 0, 0);
941 DRM_INFO("PCIE GART of %uM enabled (table at 0x%016llX).\n",
942 (unsigned)(adev->gmc.gart_size >> 20),
943 (unsigned long long)table_addr);
947 static int gmc_v8_0_gart_init(struct amdgpu_device *adev)
952 WARN(1, "R600 PCIE GART already initialized\n");
955 /* Initialize common gart structure */
956 r = amdgpu_gart_init(adev);
959 adev->gart.table_size = adev->gart.num_gpu_pages * 8;
960 adev->gart.gart_pte_flags = AMDGPU_PTE_EXECUTABLE;
961 return amdgpu_gart_table_vram_alloc(adev);
965 * gmc_v8_0_gart_disable - gart disable
967 * @adev: amdgpu_device pointer
969 * This disables all VM page table (VI).
971 static void gmc_v8_0_gart_disable(struct amdgpu_device *adev)
975 /* Disable all tables */
976 WREG32(mmVM_CONTEXT0_CNTL, 0);
977 WREG32(mmVM_CONTEXT1_CNTL, 0);
978 /* Setup TLB control */
979 tmp = RREG32(mmMC_VM_MX_L1_TLB_CNTL);
980 tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_L1_TLB, 0);
981 tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_L1_FRAGMENT_PROCESSING, 0);
982 tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ENABLE_ADVANCED_DRIVER_MODEL, 0);
983 WREG32(mmMC_VM_MX_L1_TLB_CNTL, tmp);
985 tmp = RREG32(mmVM_L2_CNTL);
986 tmp = REG_SET_FIELD(tmp, VM_L2_CNTL, ENABLE_L2_CACHE, 0);
987 WREG32(mmVM_L2_CNTL, tmp);
988 WREG32(mmVM_L2_CNTL2, 0);
992 * gmc_v8_0_vm_decode_fault - print human readable fault info
994 * @adev: amdgpu_device pointer
995 * @status: VM_CONTEXT1_PROTECTION_FAULT_STATUS register value
996 * @addr: VM_CONTEXT1_PROTECTION_FAULT_ADDR register value
997 * @mc_client: VM_CONTEXT1_PROTECTION_FAULT_MCCLIENT register value
998 * @pasid: debug logging only - no functional use
1000 * Print human readable fault information (VI).
1002 static void gmc_v8_0_vm_decode_fault(struct amdgpu_device *adev, u32 status,
1003 u32 addr, u32 mc_client, unsigned pasid)
1005 u32 vmid = REG_GET_FIELD(status, VM_CONTEXT1_PROTECTION_FAULT_STATUS, VMID);
1006 u32 protections = REG_GET_FIELD(status, VM_CONTEXT1_PROTECTION_FAULT_STATUS,
1008 char block[5] = { mc_client >> 24, (mc_client >> 16) & 0xff,
1009 (mc_client >> 8) & 0xff, mc_client & 0xff, 0 };
1012 mc_id = REG_GET_FIELD(status, VM_CONTEXT1_PROTECTION_FAULT_STATUS,
1015 dev_err(adev->dev, "VM fault (0x%02x, vmid %d, pasid %d) at page %u, %s from '%s' (0x%08x) (%d)\n",
1016 protections, vmid, pasid, addr,
1017 REG_GET_FIELD(status, VM_CONTEXT1_PROTECTION_FAULT_STATUS,
1019 "write" : "read", block, mc_client, mc_id);
1022 static int gmc_v8_0_convert_vram_type(int mc_seq_vram_type)
1024 switch (mc_seq_vram_type) {
1025 case MC_SEQ_MISC0__MT__GDDR1:
1026 return AMDGPU_VRAM_TYPE_GDDR1;
1027 case MC_SEQ_MISC0__MT__DDR2:
1028 return AMDGPU_VRAM_TYPE_DDR2;
1029 case MC_SEQ_MISC0__MT__GDDR3:
1030 return AMDGPU_VRAM_TYPE_GDDR3;
1031 case MC_SEQ_MISC0__MT__GDDR4:
1032 return AMDGPU_VRAM_TYPE_GDDR4;
1033 case MC_SEQ_MISC0__MT__GDDR5:
1034 return AMDGPU_VRAM_TYPE_GDDR5;
1035 case MC_SEQ_MISC0__MT__HBM:
1036 return AMDGPU_VRAM_TYPE_HBM;
1037 case MC_SEQ_MISC0__MT__DDR3:
1038 return AMDGPU_VRAM_TYPE_DDR3;
1040 return AMDGPU_VRAM_TYPE_UNKNOWN;
1044 static int gmc_v8_0_early_init(void *handle)
1046 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1048 gmc_v8_0_set_gmc_funcs(adev);
1049 gmc_v8_0_set_irq_funcs(adev);
1051 adev->gmc.shared_aperture_start = 0x2000000000000000ULL;
1052 adev->gmc.shared_aperture_end =
1053 adev->gmc.shared_aperture_start + (4ULL << 30) - 1;
1054 adev->gmc.private_aperture_start =
1055 adev->gmc.shared_aperture_end + 1;
1056 adev->gmc.private_aperture_end =
1057 adev->gmc.private_aperture_start + (4ULL << 30) - 1;
1062 static int gmc_v8_0_late_init(void *handle)
1064 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1066 if (amdgpu_vm_fault_stop != AMDGPU_VM_FAULT_STOP_ALWAYS)
1067 return amdgpu_irq_get(adev, &adev->gmc.vm_fault, 0);
1072 static unsigned gmc_v8_0_get_vbios_fb_size(struct amdgpu_device *adev)
1074 u32 d1vga_control = RREG32(mmD1VGA_CONTROL);
1077 if (REG_GET_FIELD(d1vga_control, D1VGA_CONTROL, D1VGA_MODE_ENABLE)) {
1078 size = AMDGPU_VBIOS_VGA_ALLOCATION;
1080 u32 viewport = RREG32(mmVIEWPORT_SIZE);
1081 size = (REG_GET_FIELD(viewport, VIEWPORT_SIZE, VIEWPORT_HEIGHT) *
1082 REG_GET_FIELD(viewport, VIEWPORT_SIZE, VIEWPORT_WIDTH) *
1089 #define mmMC_SEQ_MISC0_FIJI 0xA71
1091 static int gmc_v8_0_sw_init(void *handle)
1094 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1096 adev->num_vmhubs = 1;
1098 if (adev->flags & AMD_IS_APU) {
1099 adev->gmc.vram_type = AMDGPU_VRAM_TYPE_UNKNOWN;
1103 if ((adev->asic_type == CHIP_FIJI) ||
1104 (adev->asic_type == CHIP_VEGAM))
1105 tmp = RREG32(mmMC_SEQ_MISC0_FIJI);
1107 tmp = RREG32(mmMC_SEQ_MISC0);
1108 tmp &= MC_SEQ_MISC0__MT__MASK;
1109 adev->gmc.vram_type = gmc_v8_0_convert_vram_type(tmp);
1112 r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_GFX_PAGE_INV_FAULT, &adev->gmc.vm_fault);
1116 r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, VISLANDS30_IV_SRCID_GFX_MEM_PROT_FAULT, &adev->gmc.vm_fault);
1120 /* Adjust VM size here.
1121 * Currently set to 4GB ((1 << 20) 4k pages).
1122 * Max GPUVM size for cayman and SI is 40 bits.
1124 amdgpu_vm_adjust_size(adev, 64, 9, 1, 40);
1126 /* Set the internal MC address mask
1127 * This is the max address of the GPU's
1128 * internal address space.
1130 adev->gmc.mc_mask = 0xffffffffffULL; /* 40 bit MC */
1132 r = dma_set_mask_and_coherent(adev->dev, DMA_BIT_MASK(40));
1134 pr_warn("No suitable DMA available\n");
1137 adev->need_swiotlb = drm_need_swiotlb(40);
1139 r = gmc_v8_0_init_microcode(adev);
1141 DRM_ERROR("Failed to load mc firmware!\n");
1145 r = gmc_v8_0_mc_init(adev);
1149 amdgpu_gmc_get_vbios_allocations(adev);
1151 /* Memory manager */
1152 r = amdgpu_bo_init(adev);
1156 r = gmc_v8_0_gart_init(adev);
1162 * VMID 0 is reserved for System
1163 * amdgpu graphics/compute will use VMIDs 1-7
1164 * amdkfd will use VMIDs 8-15
1166 adev->vm_manager.first_kfd_vmid = 8;
1167 amdgpu_vm_manager_init(adev);
1169 /* base offset of vram pages */
1170 if (adev->flags & AMD_IS_APU) {
1171 u64 tmp = RREG32(mmMC_VM_FB_OFFSET);
1174 adev->vm_manager.vram_base_offset = tmp;
1176 adev->vm_manager.vram_base_offset = 0;
1179 adev->gmc.vm_fault_info = kmalloc(sizeof(struct kfd_vm_fault_info),
1181 if (!adev->gmc.vm_fault_info)
1183 atomic_set(&adev->gmc.vm_fault_info_updated, 0);
1188 static int gmc_v8_0_sw_fini(void *handle)
1190 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1192 amdgpu_gem_force_release(adev);
1193 amdgpu_vm_manager_fini(adev);
1194 kfree(adev->gmc.vm_fault_info);
1195 amdgpu_gart_table_vram_free(adev);
1196 amdgpu_bo_fini(adev);
1197 amdgpu_ucode_release(&adev->gmc.fw);
1202 static int gmc_v8_0_hw_init(void *handle)
1205 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1207 gmc_v8_0_init_golden_registers(adev);
1209 gmc_v8_0_mc_program(adev);
1211 if (adev->asic_type == CHIP_TONGA) {
1212 r = gmc_v8_0_tonga_mc_load_microcode(adev);
1214 DRM_ERROR("Failed to load MC firmware!\n");
1217 } else if (adev->asic_type == CHIP_POLARIS11 ||
1218 adev->asic_type == CHIP_POLARIS10 ||
1219 adev->asic_type == CHIP_POLARIS12) {
1220 r = gmc_v8_0_polaris_mc_load_microcode(adev);
1222 DRM_ERROR("Failed to load MC firmware!\n");
1227 r = gmc_v8_0_gart_enable(adev);
1231 if (amdgpu_emu_mode == 1)
1232 return amdgpu_gmc_vram_checking(adev);
1237 static int gmc_v8_0_hw_fini(void *handle)
1239 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1241 amdgpu_irq_put(adev, &adev->gmc.vm_fault, 0);
1242 gmc_v8_0_gart_disable(adev);
1247 static int gmc_v8_0_suspend(void *handle)
1249 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1251 gmc_v8_0_hw_fini(adev);
1256 static int gmc_v8_0_resume(void *handle)
1259 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1261 r = gmc_v8_0_hw_init(adev);
1265 amdgpu_vmid_reset_all(adev);
1270 static bool gmc_v8_0_is_idle(void *handle)
1272 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1273 u32 tmp = RREG32(mmSRBM_STATUS);
1275 if (tmp & (SRBM_STATUS__MCB_BUSY_MASK | SRBM_STATUS__MCB_NON_DISPLAY_BUSY_MASK |
1276 SRBM_STATUS__MCC_BUSY_MASK | SRBM_STATUS__MCD_BUSY_MASK | SRBM_STATUS__VMC_BUSY_MASK))
1282 static int gmc_v8_0_wait_for_idle(void *handle)
1286 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1288 for (i = 0; i < adev->usec_timeout; i++) {
1289 /* read MC_STATUS */
1290 tmp = RREG32(mmSRBM_STATUS) & (SRBM_STATUS__MCB_BUSY_MASK |
1291 SRBM_STATUS__MCB_NON_DISPLAY_BUSY_MASK |
1292 SRBM_STATUS__MCC_BUSY_MASK |
1293 SRBM_STATUS__MCD_BUSY_MASK |
1294 SRBM_STATUS__VMC_BUSY_MASK |
1295 SRBM_STATUS__VMC1_BUSY_MASK);
1304 static bool gmc_v8_0_check_soft_reset(void *handle)
1306 u32 srbm_soft_reset = 0;
1307 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1308 u32 tmp = RREG32(mmSRBM_STATUS);
1310 if (tmp & SRBM_STATUS__VMC_BUSY_MASK)
1311 srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset,
1312 SRBM_SOFT_RESET, SOFT_RESET_VMC, 1);
1314 if (tmp & (SRBM_STATUS__MCB_BUSY_MASK | SRBM_STATUS__MCB_NON_DISPLAY_BUSY_MASK |
1315 SRBM_STATUS__MCC_BUSY_MASK | SRBM_STATUS__MCD_BUSY_MASK)) {
1316 if (!(adev->flags & AMD_IS_APU))
1317 srbm_soft_reset = REG_SET_FIELD(srbm_soft_reset,
1318 SRBM_SOFT_RESET, SOFT_RESET_MC, 1);
1320 if (srbm_soft_reset) {
1321 adev->gmc.srbm_soft_reset = srbm_soft_reset;
1324 adev->gmc.srbm_soft_reset = 0;
1329 static int gmc_v8_0_pre_soft_reset(void *handle)
1331 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1333 if (!adev->gmc.srbm_soft_reset)
1336 gmc_v8_0_mc_stop(adev);
1337 if (gmc_v8_0_wait_for_idle(adev)) {
1338 dev_warn(adev->dev, "Wait for GMC idle timed out !\n");
1344 static int gmc_v8_0_soft_reset(void *handle)
1346 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1347 u32 srbm_soft_reset;
1349 if (!adev->gmc.srbm_soft_reset)
1351 srbm_soft_reset = adev->gmc.srbm_soft_reset;
1353 if (srbm_soft_reset) {
1356 tmp = RREG32(mmSRBM_SOFT_RESET);
1357 tmp |= srbm_soft_reset;
1358 dev_info(adev->dev, "SRBM_SOFT_RESET=0x%08X\n", tmp);
1359 WREG32(mmSRBM_SOFT_RESET, tmp);
1360 tmp = RREG32(mmSRBM_SOFT_RESET);
1364 tmp &= ~srbm_soft_reset;
1365 WREG32(mmSRBM_SOFT_RESET, tmp);
1366 tmp = RREG32(mmSRBM_SOFT_RESET);
1368 /* Wait a little for things to settle down */
1375 static int gmc_v8_0_post_soft_reset(void *handle)
1377 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1379 if (!adev->gmc.srbm_soft_reset)
1382 gmc_v8_0_mc_resume(adev);
1386 static int gmc_v8_0_vm_fault_interrupt_state(struct amdgpu_device *adev,
1387 struct amdgpu_irq_src *src,
1389 enum amdgpu_interrupt_state state)
1392 u32 bits = (VM_CONTEXT1_CNTL__RANGE_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK |
1393 VM_CONTEXT1_CNTL__DUMMY_PAGE_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK |
1394 VM_CONTEXT1_CNTL__PDE0_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK |
1395 VM_CONTEXT1_CNTL__VALID_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK |
1396 VM_CONTEXT1_CNTL__READ_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK |
1397 VM_CONTEXT1_CNTL__WRITE_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK |
1398 VM_CONTEXT1_CNTL__EXECUTE_PROTECTION_FAULT_ENABLE_INTERRUPT_MASK);
1401 case AMDGPU_IRQ_STATE_DISABLE:
1402 /* system context */
1403 tmp = RREG32(mmVM_CONTEXT0_CNTL);
1405 WREG32(mmVM_CONTEXT0_CNTL, tmp);
1407 tmp = RREG32(mmVM_CONTEXT1_CNTL);
1409 WREG32(mmVM_CONTEXT1_CNTL, tmp);
1411 case AMDGPU_IRQ_STATE_ENABLE:
1412 /* system context */
1413 tmp = RREG32(mmVM_CONTEXT0_CNTL);
1415 WREG32(mmVM_CONTEXT0_CNTL, tmp);
1417 tmp = RREG32(mmVM_CONTEXT1_CNTL);
1419 WREG32(mmVM_CONTEXT1_CNTL, tmp);
1428 static int gmc_v8_0_process_interrupt(struct amdgpu_device *adev,
1429 struct amdgpu_irq_src *source,
1430 struct amdgpu_iv_entry *entry)
1432 u32 addr, status, mc_client, vmid;
1434 if (amdgpu_sriov_vf(adev)) {
1435 dev_err(adev->dev, "GPU fault detected: %d 0x%08x\n",
1436 entry->src_id, entry->src_data[0]);
1437 dev_err(adev->dev, " Can't decode VM fault info here on SRIOV VF\n");
1441 addr = RREG32(mmVM_CONTEXT1_PROTECTION_FAULT_ADDR);
1442 status = RREG32(mmVM_CONTEXT1_PROTECTION_FAULT_STATUS);
1443 mc_client = RREG32(mmVM_CONTEXT1_PROTECTION_FAULT_MCCLIENT);
1444 /* reset addr and status */
1445 WREG32_P(mmVM_CONTEXT1_CNTL2, 1, ~1);
1447 if (!addr && !status)
1450 if (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_FIRST)
1451 gmc_v8_0_set_fault_enable_default(adev, false);
1453 if (printk_ratelimit()) {
1454 struct amdgpu_task_info task_info;
1456 memset(&task_info, 0, sizeof(struct amdgpu_task_info));
1457 amdgpu_vm_get_task_info(adev, entry->pasid, &task_info);
1459 dev_err(adev->dev, "GPU fault detected: %d 0x%08x for process %s pid %d thread %s pid %d\n",
1460 entry->src_id, entry->src_data[0], task_info.process_name,
1461 task_info.tgid, task_info.task_name, task_info.pid);
1462 dev_err(adev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n",
1464 dev_err(adev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n",
1466 gmc_v8_0_vm_decode_fault(adev, status, addr, mc_client,
1470 vmid = REG_GET_FIELD(status, VM_CONTEXT1_PROTECTION_FAULT_STATUS,
1472 if (amdgpu_amdkfd_is_kfd_vmid(adev, vmid)
1473 && !atomic_read(&adev->gmc.vm_fault_info_updated)) {
1474 struct kfd_vm_fault_info *info = adev->gmc.vm_fault_info;
1475 u32 protections = REG_GET_FIELD(status,
1476 VM_CONTEXT1_PROTECTION_FAULT_STATUS,
1480 info->mc_id = REG_GET_FIELD(status,
1481 VM_CONTEXT1_PROTECTION_FAULT_STATUS,
1483 info->status = status;
1484 info->page_addr = addr;
1485 info->prot_valid = protections & 0x7 ? true : false;
1486 info->prot_read = protections & 0x8 ? true : false;
1487 info->prot_write = protections & 0x10 ? true : false;
1488 info->prot_exec = protections & 0x20 ? true : false;
1490 atomic_set(&adev->gmc.vm_fault_info_updated, 1);
1496 static void fiji_update_mc_medium_grain_clock_gating(struct amdgpu_device *adev,
1501 if (enable && (adev->cg_flags & AMD_CG_SUPPORT_MC_MGCG)) {
1502 data = RREG32(mmMC_HUB_MISC_HUB_CG);
1503 data |= MC_HUB_MISC_HUB_CG__ENABLE_MASK;
1504 WREG32(mmMC_HUB_MISC_HUB_CG, data);
1506 data = RREG32(mmMC_HUB_MISC_SIP_CG);
1507 data |= MC_HUB_MISC_SIP_CG__ENABLE_MASK;
1508 WREG32(mmMC_HUB_MISC_SIP_CG, data);
1510 data = RREG32(mmMC_HUB_MISC_VM_CG);
1511 data |= MC_HUB_MISC_VM_CG__ENABLE_MASK;
1512 WREG32(mmMC_HUB_MISC_VM_CG, data);
1514 data = RREG32(mmMC_XPB_CLK_GAT);
1515 data |= MC_XPB_CLK_GAT__ENABLE_MASK;
1516 WREG32(mmMC_XPB_CLK_GAT, data);
1518 data = RREG32(mmATC_MISC_CG);
1519 data |= ATC_MISC_CG__ENABLE_MASK;
1520 WREG32(mmATC_MISC_CG, data);
1522 data = RREG32(mmMC_CITF_MISC_WR_CG);
1523 data |= MC_CITF_MISC_WR_CG__ENABLE_MASK;
1524 WREG32(mmMC_CITF_MISC_WR_CG, data);
1526 data = RREG32(mmMC_CITF_MISC_RD_CG);
1527 data |= MC_CITF_MISC_RD_CG__ENABLE_MASK;
1528 WREG32(mmMC_CITF_MISC_RD_CG, data);
1530 data = RREG32(mmMC_CITF_MISC_VM_CG);
1531 data |= MC_CITF_MISC_VM_CG__ENABLE_MASK;
1532 WREG32(mmMC_CITF_MISC_VM_CG, data);
1534 data = RREG32(mmVM_L2_CG);
1535 data |= VM_L2_CG__ENABLE_MASK;
1536 WREG32(mmVM_L2_CG, data);
1538 data = RREG32(mmMC_HUB_MISC_HUB_CG);
1539 data &= ~MC_HUB_MISC_HUB_CG__ENABLE_MASK;
1540 WREG32(mmMC_HUB_MISC_HUB_CG, data);
1542 data = RREG32(mmMC_HUB_MISC_SIP_CG);
1543 data &= ~MC_HUB_MISC_SIP_CG__ENABLE_MASK;
1544 WREG32(mmMC_HUB_MISC_SIP_CG, data);
1546 data = RREG32(mmMC_HUB_MISC_VM_CG);
1547 data &= ~MC_HUB_MISC_VM_CG__ENABLE_MASK;
1548 WREG32(mmMC_HUB_MISC_VM_CG, data);
1550 data = RREG32(mmMC_XPB_CLK_GAT);
1551 data &= ~MC_XPB_CLK_GAT__ENABLE_MASK;
1552 WREG32(mmMC_XPB_CLK_GAT, data);
1554 data = RREG32(mmATC_MISC_CG);
1555 data &= ~ATC_MISC_CG__ENABLE_MASK;
1556 WREG32(mmATC_MISC_CG, data);
1558 data = RREG32(mmMC_CITF_MISC_WR_CG);
1559 data &= ~MC_CITF_MISC_WR_CG__ENABLE_MASK;
1560 WREG32(mmMC_CITF_MISC_WR_CG, data);
1562 data = RREG32(mmMC_CITF_MISC_RD_CG);
1563 data &= ~MC_CITF_MISC_RD_CG__ENABLE_MASK;
1564 WREG32(mmMC_CITF_MISC_RD_CG, data);
1566 data = RREG32(mmMC_CITF_MISC_VM_CG);
1567 data &= ~MC_CITF_MISC_VM_CG__ENABLE_MASK;
1568 WREG32(mmMC_CITF_MISC_VM_CG, data);
1570 data = RREG32(mmVM_L2_CG);
1571 data &= ~VM_L2_CG__ENABLE_MASK;
1572 WREG32(mmVM_L2_CG, data);
1576 static void fiji_update_mc_light_sleep(struct amdgpu_device *adev,
1581 if (enable && (adev->cg_flags & AMD_CG_SUPPORT_MC_LS)) {
1582 data = RREG32(mmMC_HUB_MISC_HUB_CG);
1583 data |= MC_HUB_MISC_HUB_CG__MEM_LS_ENABLE_MASK;
1584 WREG32(mmMC_HUB_MISC_HUB_CG, data);
1586 data = RREG32(mmMC_HUB_MISC_SIP_CG);
1587 data |= MC_HUB_MISC_SIP_CG__MEM_LS_ENABLE_MASK;
1588 WREG32(mmMC_HUB_MISC_SIP_CG, data);
1590 data = RREG32(mmMC_HUB_MISC_VM_CG);
1591 data |= MC_HUB_MISC_VM_CG__MEM_LS_ENABLE_MASK;
1592 WREG32(mmMC_HUB_MISC_VM_CG, data);
1594 data = RREG32(mmMC_XPB_CLK_GAT);
1595 data |= MC_XPB_CLK_GAT__MEM_LS_ENABLE_MASK;
1596 WREG32(mmMC_XPB_CLK_GAT, data);
1598 data = RREG32(mmATC_MISC_CG);
1599 data |= ATC_MISC_CG__MEM_LS_ENABLE_MASK;
1600 WREG32(mmATC_MISC_CG, data);
1602 data = RREG32(mmMC_CITF_MISC_WR_CG);
1603 data |= MC_CITF_MISC_WR_CG__MEM_LS_ENABLE_MASK;
1604 WREG32(mmMC_CITF_MISC_WR_CG, data);
1606 data = RREG32(mmMC_CITF_MISC_RD_CG);
1607 data |= MC_CITF_MISC_RD_CG__MEM_LS_ENABLE_MASK;
1608 WREG32(mmMC_CITF_MISC_RD_CG, data);
1610 data = RREG32(mmMC_CITF_MISC_VM_CG);
1611 data |= MC_CITF_MISC_VM_CG__MEM_LS_ENABLE_MASK;
1612 WREG32(mmMC_CITF_MISC_VM_CG, data);
1614 data = RREG32(mmVM_L2_CG);
1615 data |= VM_L2_CG__MEM_LS_ENABLE_MASK;
1616 WREG32(mmVM_L2_CG, data);
1618 data = RREG32(mmMC_HUB_MISC_HUB_CG);
1619 data &= ~MC_HUB_MISC_HUB_CG__MEM_LS_ENABLE_MASK;
1620 WREG32(mmMC_HUB_MISC_HUB_CG, data);
1622 data = RREG32(mmMC_HUB_MISC_SIP_CG);
1623 data &= ~MC_HUB_MISC_SIP_CG__MEM_LS_ENABLE_MASK;
1624 WREG32(mmMC_HUB_MISC_SIP_CG, data);
1626 data = RREG32(mmMC_HUB_MISC_VM_CG);
1627 data &= ~MC_HUB_MISC_VM_CG__MEM_LS_ENABLE_MASK;
1628 WREG32(mmMC_HUB_MISC_VM_CG, data);
1630 data = RREG32(mmMC_XPB_CLK_GAT);
1631 data &= ~MC_XPB_CLK_GAT__MEM_LS_ENABLE_MASK;
1632 WREG32(mmMC_XPB_CLK_GAT, data);
1634 data = RREG32(mmATC_MISC_CG);
1635 data &= ~ATC_MISC_CG__MEM_LS_ENABLE_MASK;
1636 WREG32(mmATC_MISC_CG, data);
1638 data = RREG32(mmMC_CITF_MISC_WR_CG);
1639 data &= ~MC_CITF_MISC_WR_CG__MEM_LS_ENABLE_MASK;
1640 WREG32(mmMC_CITF_MISC_WR_CG, data);
1642 data = RREG32(mmMC_CITF_MISC_RD_CG);
1643 data &= ~MC_CITF_MISC_RD_CG__MEM_LS_ENABLE_MASK;
1644 WREG32(mmMC_CITF_MISC_RD_CG, data);
1646 data = RREG32(mmMC_CITF_MISC_VM_CG);
1647 data &= ~MC_CITF_MISC_VM_CG__MEM_LS_ENABLE_MASK;
1648 WREG32(mmMC_CITF_MISC_VM_CG, data);
1650 data = RREG32(mmVM_L2_CG);
1651 data &= ~VM_L2_CG__MEM_LS_ENABLE_MASK;
1652 WREG32(mmVM_L2_CG, data);
1656 static int gmc_v8_0_set_clockgating_state(void *handle,
1657 enum amd_clockgating_state state)
1659 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1661 if (amdgpu_sriov_vf(adev))
1664 switch (adev->asic_type) {
1666 fiji_update_mc_medium_grain_clock_gating(adev,
1667 state == AMD_CG_STATE_GATE);
1668 fiji_update_mc_light_sleep(adev,
1669 state == AMD_CG_STATE_GATE);
1677 static int gmc_v8_0_set_powergating_state(void *handle,
1678 enum amd_powergating_state state)
1683 static void gmc_v8_0_get_clockgating_state(void *handle, u64 *flags)
1685 struct amdgpu_device *adev = (struct amdgpu_device *)handle;
1688 if (amdgpu_sriov_vf(adev))
1691 /* AMD_CG_SUPPORT_MC_MGCG */
1692 data = RREG32(mmMC_HUB_MISC_HUB_CG);
1693 if (data & MC_HUB_MISC_HUB_CG__ENABLE_MASK)
1694 *flags |= AMD_CG_SUPPORT_MC_MGCG;
1696 /* AMD_CG_SUPPORT_MC_LS */
1697 if (data & MC_HUB_MISC_HUB_CG__MEM_LS_ENABLE_MASK)
1698 *flags |= AMD_CG_SUPPORT_MC_LS;
1701 static const struct amd_ip_funcs gmc_v8_0_ip_funcs = {
1703 .early_init = gmc_v8_0_early_init,
1704 .late_init = gmc_v8_0_late_init,
1705 .sw_init = gmc_v8_0_sw_init,
1706 .sw_fini = gmc_v8_0_sw_fini,
1707 .hw_init = gmc_v8_0_hw_init,
1708 .hw_fini = gmc_v8_0_hw_fini,
1709 .suspend = gmc_v8_0_suspend,
1710 .resume = gmc_v8_0_resume,
1711 .is_idle = gmc_v8_0_is_idle,
1712 .wait_for_idle = gmc_v8_0_wait_for_idle,
1713 .check_soft_reset = gmc_v8_0_check_soft_reset,
1714 .pre_soft_reset = gmc_v8_0_pre_soft_reset,
1715 .soft_reset = gmc_v8_0_soft_reset,
1716 .post_soft_reset = gmc_v8_0_post_soft_reset,
1717 .set_clockgating_state = gmc_v8_0_set_clockgating_state,
1718 .set_powergating_state = gmc_v8_0_set_powergating_state,
1719 .get_clockgating_state = gmc_v8_0_get_clockgating_state,
1722 static const struct amdgpu_gmc_funcs gmc_v8_0_gmc_funcs = {
1723 .flush_gpu_tlb = gmc_v8_0_flush_gpu_tlb,
1724 .flush_gpu_tlb_pasid = gmc_v8_0_flush_gpu_tlb_pasid,
1725 .emit_flush_gpu_tlb = gmc_v8_0_emit_flush_gpu_tlb,
1726 .emit_pasid_mapping = gmc_v8_0_emit_pasid_mapping,
1727 .set_prt = gmc_v8_0_set_prt,
1728 .get_vm_pde = gmc_v8_0_get_vm_pde,
1729 .get_vm_pte = gmc_v8_0_get_vm_pte,
1730 .get_vbios_fb_size = gmc_v8_0_get_vbios_fb_size,
1733 static const struct amdgpu_irq_src_funcs gmc_v8_0_irq_funcs = {
1734 .set = gmc_v8_0_vm_fault_interrupt_state,
1735 .process = gmc_v8_0_process_interrupt,
1738 static void gmc_v8_0_set_gmc_funcs(struct amdgpu_device *adev)
1740 adev->gmc.gmc_funcs = &gmc_v8_0_gmc_funcs;
1743 static void gmc_v8_0_set_irq_funcs(struct amdgpu_device *adev)
1745 adev->gmc.vm_fault.num_types = 1;
1746 adev->gmc.vm_fault.funcs = &gmc_v8_0_irq_funcs;
1749 const struct amdgpu_ip_block_version gmc_v8_0_ip_block =
1751 .type = AMD_IP_BLOCK_TYPE_GMC,
1755 .funcs = &gmc_v8_0_ip_funcs,
1758 const struct amdgpu_ip_block_version gmc_v8_1_ip_block =
1760 .type = AMD_IP_BLOCK_TYPE_GMC,
1764 .funcs = &gmc_v8_0_ip_funcs,
1767 const struct amdgpu_ip_block_version gmc_v8_5_ip_block =
1769 .type = AMD_IP_BLOCK_TYPE_GMC,
1773 .funcs = &gmc_v8_0_ip_funcs,