drivers/gpu/drm/amd/amdkfd/kfd_crat.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdkfd/kfd_crat.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdkfd/kfd_crat.c- Extension
.c- Size
- 71504 bytes
- Lines
- 2482
- 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.
- 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/pci.hlinux/acpi.hkfd_crat.hkfd_priv.hkfd_topology.hamdgpu.hamdgpu_amdkfd.hamdgpu_xgmi.h
Detected Declarations
function get_and_inc_gpu_processor_idfunction kfd_populated_cu_info_cpufunction kfd_populated_cu_info_gpufunction kfd_parse_subtype_cufunction find_subtype_memfunction list_for_each_entryfunction kfd_parse_subtype_memfunction kfd_parse_subtype_cachefunction kfd_parse_subtype_iolinkfunction kfd_parse_subtypefunction kfd_parse_crat_tablefunction kfd_fill_gpu_cache_info_from_gfx_configfunction kfd_fill_gpu_cache_info_from_gfx_config_v2function kfd_get_gpu_cache_infofunction kfd_fill_cu_for_cpufunction kfd_fill_mem_info_for_cpufunction kfd_fill_iolink_info_for_cpufunction kfd_create_vcrat_image_cpufunction for_each_online_nodefunction kfd_fill_gpu_memory_affinityfunction kfd_find_numa_node_in_sratfunction kfd_fill_gpu_direct_io_link_to_cpufunction kfd_fill_gpu_xgmi_link_to_gpufunction kfd_create_vcrat_image_gpufunction processedfunction CRATfunction kfd_destroy_crat_image
Annotated Snippet
if (cu->proximity_domain == dev->proximity_domain) {
if (cu->flags & CRAT_CU_FLAGS_CPU_PRESENT)
kfd_populated_cu_info_cpu(dev, cu);
if (cu->flags & CRAT_CU_FLAGS_GPU_PRESENT)
kfd_populated_cu_info_gpu(dev, cu);
break;
}
}
return 0;
}
static struct kfd_mem_properties *
find_subtype_mem(uint32_t heap_type, uint32_t flags, uint32_t width,
struct kfd_topology_device *dev)
{
struct kfd_mem_properties *props;
list_for_each_entry(props, &dev->mem_props, list) {
if (props->heap_type == heap_type
&& props->flags == flags
&& props->width == width)
return props;
}
return NULL;
}
/* kfd_parse_subtype_mem - parse memory subtypes and attach it to correct
* topology device present in the device_list
*/
static int kfd_parse_subtype_mem(struct crat_subtype_memory *mem,
struct list_head *device_list)
{
struct kfd_mem_properties *props;
struct kfd_topology_device *dev;
uint32_t heap_type;
uint64_t size_in_bytes;
uint32_t flags = 0;
uint32_t width;
pr_debug("Found memory entry in CRAT table with proximity_domain=%d\n",
mem->proximity_domain);
list_for_each_entry(dev, device_list, list) {
if (mem->proximity_domain == dev->proximity_domain) {
/* We're on GPU node */
if (dev->node_props.cpu_cores_count == 0) {
/* APU */
if (mem->visibility_type == 0)
heap_type =
HSA_MEM_HEAP_TYPE_FB_PRIVATE;
/* dGPU */
else
heap_type = mem->visibility_type;
} else
heap_type = HSA_MEM_HEAP_TYPE_SYSTEM;
if (mem->flags & CRAT_MEM_FLAGS_HOT_PLUGGABLE)
flags |= HSA_MEM_FLAGS_HOT_PLUGGABLE;
if (mem->flags & CRAT_MEM_FLAGS_NON_VOLATILE)
flags |= HSA_MEM_FLAGS_NON_VOLATILE;
size_in_bytes =
((uint64_t)mem->length_high << 32) +
mem->length_low;
width = mem->width;
/* Multiple banks of the same type are aggregated into
* one. User mode doesn't care about multiple physical
* memory segments. It's managed as a single virtual
* heap for user mode.
*/
props = find_subtype_mem(heap_type, flags, width, dev);
if (props) {
props->size_in_bytes += size_in_bytes;
break;
}
props = kfd_alloc_struct(props);
if (!props)
return -ENOMEM;
props->heap_type = heap_type;
props->flags = flags;
props->size_in_bytes = size_in_bytes;
props->width = width;
dev->node_props.mem_banks_count++;
list_add_tail(&props->list, &dev->mem_props);
Annotation
- Immediate include surface: `linux/pci.h`, `linux/acpi.h`, `kfd_crat.h`, `kfd_priv.h`, `kfd_topology.h`, `amdgpu.h`, `amdgpu_amdkfd.h`, `amdgpu_xgmi.h`.
- Detected declarations: `function get_and_inc_gpu_processor_id`, `function kfd_populated_cu_info_cpu`, `function kfd_populated_cu_info_gpu`, `function kfd_parse_subtype_cu`, `function find_subtype_mem`, `function list_for_each_entry`, `function kfd_parse_subtype_mem`, `function kfd_parse_subtype_cache`, `function kfd_parse_subtype_iolink`, `function kfd_parse_subtype`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
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.