drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v12_1.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v12_1.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v12_1.c- Extension
.c- Size
- 11821 bytes
- Lines
- 388
- 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
amdgpu.hamdgpu_amdkfd.hgc/gc_12_1_0_offset.hgc/gc_12_1_0_sh_mask.hsoc_v1_0.huapi/linux/kfd_ioctl.h
Detected Declarations
function filesfunction unlock_srbmfunction acquire_queuefunction release_queuefunction init_interrupts_v12_1function get_sdma_rlc_reg_offsetfunction hqd_dump_v12_1function hqd_sdma_dump_v12_1function wave_control_execute_v12_1function kgd_gfx_v12_1_enable_debug_trapfunction kgd_gfx_v12_1_disable_debug_trapfunction kgd_gfx_v12_1_validate_trap_override_requestfunction trap_mask_map_sw_to_hwfunction trap_mask_map_hw_to_swfunction kgd_gfx_v12_1_set_wave_launch_trap_overridefunction kgd_gfx_v12_1_set_wave_launch_modefunction kgd_gfx_v12_1_set_address_watchfunction kgd_gfx_v12_1_clear_address_watchfunction kgd_gfx_v12_1_hqd_sdma_get_doorbell
Annotated Snippet
#include "amdgpu.h"
#include "amdgpu_amdkfd.h"
#include "gc/gc_12_1_0_offset.h"
#include "gc/gc_12_1_0_sh_mask.h"
#include "soc_v1_0.h"
#include <uapi/linux/kfd_ioctl.h>
static void lock_srbm(struct amdgpu_device *adev, uint32_t mec, uint32_t pipe,
uint32_t queue, uint32_t vmid, uint32_t inst)
{
mutex_lock(&adev->srbm_mutex);
amdgpu_gfx_select_me_pipe_q(adev, mec, pipe, queue, vmid, inst);
}
static void unlock_srbm(struct amdgpu_device *adev, uint32_t inst)
{
amdgpu_gfx_select_me_pipe_q(adev, 0, 0, 0, 0, inst);
mutex_unlock(&adev->srbm_mutex);
}
static void acquire_queue(struct amdgpu_device *adev, uint32_t pipe_id,
uint32_t queue_id, uint32_t inst)
{
uint32_t mec = (pipe_id / adev->gfx.mec.num_pipe_per_mec) + 1;
uint32_t pipe = (pipe_id % adev->gfx.mec.num_pipe_per_mec);
lock_srbm(adev, mec, pipe, queue_id, 0, inst);
}
static void release_queue(struct amdgpu_device *adev, uint32_t inst)
{
unlock_srbm(adev, inst);
}
static int init_interrupts_v12_1(struct amdgpu_device *adev, uint32_t pipe_id, uint32_t inst)
{
uint32_t mec;
uint32_t pipe;
mec = (pipe_id / adev->gfx.mec.num_pipe_per_mec) + 1;
pipe = (pipe_id % adev->gfx.mec.num_pipe_per_mec);
lock_srbm(adev, mec, pipe, 0, 0, inst);
WREG32_SOC15(GC, GET_INST(GC, inst), regCPC_INT_CNTL,
CP_INT_CNTL_RING0__TIME_STAMP_INT_ENABLE_MASK |
CP_INT_CNTL_RING0__OPCODE_ERROR_INT_ENABLE_MASK);
unlock_srbm(adev, inst);
return 0;
}
static uint32_t get_sdma_rlc_reg_offset(struct amdgpu_device *adev,
unsigned int engine_id,
unsigned int queue_id)
{
uint32_t sdma_engine_reg_base = 0;
uint32_t sdma_rlc_reg_offset;
uint32_t dev_inst = GET_INST(SDMA0, engine_id);
switch (dev_inst % adev->sdma.num_inst_per_xcc) {
case 0:
sdma_engine_reg_base = SOC15_REG_OFFSET(SDMA0,
dev_inst / adev->sdma.num_inst_per_xcc,
regSDMA0_SDMA_QUEUE0_RB_CNTL) - regSDMA0_SDMA_QUEUE0_RB_CNTL;
break;
case 1:
sdma_engine_reg_base = SOC15_REG_OFFSET(SDMA1,
dev_inst / adev->sdma.num_inst_per_xcc,
regSDMA1_SDMA_QUEUE0_RB_CNTL) - regSDMA0_SDMA_QUEUE0_RB_CNTL;
break;
default:
BUG();
}
sdma_rlc_reg_offset = sdma_engine_reg_base
+ queue_id * (regSDMA0_SDMA_QUEUE1_RB_CNTL - regSDMA0_SDMA_QUEUE0_RB_CNTL);
pr_debug("RLC register offset for SDMA%d RLC%d: 0x%x\n", engine_id,
queue_id, sdma_rlc_reg_offset);
return sdma_rlc_reg_offset;
}
static int hqd_dump_v12_1(struct amdgpu_device *adev,
uint32_t pipe_id, uint32_t queue_id,
uint32_t (**dump)[2], uint32_t *n_regs, uint32_t inst)
{
uint32_t i = 0, reg;
Annotation
- Immediate include surface: `amdgpu.h`, `amdgpu_amdkfd.h`, `gc/gc_12_1_0_offset.h`, `gc/gc_12_1_0_sh_mask.h`, `soc_v1_0.h`, `uapi/linux/kfd_ioctl.h`.
- Detected declarations: `function files`, `function unlock_srbm`, `function acquire_queue`, `function release_queue`, `function init_interrupts_v12_1`, `function get_sdma_rlc_reg_offset`, `function hqd_dump_v12_1`, `function hqd_sdma_dump_v12_1`, `function wave_control_execute_v12_1`, `function kgd_gfx_v12_1_enable_debug_trap`.
- 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.