drivers/gpu/drm/amd/amdkfd/kfd_topology.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdkfd/kfd_topology.c- Extension
.c- Size
- 72175 bytes
- Lines
- 2470
- 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/types.hlinux/kernel.hlinux/pci.hlinux/errno.hlinux/acpi.hlinux/hash.hlinux/cpufreq.hlinux/log2.hlinux/dmi.hlinux/atomic.hlinux/crc16.hkfd_priv.hkfd_crat.hkfd_topology.hkfd_device_queue_manager.hkfd_svm.hkfd_debug.hamdgpu_amdkfd.hamdgpu_ras.hamdgpu.h
Detected Declarations
struct kfd_perf_attrfunction list_for_each_entryfunction list_for_each_entryfunction kfd_release_topology_devicefunction kfd_release_topology_device_listfunction kfd_release_live_viewfunction sysfs_show_gen_propfunction kfd_topology_kobj_releasefunction iolink_showfunction mem_showfunction kfd_cache_showfunction perf_showfunction node_showfunction kfd_remove_sysfs_filefunction kfd_remove_sysfs_node_entryfunction kfd_build_sysfs_node_entryfunction kfd_build_sysfs_node_treefunction list_for_each_entryfunction kfd_remove_sysfs_node_treefunction kfd_topology_update_sysfsfunction kfd_topology_release_sysfsfunction kfd_topology_update_device_listfunction kfd_debug_print_topologyfunction kfd_update_system_propertiesfunction find_system_memoryfunction list_for_each_entryfunction kfd_add_non_crat_informationfunction kfd_topology_initfunction detectedfunction kfd_topology_shutdownfunction kfd_generate_gpu_idfunction list_for_each_entryfunction list_for_each_entryfunction kfd_notify_gpu_changefunction kfd_set_iolink_no_atomicsfunction kfd_set_iolink_non_coherentfunction kfd_set_recommended_sdma_enginesfunction kfd_fill_iolink_non_crat_infofunction list_for_each_entryfunction list_for_each_entryfunction kfd_build_p2p_node_entryfunction kfd_create_indirect_link_propfunction kfd_add_peer_propfunction kfd_dev_create_p2p_linksfunction fill_in_l1_pcachefunction fill_in_l2_l3_pcachefunction kfd_fill_cache_non_crat_infofunction kfd_topology_add_device_locked
Annotated Snippet
struct kfd_perf_attr {
struct kobj_attribute attr;
uint32_t data;
};
static ssize_t perf_show(struct kobject *kobj, struct kobj_attribute *attrs,
char *buf)
{
int offs = 0;
struct kfd_perf_attr *attr;
buf[0] = 0;
attr = container_of(attrs, struct kfd_perf_attr, attr);
if (!attr->data) /* invalid data for PMC */
return 0;
else
return sysfs_show_32bit_val(buf, offs, attr->data);
}
#define KFD_PERF_DESC(_name, _data) \
{ \
.attr = __ATTR(_name, 0444, perf_show, NULL), \
.data = _data, \
}
static struct kfd_perf_attr perf_attr_iommu[] = {
KFD_PERF_DESC(max_concurrent, 0),
KFD_PERF_DESC(num_counters, 0),
KFD_PERF_DESC(counter_ids, 0),
};
/****************************************/
static ssize_t node_show(struct kobject *kobj, struct attribute *attr,
char *buffer)
{
int offs = 0;
struct kfd_topology_device *dev;
uint32_t log_max_watch_addr;
/* Making sure that the buffer is an empty string */
buffer[0] = 0;
if (strcmp(attr->name, "gpu_id") == 0) {
dev = container_of(attr, struct kfd_topology_device,
attr_gpuid);
if (dev->gpu && kfd_devcgroup_check_permission(dev->gpu))
return -EPERM;
return sysfs_show_32bit_val(buffer, offs, dev->gpu_id);
}
if (strcmp(attr->name, "name") == 0) {
dev = container_of(attr, struct kfd_topology_device,
attr_name);
if (dev->gpu && kfd_devcgroup_check_permission(dev->gpu))
return -EPERM;
return sysfs_show_str_val(buffer, offs, dev->node_props.name);
}
dev = container_of(attr, struct kfd_topology_device,
attr_props);
if (dev->gpu && kfd_devcgroup_check_permission(dev->gpu))
return -EPERM;
sysfs_show_32bit_prop(buffer, offs, "cpu_cores_count",
dev->node_props.cpu_cores_count);
sysfs_show_32bit_prop(buffer, offs, "simd_count",
dev->gpu ? dev->node_props.simd_count : 0);
sysfs_show_32bit_prop(buffer, offs, "mem_banks_count",
dev->node_props.mem_banks_count);
sysfs_show_32bit_prop(buffer, offs, "caches_count",
dev->node_props.caches_count);
sysfs_show_32bit_prop(buffer, offs, "io_links_count",
dev->node_props.io_links_count);
sysfs_show_32bit_prop(buffer, offs, "p2p_links_count",
dev->node_props.p2p_links_count);
sysfs_show_32bit_prop(buffer, offs, "cpu_core_id_base",
dev->node_props.cpu_core_id_base);
sysfs_show_32bit_prop(buffer, offs, "simd_id_base",
dev->node_props.simd_id_base);
sysfs_show_32bit_prop(buffer, offs, "max_waves_per_simd",
dev->node_props.max_waves_per_simd);
sysfs_show_32bit_prop(buffer, offs, "lds_size_in_kb",
dev->node_props.lds_size_in_kb);
sysfs_show_32bit_prop(buffer, offs, "gds_size_in_kb",
dev->node_props.gds_size_in_kb);
sysfs_show_32bit_prop(buffer, offs, "num_gws",
dev->node_props.num_gws);
sysfs_show_32bit_prop(buffer, offs, "wave_front_size",
dev->node_props.wave_front_size);
sysfs_show_32bit_prop(buffer, offs, "array_count",
Annotation
- Immediate include surface: `linux/types.h`, `linux/kernel.h`, `linux/pci.h`, `linux/errno.h`, `linux/acpi.h`, `linux/hash.h`, `linux/cpufreq.h`, `linux/log2.h`.
- Detected declarations: `struct kfd_perf_attr`, `function list_for_each_entry`, `function list_for_each_entry`, `function kfd_release_topology_device`, `function kfd_release_topology_device_list`, `function kfd_release_live_view`, `function sysfs_show_gen_prop`, `function kfd_topology_kobj_release`, `function iolink_show`, `function mem_show`.
- 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.