drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c- Extension
.c- Size
- 35505 bytes
- Lines
- 1249
- 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_2_4_d.hoss/oss_2_4_sh_mask.hgmc/gmc_7_1_d.hgmc/gmc_7_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.hiceland_sdma_pkt_open.hivsrcid/ivsrcid_vislands30.h
Detected Declarations
function sdma_v2_4_init_golden_registersfunction sdma_v2_4_free_microcodefunction driverfunction hardwarefunction hardwarefunction hardwarefunction sdma_v2_4_ring_insert_nopfunction ringfunction sdma_v2_4_ring_emit_hdp_flushfunction neededfunction buffersfunction queuesfunction themfunction themfunction themfunction sdma_v2_4_ring_test_ringfunction ringfunction sDMAfunction sDMAfunction sDMAfunction sdma_v2_4_ring_pad_ibfunction completedfunction sDMAfunction sdma_v2_4_ring_emit_wregfunction sdma_v2_4_early_initfunction sdma_v2_4_sw_initfunction sdma_v2_4_sw_finifunction sdma_v2_4_hw_initfunction sdma_v2_4_hw_finifunction sdma_v2_4_suspendfunction sdma_v2_4_resumefunction sdma_v2_4_is_idlefunction sdma_v2_4_wait_for_idlefunction sdma_v2_4_soft_resetfunction sdma_v2_4_set_trap_irq_statefunction sdma_v2_4_process_trap_irqfunction sdma_v2_4_process_illegal_inst_irqfunction sdma_v2_4_set_clockgating_statefunction sdma_v2_4_set_powergating_statefunction sdma_v2_4_set_ring_funcsfunction sdma_v2_4_set_irq_funcsfunction enginefunction enginefunction sdma_v2_4_set_buffer_funcs
Annotated Snippet
if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU) {
info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SDMA0 + i];
info->ucode_id = AMDGPU_UCODE_ID_SDMA0 + i;
info->fw = adev->sdma.instance[i].fw;
header = (const struct common_firmware_header *)info->fw->data;
adev->firmware.fw_size +=
ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
}
}
out:
if (err) {
pr_err("sdma_v2_4: Failed to load firmware \"%s_sdma%s.bin\"\n",
chip_name, i == 0 ? "" : "1");
for (i = 0; i < adev->sdma.num_instances; i++)
amdgpu_ucode_release(&adev->sdma.instance[i].fw);
}
return err;
}
/**
* sdma_v2_4_ring_get_rptr - get the current read pointer
*
* @ring: amdgpu ring pointer
*
* Get the current rptr from the hardware (VI+).
*/
static uint64_t sdma_v2_4_ring_get_rptr(struct amdgpu_ring *ring)
{
/* XXX check if swapping is necessary on BE */
return *ring->rptr_cpu_addr >> 2;
}
/**
* sdma_v2_4_ring_get_wptr - get the current write pointer
*
* @ring: amdgpu ring pointer
*
* Get the current wptr from the hardware (VI+).
*/
static uint64_t sdma_v2_4_ring_get_wptr(struct amdgpu_ring *ring)
{
struct amdgpu_device *adev = ring->adev;
u32 wptr = RREG32(mmSDMA0_GFX_RB_WPTR + sdma_offsets[ring->me]) >> 2;
return wptr;
}
/**
* sdma_v2_4_ring_set_wptr - commit the write pointer
*
* @ring: amdgpu ring pointer
*
* Write the wptr back to the hardware (VI+).
*/
static void sdma_v2_4_ring_set_wptr(struct amdgpu_ring *ring)
{
struct amdgpu_device *adev = ring->adev;
WREG32(mmSDMA0_GFX_RB_WPTR + sdma_offsets[ring->me], ring->wptr << 2);
}
static void sdma_v2_4_ring_insert_nop(struct amdgpu_ring *ring, uint32_t count)
{
struct amdgpu_sdma_instance *sdma = amdgpu_sdma_get_instance_from_ring(ring);
int i;
for (i = 0; i < count; i++)
if (sdma && sdma->burst_nop && (i == 0))
amdgpu_ring_write(ring, ring->funcs->nop |
SDMA_PKT_NOP_HEADER_COUNT(count - 1));
else
amdgpu_ring_write(ring, ring->funcs->nop);
}
/**
* sdma_v2_4_ring_emit_ib - Schedule an IB on the DMA engine
*
* @ring: amdgpu ring pointer
* @job: job to retrieve vmid from
* @ib: IB object to schedule
* @flags: unused
*
* Schedule an IB in the DMA ring (VI).
*/
static void sdma_v2_4_ring_emit_ib(struct amdgpu_ring *ring,
struct amdgpu_job *job,
struct amdgpu_ib *ib,
uint32_t flags)
{
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_v2_4_init_golden_registers`, `function sdma_v2_4_free_microcode`, `function driver`, `function hardware`, `function hardware`, `function hardware`, `function sdma_v2_4_ring_insert_nop`, `function ring`, `function sdma_v2_4_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.