drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c- Extension
.c- Size
- 17250 bytes
- Lines
- 615
- 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.hamdgpu.hamdgpu_sdma.hamdgpu_ras.hamdgpu_reset.hgc/gc_10_1_0_offset.hgc/gc_10_3_0_sh_mask.h
Detected Declarations
function filesfunction amdgpu_sdma_get_index_from_ringfunction amdgpu_sdma_get_csa_mc_addrfunction amdgpu_sdma_ras_late_initfunction amdgpu_sdma_process_ras_data_cbfunction amdgpu_sdma_process_ecc_irqfunction amdgpu_sdma_init_inst_ctxfunction amdgpu_sdma_destroy_inst_ctxfunction amdgpu_sdma_init_microcodefunction amdgpu_sdma_ras_sw_initfunction amdgpu_debugfs_sdma_sched_mask_setfunction amdgpu_debugfs_sdma_sched_mask_getfunction amdgpu_debugfs_sdma_sched_mask_initfunction amdgpu_get_sdma_reset_maskfunction amdgpu_sdma_sysfs_reset_mask_initfunction amdgpu_sdma_sysfs_reset_mask_finifunction amdgpu_sdma_is_shared_inv_engfunction amdgpu_sdma_soft_resetfunction amdgpu_sdma_reset_engine
Annotated Snippet
switch (version_major) {
case 1:
for (i = 0; i < adev->sdma.num_instances; i++) {
if (!duplicate && (instance != i))
continue;
else {
/* Use a single copy per SDMA firmware type. PSP uses the same instance for all
* groups of SDMAs */
if ((amdgpu_ip_version(adev, SDMA0_HWIP, 0) ==
IP_VERSION(4, 4, 2) ||
amdgpu_ip_version(adev, SDMA0_HWIP, 0) ==
IP_VERSION(4, 4, 4) ||
amdgpu_ip_version(adev, SDMA0_HWIP, 0) ==
IP_VERSION(4, 4, 5)) &&
adev->firmware.load_type ==
AMDGPU_FW_LOAD_PSP &&
adev->sdma.num_inst_per_aid == i) {
break;
}
info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SDMA0 + i];
info->ucode_id = AMDGPU_UCODE_ID_SDMA0 + i;
info->fw = adev->sdma.instance[i].fw;
adev->firmware.fw_size +=
ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
}
}
break;
case 2:
sdma_hdr = (const struct sdma_firmware_header_v2_0 *)
adev->sdma.instance[0].fw->data;
info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SDMA_UCODE_TH0];
info->ucode_id = AMDGPU_UCODE_ID_SDMA_UCODE_TH0;
info->fw = adev->sdma.instance[0].fw;
adev->firmware.fw_size +=
ALIGN(le32_to_cpu(sdma_hdr->ctx_ucode_size_bytes), PAGE_SIZE);
info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SDMA_UCODE_TH1];
info->ucode_id = AMDGPU_UCODE_ID_SDMA_UCODE_TH1;
info->fw = adev->sdma.instance[0].fw;
adev->firmware.fw_size +=
ALIGN(le32_to_cpu(sdma_hdr->ctl_ucode_size_bytes), PAGE_SIZE);
break;
case 3:
sdma_hv3 = (const struct sdma_firmware_header_v3_0 *)
adev->sdma.instance[0].fw->data;
info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SDMA_RS64];
info->ucode_id = AMDGPU_UCODE_ID_SDMA_RS64;
info->fw = adev->sdma.instance[0].fw;
adev->firmware.fw_size +=
ALIGN(le32_to_cpu(sdma_hv3->ucode_size_bytes), PAGE_SIZE);
break;
default:
err = -EINVAL;
}
}
out:
if (err)
amdgpu_sdma_destroy_inst_ctx(adev, duplicate);
return err;
}
int amdgpu_sdma_ras_sw_init(struct amdgpu_device *adev)
{
int err = 0;
struct amdgpu_sdma_ras *ras = NULL;
/* adev->sdma.ras is NULL, which means sdma does not
* support ras function, then do nothing here.
*/
if (!adev->sdma.ras)
return 0;
ras = adev->sdma.ras;
err = amdgpu_ras_register_ras_block(adev, &ras->ras_block);
if (err) {
dev_err(adev->dev, "Failed to register sdma ras block!\n");
return err;
}
strcpy(ras->ras_block.ras_comm.name, "sdma");
ras->ras_block.ras_comm.block = AMDGPU_RAS_BLOCK__SDMA;
ras->ras_block.ras_comm.type = AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE;
adev->sdma.ras_if = &ras->ras_block.ras_comm;
/* If not define special ras_late_init function, use default ras_late_init */
if (!ras->ras_block.ras_late_init)
ras->ras_block.ras_late_init = amdgpu_sdma_ras_late_init;
/* If not defined special ras_cb function, use default ras_cb */
Annotation
- Immediate include surface: `linux/firmware.h`, `amdgpu.h`, `amdgpu_sdma.h`, `amdgpu_ras.h`, `amdgpu_reset.h`, `gc/gc_10_1_0_offset.h`, `gc/gc_10_3_0_sh_mask.h`.
- Detected declarations: `function files`, `function amdgpu_sdma_get_index_from_ring`, `function amdgpu_sdma_get_csa_mc_addr`, `function amdgpu_sdma_ras_late_init`, `function amdgpu_sdma_process_ras_data_cb`, `function amdgpu_sdma_process_ecc_irq`, `function amdgpu_sdma_init_inst_ctx`, `function amdgpu_sdma_destroy_inst_ctx`, `function amdgpu_sdma_init_microcode`, `function amdgpu_sdma_ras_sw_init`.
- 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.