drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c- Extension
.c- Size
- 63462 bytes
- Lines
- 2074
- 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_3_0_offset.hgc/gc_10_3_0_sh_mask.hivsrcid/sdma0/irqsrcs_sdma0_5_0.hivsrcid/sdma1/irqsrcs_sdma1_5_0.hivsrcid/sdma2/irqsrcs_sdma2_5_0.hivsrcid/sdma3/irqsrcs_sdma3_5_0.hsoc15_common.hsoc15.hnavi10_sdma_pkt_open.hnbio_v2_3.hsdma_common.hsdma_v5_2.h
Detected Declarations
function sdma_v5_2_get_reg_offsetfunction sdma_v5_2_ring_init_cond_execfunction hardwarefunction hardwarefunction hardwarefunction sdma_v5_2_ring_insert_nopfunction sdma_v5_2_ring_emit_ibfunction sdma_v5_2_ring_emit_mem_syncfunction sdma_v5_2_ring_emit_hdp_flushfunction sdma_v5_2_ring_emit_fencefunction sdma_v5_2_gfx_stopfunction for_each_instfunction sdma_v5_2_rlc_stopfunction sdma_v5_2_enablefunction sdma_v5_2_gfx_resume_instancefunction sdma_v5_2_gfx_resumefunction sdma_v5_2_rlc_resumefunction sdma_v5_2_load_microcodefunction sdma_v5_2_soft_reset_enginefunction sdma_v5_2_soft_resetfunction sdma_v5_2_startfunction sdma_v5_2_mqd_initfunction sdma_v5_2_set_mqd_funcsfunction sdma_v5_2_ring_test_ringfunction sdma_v5_2_ring_test_ibfunction sdma_v5_2_vm_copy_ptefunction sdma_v5_2_vm_write_ptefunction sdma_v5_2_vm_set_pte_pdefunction sdma_v5_2_ring_pad_ibfunction completedfunction sdma_v5_2_ring_emit_vm_flushfunction sdma_v5_2_ring_emit_wregfunction sdma_v5_2_ring_emit_reg_waitfunction sdma_v5_2_ring_emit_reg_write_reg_waitfunction sdma_v5_2_early_initfunction sdma_v5_2_seq_to_irq_idfunction sdma_v5_2_seq_to_trap_idfunction sdma_v5_2_sw_initfunction sdma_v5_2_sw_finifunction sdma_v5_2_hw_initfunction sdma_v5_2_hw_finifunction sdma_v5_2_suspendfunction sdma_v5_2_resumefunction sdma_v5_2_is_idlefunction sdma_v5_2_wait_for_idlefunction sdma_v5_2_reset_queuefunction sdma_v5_2_stop_queuefunction sdma_v5_2_restore_queue
Annotated Snippet
if (instance < 2) {
base = adev->reg_offset[GC_HWIP][0][0];
if (instance == 1)
internal_offset += SDMA1_REG_OFFSET;
} else {
base = adev->reg_offset[GC_HWIP][0][2];
if (instance == 3)
internal_offset += SDMA3_REG_OFFSET;
}
}
return base + internal_offset;
}
static unsigned sdma_v5_2_ring_init_cond_exec(struct amdgpu_ring *ring,
uint64_t addr)
{
unsigned ret;
amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_COND_EXE));
amdgpu_ring_write(ring, lower_32_bits(addr));
amdgpu_ring_write(ring, upper_32_bits(addr));
amdgpu_ring_write(ring, 1);
/* this is the offset we need patch later */
ret = ring->wptr & ring->buf_mask;
/* insert dummy here and patch it later */
amdgpu_ring_write(ring, 0);
return ret;
}
/**
* sdma_v5_2_ring_get_rptr - get the current read pointer
*
* @ring: amdgpu ring pointer
*
* Get the current rptr from the hardware (NAVI10+).
*/
static uint64_t sdma_v5_2_ring_get_rptr(struct amdgpu_ring *ring)
{
u64 *rptr;
/* XXX check if swapping is necessary on BE */
rptr = (u64 *)ring->rptr_cpu_addr;
DRM_DEBUG("rptr before shift == 0x%016llx\n", *rptr);
return ((*rptr) >> 2);
}
/**
* sdma_v5_2_ring_get_wptr - get the current write pointer
*
* @ring: amdgpu ring pointer
*
* Get the current wptr from the hardware (NAVI10+).
*/
static uint64_t sdma_v5_2_ring_get_wptr(struct amdgpu_ring *ring)
{
struct amdgpu_device *adev = ring->adev;
u64 wptr;
if (ring->use_doorbell) {
/* XXX check if swapping is necessary on BE */
wptr = READ_ONCE(*((u64 *)ring->wptr_cpu_addr));
DRM_DEBUG("wptr/doorbell before shift == 0x%016llx\n", wptr);
} else {
wptr = RREG32(sdma_v5_2_get_reg_offset(adev, ring->me, mmSDMA0_GFX_RB_WPTR_HI));
wptr = wptr << 32;
wptr |= RREG32(sdma_v5_2_get_reg_offset(adev, ring->me, mmSDMA0_GFX_RB_WPTR));
DRM_DEBUG("wptr before shift [%i] wptr == 0x%016llx\n", ring->me, wptr);
}
return wptr >> 2;
}
/**
* sdma_v5_2_ring_set_wptr - commit the write pointer
*
* @ring: amdgpu ring pointer
*
* Write the wptr back to the hardware (NAVI10+).
*/
static void sdma_v5_2_ring_set_wptr(struct amdgpu_ring *ring)
{
struct amdgpu_device *adev = ring->adev;
DRM_DEBUG("Setting write pointer\n");
if (ring->use_doorbell) {
DRM_DEBUG("Using doorbell -- "
"wptr_offs == 0x%08x "
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_3_0_offset.h`.
- Detected declarations: `function sdma_v5_2_get_reg_offset`, `function sdma_v5_2_ring_init_cond_exec`, `function hardware`, `function hardware`, `function hardware`, `function sdma_v5_2_ring_insert_nop`, `function sdma_v5_2_ring_emit_ib`, `function sdma_v5_2_ring_emit_mem_sync`, `function sdma_v5_2_ring_emit_hdp_flush`, `function sdma_v5_2_ring_emit_fence`.
- 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.