drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c- Extension
.c- Size
- 52071 bytes
- Lines
- 1777
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/firmware.hlinux/module.hlinux/pci.hdrm/drm_cache.hamdgpu.hgmc_v8_0.hamdgpu_ucode.hamdgpu_amdkfd.hamdgpu_gem.hgmc/gmc_8_1_d.hgmc/gmc_8_1_sh_mask.hbif/bif_5_0_d.hbif/bif_5_0_sh_mask.hoss/oss_3_0_d.hoss/oss_3_0_sh_mask.hdce/dce_10_0_d.hdce/dce_10_0_sh_mask.hvid.hvi.hamdgpu_atombios.hivsrcid/ivsrcid_vislands30.h
Detected Declarations
function gmc_v8_0_init_golden_registersfunction gmc_v8_0_mc_stopfunction gmc_v8_0_mc_resumefunction driverfunction hwfunction gmc_v8_0_polaris_mc_load_microcodefunction gmc_v8_0_vram_gtt_locationfunction spacefunction gmc_v8_0_mc_initfunction gmc_v8_0_flush_gpu_tlb_pasidfunction tablefunction gmc_v8_0_emit_flush_gpu_tlbfunction gmc_v8_0_emit_pasid_mappingfunction gmc_v8_0_get_vm_pdefunction gmc_v8_0_get_vm_ptefunction gmc_v8_0_set_fault_enable_defaultfunction gmc_v8_0_set_prtfunction clientsfunction gmc_v8_0_gart_initfunction tablefunction informationfunction gmc_v8_0_convert_vram_typefunction gmc_v8_0_early_initfunction gmc_v8_0_late_initfunction gmc_v8_0_get_vbios_fb_sizefunction gmc_v8_0_sw_initfunction gmc_v8_0_sw_finifunction gmc_v8_0_hw_initfunction gmc_v8_0_hw_finifunction gmc_v8_0_suspendfunction gmc_v8_0_resumefunction gmc_v8_0_is_idlefunction gmc_v8_0_wait_for_idlefunction gmc_v8_0_check_soft_resetfunction gmc_v8_0_pre_soft_resetfunction gmc_v8_0_soft_resetfunction gmc_v8_0_post_soft_resetfunction gmc_v8_0_vm_fault_interrupt_statefunction gmc_v8_0_process_interruptfunction fiji_update_mc_medium_grain_clock_gatingfunction fiji_update_mc_light_sleepfunction gmc_v8_0_set_clockgating_statefunction gmc_v8_0_set_powergating_statefunction gmc_v8_0_get_clockgating_statefunction gmc_v8_0_set_gmc_funcsfunction gmc_v8_0_set_irq_funcs
Annotated Snippet
if (ASICID_IS_P23(adev->pdev->device, adev->pdev->revision)) {
chip_name = "polaris12_k";
} else {
WREG32(mmMC_SEQ_IO_DEBUG_INDEX, ixMC_IO_DEBUG_UP_159);
/* Polaris12 32bit ASIC needs a special MC firmware */
if (RREG32(mmMC_SEQ_IO_DEBUG_DATA) == 0x05b4dc40)
chip_name = "polaris12_32";
else
chip_name = "polaris12";
}
break;
case CHIP_FIJI:
case CHIP_CARRIZO:
case CHIP_STONEY:
case CHIP_VEGAM:
return 0;
default:
return -EINVAL;
}
err = amdgpu_ucode_request(adev, &adev->gmc.fw, AMDGPU_UCODE_REQUIRED,
"amdgpu/%s_mc.bin", chip_name);
if (err) {
pr_err("mc: Failed to load firmware \"%s_mc.bin\"\n", chip_name);
amdgpu_ucode_release(&adev->gmc.fw);
}
return err;
}
/**
* gmc_v8_0_tonga_mc_load_microcode - load tonga MC ucode into the hw
*
* @adev: amdgpu_device pointer
*
* Load the GDDR MC ucode into the hw (VI).
* Returns 0 on success, error on failure.
*/
static int gmc_v8_0_tonga_mc_load_microcode(struct amdgpu_device *adev)
{
const struct mc_firmware_header_v1_0 *hdr;
const __le32 *fw_data = NULL;
const __le32 *io_mc_regs = NULL;
u32 running;
int i, ucode_size, regs_size;
/* Skip MC ucode loading on SR-IOV capable boards.
* vbios does this for us in asic_init in that case.
* Skip MC ucode loading on VF, because hypervisor will do that
* for this adaptor.
*/
if (amdgpu_sriov_bios(adev))
return 0;
if (!adev->gmc.fw)
return -EINVAL;
hdr = (const struct mc_firmware_header_v1_0 *)adev->gmc.fw->data;
amdgpu_ucode_print_mc_hdr(&hdr->header);
adev->gmc.fw_version = le32_to_cpu(hdr->header.ucode_version);
regs_size = le32_to_cpu(hdr->io_debug_size_bytes) / (4 * 2);
io_mc_regs = (const __le32 *)
(adev->gmc.fw->data + le32_to_cpu(hdr->io_debug_array_offset_bytes));
ucode_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4;
fw_data = (const __le32 *)
(adev->gmc.fw->data + le32_to_cpu(hdr->header.ucode_array_offset_bytes));
running = REG_GET_FIELD(RREG32(mmMC_SEQ_SUP_CNTL), MC_SEQ_SUP_CNTL, RUN);
if (running == 0) {
/* reset the engine and set to writable */
WREG32(mmMC_SEQ_SUP_CNTL, 0x00000008);
WREG32(mmMC_SEQ_SUP_CNTL, 0x00000010);
/* load mc io regs */
for (i = 0; i < regs_size; i++) {
WREG32(mmMC_SEQ_IO_DEBUG_INDEX, le32_to_cpup(io_mc_regs++));
WREG32(mmMC_SEQ_IO_DEBUG_DATA, le32_to_cpup(io_mc_regs++));
}
/* load the MC ucode */
for (i = 0; i < ucode_size; i++)
WREG32(mmMC_SEQ_SUP_PGM, le32_to_cpup(fw_data++));
/* put the engine back into the active state */
WREG32(mmMC_SEQ_SUP_CNTL, 0x00000008);
WREG32(mmMC_SEQ_SUP_CNTL, 0x00000004);
WREG32(mmMC_SEQ_SUP_CNTL, 0x00000001);
/* wait for training to complete */
for (i = 0; i < adev->usec_timeout; i++) {
Annotation
- Immediate include surface: `linux/firmware.h`, `linux/module.h`, `linux/pci.h`, `drm/drm_cache.h`, `amdgpu.h`, `gmc_v8_0.h`, `amdgpu_ucode.h`, `amdgpu_amdkfd.h`.
- Detected declarations: `function gmc_v8_0_init_golden_registers`, `function gmc_v8_0_mc_stop`, `function gmc_v8_0_mc_resume`, `function driver`, `function hw`, `function gmc_v8_0_polaris_mc_load_microcode`, `function gmc_v8_0_vram_gtt_location`, `function space`, `function gmc_v8_0_mc_init`, `function gmc_v8_0_flush_gpu_tlb_pasid`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.