drivers/gpu/drm/amd/amdgpu/cik_sdma.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/cik_sdma.c- Extension
.c- Size
- 37440 bytes
- Lines
- 1360
- 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/firmware.hlinux/module.hamdgpu.hamdgpu_ucode.hamdgpu_trace.hcikd.hcik.hbif/bif_4_1_d.hbif/bif_4_1_sh_mask.hgca/gfx_7_2_d.hgca/gfx_7_2_enum.hgca/gfx_7_2_sh_mask.hgmc/gmc_7_1_d.hgmc/gmc_7_1_sh_mask.hoss/oss_2_0_d.hoss/oss_2_0_sh_mask.h
Detected Declarations
function cik_sdma_free_microcodefunction driverfunction hardwarefunction hardwarefunction hardwarefunction cik_sdma_ring_insert_nopfunction ringfunction cik_sdma_ring_emit_hdp_flushfunction neededfunction buffersfunction queuesfunction enginesfunction themfunction themfunction cik_sdma_load_microcodefunction themfunction cik_sdma_ring_test_ringfunction ringfunction sDMAfunction sDMAfunction sDMAfunction cik_sdma_ring_pad_ibfunction completedfunction sDMAfunction cik_sdma_ring_emit_wregfunction cik_enable_sdma_mgcgfunction cik_enable_sdma_mglsfunction cik_sdma_early_initfunction cik_sdma_sw_initfunction cik_sdma_sw_finifunction cik_sdma_hw_initfunction cik_sdma_hw_finifunction cik_sdma_suspendfunction cik_sdma_resumefunction cik_sdma_is_idlefunction cik_sdma_wait_for_idlefunction cik_sdma_soft_resetfunction cik_sdma_set_trap_irq_statefunction cik_sdma_process_trap_irqfunction cik_sdma_process_illegal_inst_irqfunction cik_sdma_set_clockgating_statefunction cik_sdma_set_powergating_statefunction cik_sdma_set_ring_funcsfunction cik_sdma_set_irq_funcsfunction enginefunction enginefunction cik_sdma_set_buffer_funcs
Annotated Snippet
if (enable) {
f32_cntl = REG_SET_FIELD(f32_cntl, SDMA0_CNTL,
AUTO_CTXSW_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);
}
WREG32(mmSDMA0_CNTL + sdma_offsets[i], f32_cntl);
}
}
/**
* cik_sdma_enable - stop the async dma engines
*
* @adev: amdgpu_device pointer
* @enable: enable/disable the DMA MEs.
*
* Halt or unhalt the async dma engines (CIK).
*/
static void cik_sdma_enable(struct amdgpu_device *adev, bool enable)
{
u32 me_cntl;
int i;
if (!enable) {
cik_sdma_gfx_stop(adev);
cik_sdma_rlc_stop(adev);
}
for (i = 0; i < adev->sdma.num_instances; i++) {
me_cntl = RREG32(mmSDMA0_F32_CNTL + sdma_offsets[i]);
if (enable)
me_cntl &= ~SDMA0_F32_CNTL__HALT_MASK;
else
me_cntl |= SDMA0_F32_CNTL__HALT_MASK;
WREG32(mmSDMA0_F32_CNTL + sdma_offsets[i], me_cntl);
}
}
/**
* cik_sdma_gfx_resume - setup and start the async dma engines
*
* @adev: amdgpu_device pointer
*
* Set up the gfx DMA ring buffers and enable them (CIK).
* Returns 0 for success, error for failure.
*/
static int cik_sdma_gfx_resume(struct amdgpu_device *adev)
{
struct amdgpu_ring *ring;
u32 rb_cntl, ib_cntl;
u32 rb_bufsz;
int i, j, r;
for (i = 0; i < adev->sdma.num_instances; i++) {
ring = &adev->sdma.instance[i].ring;
mutex_lock(&adev->srbm_mutex);
for (j = 0; j < 16; j++) {
cik_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);
/* XXX SDMA RLC - todo */
}
cik_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_INCOMPLETE_TIMER_CNTL + sdma_offsets[i], 0);
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 = rb_bufsz << 1;
#ifdef __BIG_ENDIAN
rb_cntl |= SDMA0_GFX_RB_CNTL__RB_SWAP_ENABLE_MASK |
SDMA0_GFX_RB_CNTL__RPTR_WRITEBACK_SWAP_ENABLE_MASK;
#endif
WREG32(mmSDMA0_GFX_RB_CNTL + sdma_offsets[i], rb_cntl);
Annotation
- Immediate include surface: `linux/firmware.h`, `linux/module.h`, `amdgpu.h`, `amdgpu_ucode.h`, `amdgpu_trace.h`, `cikd.h`, `cik.h`, `bif/bif_4_1_d.h`.
- Detected declarations: `function cik_sdma_free_microcode`, `function driver`, `function hardware`, `function hardware`, `function hardware`, `function cik_sdma_ring_insert_nop`, `function ring`, `function cik_sdma_ring_emit_hdp_flush`, `function needed`, `function buffers`.
- 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.