drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c- Extension
.c- Size
- 48864 bytes
- Lines
- 1701
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/firmware.hlinux/module.hamdgpu.hamdgpu_ucode.hamdgpu_trace.hvi.hvid.hoss/oss_3_0_d.hoss/oss_3_0_sh_mask.hgmc/gmc_8_1_d.hgmc/gmc_8_1_sh_mask.hgca/gfx_8_0_d.hgca/gfx_8_0_enum.hgca/gfx_8_0_sh_mask.hbif/bif_5_0_d.hbif/bif_5_0_sh_mask.htonga_sdma_pkt_open.hivsrcid/ivsrcid_vislands30.h
Detected Declarations
function sdma_v3_0_init_golden_registersfunction sdma_v3_0_free_microcodefunction driverfunction hardwarefunction hardwarefunction hardwarefunction sdma_v3_0_ring_insert_nopfunction ringfunction sdma_v3_0_ring_emit_hdp_flushfunction neededfunction buffersfunction queuesfunction enginesfunction themfunction themfunction themfunction sdma_v3_0_ring_test_ringfunction ringfunction sDMAfunction sDMAfunction sDMAfunction sdma_v3_0_ring_pad_ibfunction completedfunction sDMAfunction sdma_v3_0_ring_emit_wregfunction sdma_v3_0_early_initfunction sdma_v3_0_sw_initfunction sdma_v3_0_sw_finifunction sdma_v3_0_hw_initfunction sdma_v3_0_hw_finifunction sdma_v3_0_suspendfunction sdma_v3_0_resumefunction sdma_v3_0_is_idlefunction sdma_v3_0_wait_for_idlefunction sdma_v3_0_check_soft_resetfunction sdma_v3_0_pre_soft_resetfunction sdma_v3_0_post_soft_resetfunction sdma_v3_0_soft_resetfunction sdma_v3_0_set_trap_irq_statefunction sdma_v3_0_process_trap_irqfunction sdma_v3_0_process_illegal_inst_irqfunction sdma_v3_0_update_sdma_medium_grain_clock_gatingfunction sdma_v3_0_update_sdma_medium_grain_light_sleepfunction sdma_v3_0_set_clockgating_statefunction sdma_v3_0_set_powergating_statefunction sdma_v3_0_get_clockgating_statefunction sdma_v3_0_set_ring_funcsfunction sdma_v3_0_set_irq_funcs
Annotated Snippet
if (enable) {
f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL,
AUTO_CTXSW_ENABLE, 1);
f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL,
ATC_L1_ENABLE, 1);
if (amdgpu_sdma_phase_quantum) {
WREG32(mmSDMA0_PHASE0_QUANTUM + sdma_offsets[i],
phase_quantum);
WREG32(mmSDMA0_PHASE1_QUANTUM + sdma_offsets[i],
phase_quantum);
}
} else {
f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL,
AUTO_CTXSW_ENABLE, 0);
f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL,
ATC_L1_ENABLE, 1);
}
WREG32(mmSDMA0_CNTL + sdma_offsets[i], f32_cntl);
}
}
/**
* sdma_v3_0_enable - stop the async dma engines
*
* @adev: amdgpu_device pointer
* @enable: enable/disable the DMA MEs.
*
* Halt or unhalt the async dma engines (VI).
*/
static void sdma_v3_0_enable(struct amdgpu_device *adev, bool enable)
{
u32 f32_cntl;
int i;
if (!enable) {
sdma_v3_0_gfx_stop(adev);
sdma_v3_0_rlc_stop(adev);
}
for (i = 0; i < adev->sdma.num_instances; i++) {
f32_cntl = RREG32(mmSDMA0_F32_CNTL + sdma_offsets[i]);
if (enable)
f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_F32_CNTL, HALT, 0);
else
f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_F32_CNTL, HALT, 1);
WREG32(mmSDMA0_F32_CNTL + sdma_offsets[i], f32_cntl);
}
}
/**
* sdma_v3_0_gfx_resume - setup and start the async dma engines
*
* @adev: amdgpu_device pointer
*
* Set up the gfx DMA ring buffers and enable them (VI).
* Returns 0 for success, error for failure.
*/
static int sdma_v3_0_gfx_resume(struct amdgpu_device *adev)
{
struct amdgpu_ring *ring;
u32 rb_cntl, ib_cntl, wptr_poll_cntl;
u32 rb_bufsz;
u32 doorbell;
u64 wptr_gpu_addr;
int i, j, r;
for (i = 0; i < adev->sdma.num_instances; i++) {
ring = &adev->sdma.instance[i].ring;
amdgpu_ring_clear_ring(ring);
mutex_lock(&adev->srbm_mutex);
for (j = 0; j < 16; j++) {
vi_srbm_select(adev, 0, 0, 0, j);
/* SDMA GFX */
WREG32(mmSDMA0_GFX_VIRTUAL_ADDR + sdma_offsets[i], 0);
WREG32(mmSDMA0_GFX_APE1_CNTL + sdma_offsets[i], 0);
}
vi_srbm_select(adev, 0, 0, 0, 0);
mutex_unlock(&adev->srbm_mutex);
WREG32(mmSDMA0_TILING_CONFIG + sdma_offsets[i],
adev->gfx.config.gb_addr_config & 0x70);
WREG32(mmSDMA0_SEM_WAIT_FAIL_TIMER_CNTL + sdma_offsets[i], 0);
/* Set ring buffer size in dwords */
rb_bufsz = order_base_2(ring->ring_size / 4);
rb_cntl = RREG32(mmSDMA0_GFX_RB_CNTL + sdma_offsets[i]);
rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_SIZE, rb_bufsz);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/firmware.h`, `linux/module.h`, `amdgpu.h`, `amdgpu_ucode.h`, `amdgpu_trace.h`, `vi.h`, `vid.h`.
- Detected declarations: `function sdma_v3_0_init_golden_registers`, `function sdma_v3_0_free_microcode`, `function driver`, `function hardware`, `function hardware`, `function hardware`, `function sdma_v3_0_ring_insert_nop`, `function ring`, `function sdma_v3_0_ring_emit_hdp_flush`, `function needed`.
- 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.
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.