drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c- Extension
.c- Size
- 15735 bytes
- Lines
- 585
- 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/slab.hlinux/mutex.hkfd_device_queue_manager.hkfd_kernel_queue.hkfd_priv.h
Detected Declarations
function filesfunction pm_calc_rlib_sizefunction pm_allocate_runlist_ibfunction pm_create_runlist_ibfunction list_for_each_entryfunction list_for_each_entryfunction pm_initfunction pm_uninitfunction pm_send_set_resourcesfunction pm_send_runlistfunction pm_send_query_statusfunction pm_config_dequeue_wait_countsfunction pm_send_unmap_queuefunction pm_release_ibfunction pm_debugfs_runlistfunction pm_debugfs_hang_hws
Annotated Snippet
else if (qpd->pqm->process->xnack_enabled != xnack_enabled) {
/* Found a process with a different xnack mode */
xnack_conflict = 1;
break;
}
}
retval = pm_allocate_runlist_ib(pm, &rl_buffer, rl_gpu_addr,
&alloc_size_bytes, &is_over_subscription,
xnack_conflict);
if (retval)
return retval;
*rl_size_bytes = alloc_size_bytes;
pm->ib_size_bytes = alloc_size_bytes;
dev_dbg(dev, "Building runlist ib process count: %d queues count %d\n",
pm->dqm->processes_count, pm->dqm->active_queue_count);
build_runlist_ib:
/* build the run list ib packet */
list_for_each_entry(cur, queues, list) {
qpd = cur->qpd;
/* group processes with the same xnack mode together */
if (qpd->pqm->process->xnack_enabled != xnack_enabled)
continue;
/* build map process packet */
if (processes_mapped >= pm->dqm->processes_count) {
dev_dbg(dev, "Not enough space left in runlist IB\n");
pm_release_ib(pm);
return -ENOMEM;
}
retval = pm->pmf->map_process(pm, &rl_buffer[rl_wptr], qpd);
if (retval)
return retval;
processes_mapped++;
inc_wptr(&rl_wptr, pm->pmf->map_process_size,
alloc_size_bytes);
list_for_each_entry(kq, &qpd->priv_queue_list, list) {
if (!kq->queue->properties.is_active)
continue;
dev_dbg(dev,
"static_queue, mapping kernel q %d, is debug status %d\n",
kq->queue->queue, qpd->is_debug);
retval = pm->pmf->map_queues(pm,
&rl_buffer[rl_wptr],
kq->queue,
qpd->is_debug);
if (retval)
return retval;
inc_wptr(&rl_wptr,
pm->pmf->map_queues_size,
alloc_size_bytes);
}
list_for_each_entry(q, &qpd->queues_list, list) {
if (!q->properties.is_active)
continue;
dev_dbg(dev,
"static_queue, mapping user queue %d, is debug status %d\n",
q->queue, qpd->is_debug);
retval = pm->pmf->map_queues(pm,
&rl_buffer[rl_wptr],
q,
qpd->is_debug);
if (retval)
return retval;
inc_wptr(&rl_wptr,
pm->pmf->map_queues_size,
alloc_size_bytes);
}
}
if (xnack_conflict) {
/* pick up processes with the other xnack mode */
xnack_enabled = !xnack_enabled;
xnack_conflict = 0;
goto build_runlist_ib;
}
dev_dbg(dev, "Finished map process and queues to runlist\n");
Annotation
- Immediate include surface: `linux/slab.h`, `linux/mutex.h`, `kfd_device_queue_manager.h`, `kfd_kernel_queue.h`, `kfd_priv.h`.
- Detected declarations: `function files`, `function pm_calc_rlib_size`, `function pm_allocate_runlist_ib`, `function pm_create_runlist_ib`, `function list_for_each_entry`, `function list_for_each_entry`, `function pm_init`, `function pm_uninit`, `function pm_send_set_resources`, `function pm_send_runlist`.
- 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.