drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c- Extension
.c- Size
- 68072 bytes
- Lines
- 2067
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/firmware.hlinux/module.hlinux/pci.hamdgpu.hamdgpu_ucode.hamdgpu_trace.hgc/gc_10_1_0_offset.hgc/gc_10_1_0_sh_mask.hivsrcid/sdma0/irqsrcs_sdma0_5_0.hivsrcid/sdma1/irqsrcs_sdma1_5_0.hsoc15_common.hsoc15.hnavi10_sdma_pkt_open.hnbio_v2_3.hsdma_common.hsdma_v5_0.h
Detected Declarations
function sdma_v5_0_get_reg_offsetfunction sdma_v5_0_init_golden_registersfunction driverfunction sdma_v5_0_ring_init_cond_execfunction hardwarefunction hardwarefunction hardwarefunction sdma_v5_0_ring_insert_nopfunction ringfunction sdma_v5_0_ring_emit_mem_syncfunction sdma_v5_0_ring_emit_hdp_flushfunction neededfunction buffersfunction for_each_instfunction queuesfunction enginesfunction sdma_v5_0_gfx_resume_instancefunction themfunction themfunction sdma_v5_0_load_microcodefunction themfunction sdma_v5_0_mqd_initfunction sdma_v5_0_set_mqd_funcsfunction sdma_v5_0_ring_test_ringfunction ringfunction sDMAfunction sDMAfunction sDMAfunction sdma_v5_0_ring_pad_ibfunction completedfunction sDMAfunction sdma_v5_0_ring_emit_wregfunction sdma_v5_0_ring_emit_reg_waitfunction sdma_v5_0_ring_emit_reg_write_reg_waitfunction sdma_v5_0_soft_reset_enginefunction sdma_v5_0_early_initfunction sdma_v5_0_sw_initfunction sdma_v5_0_sw_finifunction sdma_v5_0_hw_initfunction sdma_v5_0_hw_finifunction sdma_v5_0_suspendfunction sdma_v5_0_resumefunction sdma_v5_0_is_idlefunction sdma_v5_0_wait_for_idlefunction sdma_v5_0_soft_resetfunction sdma_v5_0_reset_queuefunction sdma_v5_0_stop_queuefunction sdma_v5_0_restore_queue
Annotated Snippet
if (!amdgpu_sriov_vf(adev)) {
f32_cntl = RREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_CNTL));
f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL,
AUTO_CTXSW_ENABLE, enable ? 1 : 0);
}
if (enable && amdgpu_sdma_phase_quantum) {
WREG32_SOC15_IP(GC, sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_PHASE0_QUANTUM),
phase_quantum);
WREG32_SOC15_IP(GC, sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_PHASE1_QUANTUM),
phase_quantum);
WREG32_SOC15_IP(GC, sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_PHASE2_QUANTUM),
phase_quantum);
}
if (!amdgpu_sriov_vf(adev))
WREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_CNTL), f32_cntl);
}
}
/**
* sdma_v5_0_enable - stop the async dma engines
*
* @adev: amdgpu_device pointer
* @enable: enable/disable the DMA MEs.
*
* Halt or unhalt the async dma engines (NAVI10).
*/
static void sdma_v5_0_enable(struct amdgpu_device *adev, bool enable)
{
u32 f32_cntl;
int i;
uint32_t inst_mask;
inst_mask = GENMASK(adev->sdma.num_instances - 1, 0);
if (!enable) {
sdma_v5_0_gfx_stop(adev, 1 << inst_mask);
sdma_v5_0_rlc_stop(adev);
}
if (amdgpu_sriov_vf(adev))
return;
for (i = 0; i < adev->sdma.num_instances; i++) {
f32_cntl = RREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_F32_CNTL));
f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_F32_CNTL, HALT, enable ? 0 : 1);
WREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_F32_CNTL), f32_cntl);
}
}
/**
* sdma_v5_0_gfx_resume_instance - start/restart a certain sdma engine
*
* @adev: amdgpu_device pointer
* @i: instance
* @restore: used to restore wptr when restart
*
* Set up the gfx DMA ring buffers and enable them. On restart, we will restore wptr and rptr.
* Return 0 for success.
*/
static int sdma_v5_0_gfx_resume_instance(struct amdgpu_device *adev, int i, bool restore)
{
struct amdgpu_ring *ring;
u32 rb_cntl, ib_cntl;
u32 rb_bufsz;
u32 doorbell;
u32 doorbell_offset;
u32 temp;
u32 wptr_poll_cntl;
u64 wptr_gpu_addr;
ring = &adev->sdma.instance[i].ring;
if (!amdgpu_sriov_vf(adev))
WREG32(sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_SEM_WAIT_FAIL_TIMER_CNTL), 0);
/* Set ring buffer size in dwords */
rb_bufsz = order_base_2(ring->ring_size / 4);
rb_cntl = RREG32_SOC15_IP(GC, sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL));
rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_SIZE, rb_bufsz);
#ifdef __BIG_ENDIAN
rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL, RB_SWAP_ENABLE, 1);
rb_cntl = REG_SET_FIELD(rb_cntl, SDMA0_GFX_RB_CNTL,
RPTR_WRITEBACK_SWAP_ENABLE, 1);
#endif
WREG32_SOC15_IP(GC, sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_CNTL), rb_cntl);
/* Initialize the ring buffer's read and write pointers */
if (restore) {
WREG32_SOC15_IP(GC, sdma_v5_0_get_reg_offset(adev, i, mmSDMA0_GFX_RB_RPTR), lower_32_bits(ring->wptr << 2));
Annotation
- Immediate include surface: `linux/delay.h`, `linux/firmware.h`, `linux/module.h`, `linux/pci.h`, `amdgpu.h`, `amdgpu_ucode.h`, `amdgpu_trace.h`, `gc/gc_10_1_0_offset.h`.
- Detected declarations: `function sdma_v5_0_get_reg_offset`, `function sdma_v5_0_init_golden_registers`, `function driver`, `function sdma_v5_0_ring_init_cond_exec`, `function hardware`, `function hardware`, `function hardware`, `function sdma_v5_0_ring_insert_nop`, `function ring`, `function sdma_v5_0_ring_emit_mem_sync`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
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.