drivers/gpu/drm/amd/amdgpu/vi.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/vi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/vi.c- Extension
.c- Size
- 60537 bytes
- Lines
- 2187
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/pci.hlinux/slab.hdrm/amdgpu_drm.hamdgpu.hamdgpu_atombios.hamdgpu_ih.hamdgpu_uvd.hamdgpu_vce.hamdgpu_ucode.hatom.hamd_pcie.hgmc/gmc_8_1_d.hgmc/gmc_8_1_sh_mask.hoss/oss_3_0_d.hoss/oss_3_0_sh_mask.hbif/bif_5_0_d.hbif/bif_5_0_sh_mask.hgca/gfx_8_0_d.hgca/gfx_8_0_sh_mask.hsmu/smu_7_1_1_d.hsmu/smu_7_1_1_sh_mask.huvd/uvd_5_0_d.huvd/uvd_5_0_sh_mask.hvce/vce_3_0_d.hvce/vce_3_0_sh_mask.hdce/dce_10_0_d.hdce/dce_10_0_sh_mask.hvid.hvi.hgmc_v8_0.hgmc_v7_0.hgfx_v8_0.h
Detected Declarations
function vi_query_video_codecsfunction vi_pcie_rregfunction vi_pcie_wregfunction vi_smc_rregfunction vi_smc_wregfunction cz_smc_rregfunction cz_smc_wregfunction vi_uvd_ctx_rregfunction vi_uvd_ctx_wregfunction vi_didt_rregfunction vi_didt_wregfunction vi_gc_cac_rregfunction vi_gc_cac_wregfunction vi_init_golden_registersfunction vi_get_xclkfunction vi_srbm_selectfunction vi_read_disabled_biosfunction vi_read_bios_from_romfunction vi_get_register_valuefunction vi_read_registerfunction vi_asic_pci_config_resetfunction vi_asic_supports_bacofunction vi_asic_reset_methodfunction vi_asic_resetfunction vi_get_config_memsizefunction vi_set_uvd_clockfunction vi_set_uvd_clocksfunction vi_set_vce_clocksfunction vi_enable_aspmfunction vi_program_aspmfunction vi_enable_doorbell_aperturefunction vi_get_rev_idfunction vi_flush_hdpfunction vi_invalidate_hdpfunction vi_need_full_resetfunction vi_get_pcie_usagefunction vi_get_pcie_replay_countfunction vi_need_reset_on_initfunction vi_common_early_initfunction vi_common_late_initfunction vi_common_sw_initfunction vi_common_hw_initfunction vi_common_hw_finifunction vi_common_suspendfunction vi_common_resumefunction vi_common_is_idlefunction vi_update_bif_medium_grain_light_sleepfunction vi_update_hdp_medium_grain_clock_gating
Annotated Snippet
switch (adev->asic_type) {
case CHIP_STONEY:
/* vbios says 48Mhz, but the actual freq is 100Mhz */
return 10000;
default:
return reference_clock;
}
}
tmp = RREG32_SMC(ixCG_CLKPIN_CNTL_2);
if (REG_GET_FIELD(tmp, CG_CLKPIN_CNTL_2, MUX_TCLK_TO_XCLK))
return 1000;
tmp = RREG32_SMC(ixCG_CLKPIN_CNTL);
if (REG_GET_FIELD(tmp, CG_CLKPIN_CNTL, XTALIN_DIVIDE))
return reference_clock / 4;
return reference_clock;
}
/**
* vi_srbm_select - select specific register instances
*
* @adev: amdgpu_device pointer
* @me: selected ME (micro engine)
* @pipe: pipe
* @queue: queue
* @vmid: VMID
*
* Switches the currently active registers instances. Some
* registers are instanced per VMID, others are instanced per
* me/pipe/queue combination.
*/
void vi_srbm_select(struct amdgpu_device *adev,
u32 me, u32 pipe, u32 queue, u32 vmid)
{
u32 srbm_gfx_cntl = 0;
srbm_gfx_cntl = REG_SET_FIELD(srbm_gfx_cntl, SRBM_GFX_CNTL, PIPEID, pipe);
srbm_gfx_cntl = REG_SET_FIELD(srbm_gfx_cntl, SRBM_GFX_CNTL, MEID, me);
srbm_gfx_cntl = REG_SET_FIELD(srbm_gfx_cntl, SRBM_GFX_CNTL, VMID, vmid);
srbm_gfx_cntl = REG_SET_FIELD(srbm_gfx_cntl, SRBM_GFX_CNTL, QUEUEID, queue);
WREG32(mmSRBM_GFX_CNTL, srbm_gfx_cntl);
}
static bool vi_read_disabled_bios(struct amdgpu_device *adev)
{
u32 bus_cntl;
u32 d1vga_control = 0;
u32 d2vga_control = 0;
u32 vga_render_control = 0;
u32 rom_cntl;
bool r;
bus_cntl = RREG32(mmBUS_CNTL);
if (adev->mode_info.num_crtc) {
d1vga_control = RREG32(mmD1VGA_CONTROL);
d2vga_control = RREG32(mmD2VGA_CONTROL);
vga_render_control = RREG32(mmVGA_RENDER_CONTROL);
}
rom_cntl = RREG32_SMC(ixROM_CNTL);
/* enable the rom */
WREG32(mmBUS_CNTL, (bus_cntl & ~BUS_CNTL__BIOS_ROM_DIS_MASK));
if (adev->mode_info.num_crtc) {
/* Disable VGA mode */
WREG32(mmD1VGA_CONTROL,
(d1vga_control & ~(D1VGA_CONTROL__D1VGA_MODE_ENABLE_MASK |
D1VGA_CONTROL__D1VGA_TIMING_SELECT_MASK)));
WREG32(mmD2VGA_CONTROL,
(d2vga_control & ~(D2VGA_CONTROL__D2VGA_MODE_ENABLE_MASK |
D2VGA_CONTROL__D2VGA_TIMING_SELECT_MASK)));
WREG32(mmVGA_RENDER_CONTROL,
(vga_render_control & ~VGA_RENDER_CONTROL__VGA_VSTATUS_CNTL_MASK));
}
WREG32_SMC(ixROM_CNTL, rom_cntl | ROM_CNTL__SCK_OVERWRITE_MASK);
r = amdgpu_read_bios(adev);
/* restore regs */
WREG32(mmBUS_CNTL, bus_cntl);
if (adev->mode_info.num_crtc) {
WREG32(mmD1VGA_CONTROL, d1vga_control);
WREG32(mmD2VGA_CONTROL, d2vga_control);
WREG32(mmVGA_RENDER_CONTROL, vga_render_control);
}
WREG32_SMC(ixROM_CNTL, rom_cntl);
return r;
}
static bool vi_read_bios_from_rom(struct amdgpu_device *adev,
Annotation
- Immediate include surface: `linux/pci.h`, `linux/slab.h`, `drm/amdgpu_drm.h`, `amdgpu.h`, `amdgpu_atombios.h`, `amdgpu_ih.h`, `amdgpu_uvd.h`, `amdgpu_vce.h`.
- Detected declarations: `function vi_query_video_codecs`, `function vi_pcie_rreg`, `function vi_pcie_wreg`, `function vi_smc_rreg`, `function vi_smc_wreg`, `function cz_smc_rreg`, `function cz_smc_wreg`, `function vi_uvd_ctx_rreg`, `function vi_uvd_ctx_wreg`, `function vi_didt_rreg`.
- 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.