drivers/gpu/drm/amd/amdgpu/sdma_v7_1.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/sdma_v7_1.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/sdma_v7_1.c- Extension
.c- Size
- 58057 bytes
- Lines
- 1820
- 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_12_1_0_offset.hgc/gc_12_1_0_sh_mask.hivsrcid/gfx/irqsrcs_gfx_12_1_0.hsoc15_common.hsoc15.hsdma_v7_1_0_pkt_open.hnbio_v4_3.hsdma_common.hsdma_v7_1.hv12_structs.hmes_userqueue.hsoc_v1_0.h
Detected Declarations
function sdma_v7_1_get_reg_offsetfunction sdma_v7_1_ring_init_cond_execfunction sdma_v7_1_ring_get_rptrfunction sdma_v7_1_ring_get_wptrfunction sdma_v7_1_ring_set_wptrfunction sdma_v7_1_ring_insert_nopfunction sdma_v7_1_ring_emit_ibfunction sdma_v7_1_ring_emit_mem_syncfunction sdma_v7_1_ring_emit_fencefunction sdma_v7_1_inst_gfx_stopfunction for_each_instfunction sdma_v7_1_inst_rlc_stopfunction for_each_instfunction sdma_v7_1_inst_enablefunction for_each_instfunction sdma_v7_1_gfx_resume_instancefunction sdma_v7_1_inst_gfx_resumefunction for_each_instfunction sdma_v7_1_inst_rlc_resumefunction sdma_v7_1_inst_free_ucode_bufferfunction for_each_instfunction sdma_v7_1_inst_load_microcodefunction for_each_instfunction sdma_v7_1_soft_resetfunction for_each_instfunction sdma_v7_1_check_soft_resetfunction sdma_v7_1_reset_queuefunction sdma_v7_1_inst_startfunction sdma_v7_1_mqd_initfunction sdma_v7_1_set_mqd_funcsfunction sdma_v7_1_ring_test_ringfunction sdma_v7_1_ring_test_ibfunction sdma_v7_1_vm_copy_ptefunction sdma_v7_1_vm_write_ptefunction sdma_v7_1_vm_set_pte_pdefunction sdma_v7_1_ring_pad_ibfunction completedfunction sdma_v7_1_ring_emit_vm_flushfunction sdma_v7_1_ring_emit_wregfunction sdma_v7_1_ring_emit_reg_waitfunction sdma_v7_1_ring_emit_reg_write_reg_waitfunction sdma_v7_1_early_initfunction sdma_v7_1_sw_initfunction sdma_v7_1_sw_finifunction sdma_v7_1_hw_initfunction sdma_v7_1_hw_finifunction sdma_v7_1_suspendfunction sdma_v7_1_resume
Annotated Snippet
if (r) {
dev_err(adev->dev, "(%d) failed to create sdma ucode bo\n", r);
return r;
}
memcpy(adev->sdma.instance[i].sdma_fw_ptr, fw_data, fw_size);
amdgpu_bo_kunmap(adev->sdma.instance[i].sdma_fw_obj);
amdgpu_bo_unreserve(adev->sdma.instance[i].sdma_fw_obj);
tmp = RREG32_SOC15_IP(GC, sdma_v7_1_get_reg_offset(adev, i, regSDMA0_SDMA_IC_CNTL));
tmp = REG_SET_FIELD(tmp, SDMA0_SDMA_IC_CNTL, GPA, 0);
WREG32_SOC15_IP(GC, sdma_v7_1_get_reg_offset(adev, i, regSDMA0_SDMA_IC_CNTL), tmp);
WREG32_SOC15_IP(GC, sdma_v7_1_get_reg_offset(adev, i, regSDMA0_SDMA_IC_BASE_LO),
lower_32_bits(adev->sdma.instance[i].sdma_fw_gpu_addr));
WREG32_SOC15_IP(GC, sdma_v7_1_get_reg_offset(adev, i, regSDMA0_SDMA_IC_BASE_HI),
upper_32_bits(adev->sdma.instance[i].sdma_fw_gpu_addr));
tmp = RREG32_SOC15_IP(GC, sdma_v7_1_get_reg_offset(adev, i, regSDMA0_SDMA_IC_OP_CNTL));
tmp = REG_SET_FIELD(tmp, SDMA0_SDMA_IC_OP_CNTL, PRIME_ICACHE, 1);
WREG32_SOC15_IP(GC, sdma_v7_1_get_reg_offset(adev, i, regSDMA0_SDMA_IC_OP_CNTL), tmp);
/* Wait for sdma ucode init complete */
for (j = 0; j < adev->usec_timeout; j++) {
ic_op_cntl = RREG32_SOC15_IP(GC,
sdma_v7_1_get_reg_offset(adev, i, regSDMA0_SDMA_IC_OP_CNTL));
sdma_status = RREG32_SOC15_IP(GC,
sdma_v7_1_get_reg_offset(adev, i, regSDMA0_SDMA_STATUS_REG));
if ((REG_GET_FIELD(ic_op_cntl, SDMA0_SDMA_IC_OP_CNTL, ICACHE_PRIMED) == 1) &&
(REG_GET_FIELD(sdma_status, SDMA0_SDMA_STATUS_REG, UCODE_INIT_DONE) == 1))
break;
udelay(1);
}
if (j >= adev->usec_timeout) {
dev_err(adev->dev, "failed to init sdma ucode\n");
return -EINVAL;
}
}
return 0;
}
static int sdma_v7_1_soft_reset(struct amdgpu_ip_block *ip_block)
{
struct amdgpu_device *adev = ip_block->adev;
uint32_t inst_mask;
u32 tmp;
int i;
inst_mask = GENMASK(NUM_XCC(adev->sdma.sdma_mask) - 1, 0);
sdma_v7_1_inst_gfx_stop(adev, inst_mask);
for_each_inst(i, inst_mask) {
//tmp = RREG32_SOC15_IP(GC, sdma_v7_1_get_reg_offset(adev, i, regSDMA0_SDMA_FREEZE));
//tmp |= SDMA0_SDMA_FREEZE__FREEZE_MASK;
//WREG32_SOC15_IP(GC, sdma_v7_1_get_reg_offset(adev, i, regSDMA0_SDMA_FREEZE), tmp);
tmp = RREG32_SOC15_IP(GC, sdma_v7_1_get_reg_offset(adev, i, regSDMA0_SDMA_MCU_CNTL));
tmp |= SDMA0_SDMA_MCU_CNTL__HALT_MASK;
tmp |= SDMA0_SDMA_MCU_CNTL__RESET_MASK;
WREG32_SOC15_IP(GC, sdma_v7_1_get_reg_offset(adev, i, regSDMA0_SDMA_MCU_CNTL), tmp);
WREG32_SOC15_IP(GC, sdma_v7_1_get_reg_offset(adev, i, regSDMA0_SDMA_QUEUE0_PREEMPT), 0);
udelay(100);
tmp = GRBM_SOFT_RESET__SOFT_RESET_SDMA0_MASK << i;
WREG32_SOC15(GC, 0, regGRBM_SOFT_RESET, tmp);
tmp = RREG32_SOC15(GC, 0, regGRBM_SOFT_RESET);
udelay(100);
WREG32_SOC15(GC, 0, regGRBM_SOFT_RESET, 0);
tmp = RREG32_SOC15(GC, 0, regGRBM_SOFT_RESET);
udelay(100);
}
return sdma_v7_1_inst_start(adev, inst_mask);
}
static bool sdma_v7_1_check_soft_reset(struct amdgpu_ip_block *ip_block)
{
struct amdgpu_device *adev = ip_block->adev;
struct amdgpu_ring *ring;
int i, r;
long tmo = msecs_to_jiffies(1000);
for (i = 0; i < adev->sdma.num_instances; i++) {
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_12_1_0_offset.h`.
- Detected declarations: `function sdma_v7_1_get_reg_offset`, `function sdma_v7_1_ring_init_cond_exec`, `function sdma_v7_1_ring_get_rptr`, `function sdma_v7_1_ring_get_wptr`, `function sdma_v7_1_ring_set_wptr`, `function sdma_v7_1_ring_insert_nop`, `function sdma_v7_1_ring_emit_ib`, `function sdma_v7_1_ring_emit_mem_sync`, `function sdma_v7_1_ring_emit_fence`, `function sdma_v7_1_inst_gfx_stop`.
- 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.