drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v12_1.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v12_1.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v12_1.c- Extension
.c- Size
- 22664 bytes
- Lines
- 729
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/printk.hlinux/slab.hlinux/uaccess.hkfd_priv.hkfd_mqd_manager.hv12_structs.hgc/gc_12_1_0_sh_mask.hamdgpu_amdkfd.hkfd_device_queue_manager.h
Detected Declarations
function mqd_symmetrically_map_cu_mask_v12_1function update_cu_maskfunction set_priorityfunction init_mqdfunction load_mqdfunction update_mqdfunction check_preemption_failedfunction get_wave_statefunction init_mqd_hiqfunction init_mqd_sdmafunction update_mqd_sdmafunction get_xcc_mqdfunction init_mqd_v12_1function update_mqd_v12_1function destroy_mqd_v12_1function for_each_instfunction load_mqd_v12_1function for_each_instfunction get_wave_state_v12_1function debugfs_show_mqdfunction debugfs_show_mqd_sdma
Annotated Snippet
if (cu_per_sh[se][sh] > cu) {
if (cu_mask[i / 32] & (1U << (i % 32))) {
if (cu == 8 && sh == 0)
se_mask[se] |= en_mask << 30;
else
se_mask[se] |= en_mask << (cu_inc + sh * 16);
}
i += inc;
if (i >= cu_mask_count)
return;
}
}
}
cu_inc += 2;
}
}
static void update_cu_mask(struct mqd_manager *mm, void *mqd,
struct mqd_update_info *minfo, uint32_t inst)
{
struct v12_1_compute_mqd *m;
uint32_t se_mask[2] = {0};
if (!minfo || !minfo->cu_mask.ptr)
return;
mqd_symmetrically_map_cu_mask_v12_1(mm,
minfo->cu_mask.ptr, minfo->cu_mask.count, se_mask, inst);
m = get_mqd(mqd);
m->compute_static_thread_mgmt_se0 = se_mask[0];
m->compute_static_thread_mgmt_se1 = se_mask[1];
pr_debug("update cu mask to %#x %#x\n",
m->compute_static_thread_mgmt_se0,
m->compute_static_thread_mgmt_se1);
}
static void set_priority(struct v12_1_compute_mqd *m, struct queue_properties *q)
{
m->cp_hqd_pipe_priority = pipe_priority_map[q->priority];
}
static struct kfd_mem_obj *allocate_mqd(struct mqd_manager *mm,
struct queue_properties *q)
{
u32 mqd_size = AMDGPU_MQD_SIZE_ALIGN(mm->mqd_size);
struct kfd_node *node = mm->dev;
struct kfd_mem_obj *mqd_mem_obj;
if (q->type == KFD_QUEUE_TYPE_COMPUTE)
mqd_size *= NUM_XCC(node->xcc_mask);
if (kfd_gtt_sa_allocate(node, mqd_size, &mqd_mem_obj))
return NULL;
return mqd_mem_obj;
}
static void init_mqd(struct mqd_manager *mm, void **mqd,
struct kfd_mem_obj *mqd_mem_obj, uint64_t *gart_addr,
struct queue_properties *q)
{
uint64_t addr;
struct v12_1_compute_mqd *m;
u32 mqd_size = AMDGPU_MQD_SIZE_ALIGN(mm->mqd_size);
m = (struct v12_1_compute_mqd *) mqd_mem_obj->cpu_ptr;
addr = mqd_mem_obj->gpu_addr;
memset(m, 0, mqd_size);
m->header = 0xC0310800;
m->compute_pipelinestat_enable = 1;
m->compute_static_thread_mgmt_se0 = 0xFFFFFFFF;
m->compute_static_thread_mgmt_se1 = 0xFFFFFFFF;
m->compute_static_thread_mgmt_se2 = 0xFFFFFFFF;
m->compute_static_thread_mgmt_se3 = 0xFFFFFFFF;
m->compute_static_thread_mgmt_se4 = 0xFFFFFFFF;
m->compute_static_thread_mgmt_se5 = 0xFFFFFFFF;
m->compute_static_thread_mgmt_se6 = 0xFFFFFFFF;
m->compute_static_thread_mgmt_se7 = 0xFFFFFFFF;
m->compute_static_thread_mgmt_se8 = 0xFFFFFFFF;
m->cp_hqd_persistent_state = CP_HQD_PERSISTENT_STATE__PRELOAD_REQ_MASK |
0x63 << CP_HQD_PERSISTENT_STATE__PRELOAD_SIZE__SHIFT;
m->cp_mqd_control = 1 << CP_MQD_CONTROL__PRIV_STATE__SHIFT;
m->cp_mqd_base_addr_lo = lower_32_bits(addr);
Annotation
- Immediate include surface: `linux/printk.h`, `linux/slab.h`, `linux/uaccess.h`, `kfd_priv.h`, `kfd_mqd_manager.h`, `v12_structs.h`, `gc/gc_12_1_0_sh_mask.h`, `amdgpu_amdkfd.h`.
- Detected declarations: `function mqd_symmetrically_map_cu_mask_v12_1`, `function update_cu_mask`, `function set_priority`, `function init_mqd`, `function load_mqd`, `function update_mqd`, `function check_preemption_failed`, `function get_wave_state`, `function init_mqd_hiq`, `function init_mqd_sdma`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.