drivers/gpu/drm/amd/amdgpu/mes_v12_1.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/mes_v12_1.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/mes_v12_1.c- Extension
.c- Size
- 72945 bytes
- Lines
- 2332
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/firmware.hlinux/module.hamdgpu.hsoc15_common.hsoc_v1_0.hgc/gc_12_1_0_offset.hgc/gc_12_1_0_sh_mask.hgc/gc_11_0_0_default.hv12_structs.hmes_v12_api_def.hgfx_v12_1_pkt.hsdma_v7_1_0_pkt_open.h
Detected Declarations
function mes_v12_1_ring_set_wptrfunction mes_v12_1_ring_get_rptrfunction mes_v12_1_ring_get_wptrfunction mes_v12_1_submit_pkt_and_poll_completionfunction convert_to_mes_queue_typefunction mes_v12_1_add_hw_queuefunction mes_v12_1_remove_hw_queuefunction mes_v12_1_reset_hw_queuefunction mes_v12_1_map_legacy_queuefunction mes_v12_1_unmap_legacy_queuefunction mes_v12_1_suspend_gangfunction mes_v12_1_resume_gangfunction mes_v12_1_query_sched_statusfunction mes_v12_1_get_xcc_from_regfunction mes_v12_1_get_rrmtfunction mes_v12_1_misc_opfunction mes_v12_1_set_hw_resources_1function mes_v12_1_set_hw_resourcesfunction mes_v12_1_init_aggregated_doorbellfunction mes_v12_1_enable_unmapped_doorbell_handlingfunction mes_v12_1_reset_legacy_queuefunction mes_v12_1_detect_and_reset_hung_queuesfunction mes_v12_inv_tlb_convert_hub_idfunction mes_v12_1_inv_tlbs_pasidfunction mes_v12_1_allocate_ucode_bufferfunction mes_v12_1_allocate_ucode_data_bufferfunction mes_v12_1_free_ucode_buffersfunction mes_v12_1_enablefunction mes_v12_1_set_ucode_start_addrfunction mes_v12_1_load_microcodefunction mes_v12_1_allocate_eop_buffunction mes_v12_1_allocate_shared_cmd_buffunction mes_v12_1_mqd_initfunction mes_v12_1_queue_init_registerfunction mes_v12_1_kiq_enable_queuefunction mes_v12_1_queue_initfunction mes_v12_1_ring_initfunction mes_v12_1_kiq_ring_initfunction mes_v12_1_mqd_sw_initfunction mes_v12_1_sw_initfunction mes_v12_1_sw_finifunction mes_v12_1_kiq_dequeue_schedfunction mes_v12_1_kiq_settingfunction mes_v12_1_kiq_hw_initfunction mes_v12_1_kiq_hw_finifunction mes_v12_1_setup_coop_modefunction mes_v12_1_xcc_hw_initfunction mes_v12_1_hw_init
Annotated Snippet
if (adev->enable_uni_mes && num_xcc > 1) {
r = mes_v12_1_allocate_shared_cmd_buf(adev,
pipe, xcc_id);
if (r)
return r;
}
}
}
return 0;
}
static int mes_v12_1_sw_fini(struct amdgpu_ip_block *ip_block)
{
struct amdgpu_device *adev = ip_block->adev;
int pipe, inst, xcc_id, num_xcc = NUM_XCC(adev->gfx.xcc_mask);
for (xcc_id = 0; xcc_id < num_xcc; xcc_id++) {
for (pipe = 0; pipe < AMDGPU_MAX_MES_PIPES; pipe++) {
inst = MES_PIPE_INST(xcc_id, pipe);
amdgpu_bo_free_kernel(&adev->mes.shared_cmd_buf_obj[inst],
&adev->mes.shared_cmd_buf_gpu_addr[inst],
NULL);
kfree(adev->mes.mqd_backup[inst]);
amdgpu_bo_free_kernel(&adev->mes.eop_gpu_obj[inst],
&adev->mes.eop_gpu_addr[inst],
NULL);
if (adev->enable_uni_mes || pipe == AMDGPU_MES_SCHED_PIPE) {
amdgpu_bo_free_kernel(&adev->mes.ring[inst].mqd_obj,
&adev->mes.ring[inst].mqd_gpu_addr,
&adev->mes.ring[inst].mqd_ptr);
amdgpu_ring_fini(&adev->mes.ring[inst]);
}
}
}
for (pipe = 0; pipe < AMDGPU_MAX_MES_PIPES; pipe++)
amdgpu_ucode_release(&adev->mes.fw[pipe]);
for (xcc_id = 0; xcc_id < num_xcc; xcc_id++) {
if (!adev->enable_uni_mes) {
amdgpu_bo_free_kernel(&adev->gfx.kiq[xcc_id].ring.mqd_obj,
&adev->gfx.kiq[xcc_id].ring.mqd_gpu_addr,
&adev->gfx.kiq[xcc_id].ring.mqd_ptr);
amdgpu_ring_fini(&adev->gfx.kiq[xcc_id].ring);
}
if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) {
mes_v12_1_free_ucode_buffers(adev,
AMDGPU_MES_KIQ_PIPE, xcc_id);
mes_v12_1_free_ucode_buffers(adev,
AMDGPU_MES_SCHED_PIPE, xcc_id);
}
}
amdgpu_mes_fini(adev);
return 0;
}
static void mes_v12_1_kiq_dequeue_sched(struct amdgpu_device *adev,
int xcc_id)
{
uint32_t data;
int i;
mutex_lock(&adev->srbm_mutex);
soc_v1_0_grbm_select(adev, 3, AMDGPU_MES_SCHED_PIPE, 0, 0,
GET_INST(GC, xcc_id));
/* disable the queue if it's active */
if (RREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_HQD_ACTIVE) & 1) {
WREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_HQD_DEQUEUE_REQUEST, 1);
for (i = 0; i < adev->usec_timeout; i++) {
if (!(RREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_HQD_ACTIVE) & 1))
break;
udelay(1);
}
}
data = RREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_HQD_PQ_DOORBELL_CONTROL);
data = REG_SET_FIELD(data, CP_HQD_PQ_DOORBELL_CONTROL,
DOORBELL_EN, 0);
data = REG_SET_FIELD(data, CP_HQD_PQ_DOORBELL_CONTROL,
DOORBELL_HIT, 1);
WREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_HQD_PQ_DOORBELL_CONTROL, data);
WREG32_SOC15(GC, GET_INST(GC, xcc_id), regCP_HQD_PQ_DOORBELL_CONTROL, 0);
Annotation
- Immediate include surface: `linux/firmware.h`, `linux/module.h`, `amdgpu.h`, `soc15_common.h`, `soc_v1_0.h`, `gc/gc_12_1_0_offset.h`, `gc/gc_12_1_0_sh_mask.h`, `gc/gc_11_0_0_default.h`.
- Detected declarations: `function mes_v12_1_ring_set_wptr`, `function mes_v12_1_ring_get_rptr`, `function mes_v12_1_ring_get_wptr`, `function mes_v12_1_submit_pkt_and_poll_completion`, `function convert_to_mes_queue_type`, `function mes_v12_1_add_hw_queue`, `function mes_v12_1_remove_hw_queue`, `function mes_v12_1_reset_hw_queue`, `function mes_v12_1_map_legacy_queue`, `function mes_v12_1_unmap_legacy_queue`.
- 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.