drivers/gpu/drm/amd/amdkfd/kfd_debug.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdkfd/kfd_debug.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdkfd/kfd_debug.c- Extension
.c- Size
- 30862 bytes
- Lines
- 1184
- 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.
- 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
kfd_debug.hkfd_device_queue_manager.hkfd_topology.hlinux/file.huapi/linux/kfd_ioctl.huapi/linux/kfd_sysfs.h
Detected Declarations
function filesfunction debug_event_write_work_handlerfunction kfd_dbg_ev_raisefunction list_for_each_entryfunction kfd_set_dbg_ev_from_interruptfunction list_for_each_entryfunction kfd_dbg_send_exception_to_runtimefunction kfd_dbg_set_queue_workaroundfunction kfd_dbg_set_workaroundfunction list_for_each_entryfunction kfd_dbg_set_mes_debug_modefunction kfd_dbg_get_dev_watch_idfunction kfd_dbg_clear_dev_watch_idfunction kfd_dbg_owns_dev_watch_idfunction kfd_dbg_trap_clear_dev_address_watchfunction kfd_dbg_trap_set_dev_address_watchfunction kfd_dbg_clear_process_address_watchfunction kfd_dbg_trap_set_flagsfunction kfd_dbg_trap_deactivatefunction kfd_dbg_clean_exception_statusfunction kfd_dbg_trap_disablefunction kfd_dbg_trap_activatefunction kfd_dbg_trap_enablefunction kfd_dbg_validate_trap_override_requestfunction kfd_dbg_trap_set_wave_launch_overridefunction kfd_dbg_trap_set_wave_launch_modefunction kfd_dbg_trap_query_exception_infofunction list_for_each_entryfunction kfd_dbg_trap_device_snapshotfunction kfd_dbg_set_enabled_debug_exception_mask
Annotated Snippet
if (event_mask & KFD_EC_MASK(EC_DEVICE_MEMORY_VIOLATION)) {
if (!pdd->vm_fault_exc_data) {
pdd->vm_fault_exc_data = kmemdup(
exception_data,
exception_data_size,
GFP_KERNEL);
if (!pdd->vm_fault_exc_data)
pr_debug("Failed to allocate exception data memory");
} else {
pr_debug("Debugger exception data not saved\n");
print_hex_dump_bytes("exception data: ",
DUMP_PREFIX_OFFSET,
exception_data,
exception_data_size);
}
}
break;
}
} else if (event_mask & KFD_EC_MASK_PROCESS) {
process->exception_status |= event_mask & KFD_EC_MASK_PROCESS;
} else {
pqm = &process->pqm;
list_for_each_entry(pqn, &pqm->queues,
process_queue_list) {
int target_id;
if (!pqn->q)
continue;
target_id = event_mask & KFD_EC_MASK(EC_QUEUE_NEW) ?
pqn->q->properties.queue_id :
pqn->q->doorbell_id;
if (pqn->q->device != dev || target_id != source_id)
continue;
pqn->q->properties.exception_status |= event_mask;
break;
}
}
if (process->exception_enable_mask & event_mask) {
if (use_worker)
schedule_work(&process->debug_event_workarea);
else
kernel_write(process->dbg_ev_file,
&write_data,
1,
&pos);
} else {
is_subscribed = false;
}
mutex_unlock(&process->event_mutex);
return is_subscribed;
}
/* set pending event queue entry from ring entry */
bool kfd_set_dbg_ev_from_interrupt(struct kfd_node *dev,
unsigned int pasid,
uint32_t doorbell_id,
uint64_t trap_mask,
void *exception_data,
size_t exception_data_size)
{
struct kfd_process *p;
struct kfd_process_device *pdd = NULL;
bool signaled_to_debugger_or_runtime = false;
p = kfd_lookup_process_by_pasid(pasid, &pdd);
if (!pdd)
return false;
if (!kfd_dbg_ev_raise(trap_mask, p, dev, doorbell_id, true,
exception_data, exception_data_size)) {
struct process_queue_manager *pqm;
struct process_queue_node *pqn;
if (!!(trap_mask & KFD_EC_MASK_QUEUE) &&
p->runtime_info.runtime_state == DEBUG_RUNTIME_STATE_ENABLED) {
mutex_lock(&p->mutex);
pqm = &p->pqm;
list_for_each_entry(pqn, &pqm->queues,
process_queue_list) {
if (!(pqn->q && pqn->q->device == dev &&
pqn->q->doorbell_id == doorbell_id))
Annotation
- Immediate include surface: `kfd_debug.h`, `kfd_device_queue_manager.h`, `kfd_topology.h`, `linux/file.h`, `uapi/linux/kfd_ioctl.h`, `uapi/linux/kfd_sysfs.h`.
- Detected declarations: `function files`, `function debug_event_write_work_handler`, `function kfd_dbg_ev_raise`, `function list_for_each_entry`, `function kfd_set_dbg_ev_from_interrupt`, `function list_for_each_entry`, `function kfd_dbg_send_exception_to_runtime`, `function kfd_dbg_set_queue_workaround`, `function kfd_dbg_set_workaround`, `function list_for_each_entry`.
- 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.
- 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.