drivers/gpu/drm/amd/amdkfd/kfd_device.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdkfd/kfd_device.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdkfd/kfd_device.c- Extension
.c- Size
- 50184 bytes
- Lines
- 1820
- 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/bsearch.hlinux/pci.hlinux/slab.hkfd_priv.hkfd_device_queue_manager.hkfd_pm4_headers_vi.hkfd_pm4_headers_aldebaran.hcwsr_trap_handler.hamdgpu_amdkfd.hkfd_smi_events.hkfd_svm.hkfd_migrate.hamdgpu.hamdgpu_xcp.h
Detected Declarations
function kfd_device_info_set_sdma_infofunction kfd_device_info_set_event_interrupt_classfunction kfd_device_info_initfunction kfd_cwsr_initfunction KFD_GC_VERSIONfunction kfd_gws_initfunction kfd_smi_initfunction kfd_init_nodefunction kfd_cleanup_nodesfunction kfd_setup_interrupt_bitmapfunction IP_VERSIONfunction for_each_instfunction kgd2kfd_device_initfunction kgd2kfd_device_exitfunction kgd2kfd_pre_resetfunction kgd2kfd_post_resetfunction kfd_is_lockedfunction kgd2kfd_suspendfunction kgd2kfd_resumefunction kgd2kfd_suspend_processfunction kgd2kfd_resume_processfunction kfd_resumefunction kgd2kfd_interruptfunction kgd2kfd_quiesce_mmfunction kgd2kfd_resume_mmfunction kgd2kfd_schedule_evict_and_restore_processfunction kfd_gtt_sa_initfunction kfd_gtt_sa_finifunction kfd_gtt_sa_calc_gpu_addrfunction kfd_gtt_sa_allocatefunction foundfunction kfd_gtt_sa_freefunction kgd2kfd_set_sram_ecc_flagfunction kfd_inc_compute_activefunction kfd_dec_compute_activefunction kfd_compute_activefunction kgd2kfd_smi_event_throttlefunction kfd_get_num_sdma_enginesfunction kfd_get_num_xgmi_sdma_enginesfunction kgd2kfd_check_and_lock_kfdfunction kgd2kfd_unlock_kfdfunction kgd2kfd_start_schedfunction kgd2kfd_start_sched_all_nodesfunction kgd2kfd_stop_schedfunction kgd2kfd_stop_sched_all_nodesfunction amdgpu_amdkfd_stop_sched_allfunction amdgpu_amdkfd_start_sched_allfunction kgd2kfd_compute_active
Annotated Snippet
if (gc_version < IP_VERSION(11, 0, 0)) {
/* Navi2x+, Navi1x+ */
if (gc_version == IP_VERSION(10, 3, 6))
kfd->device_info.no_atomic_fw_version = 14;
else if (gc_version == IP_VERSION(10, 3, 7))
kfd->device_info.no_atomic_fw_version = 3;
else if (gc_version >= IP_VERSION(10, 3, 0))
kfd->device_info.no_atomic_fw_version = 92;
else if (gc_version >= IP_VERSION(10, 1, 1))
kfd->device_info.no_atomic_fw_version = 145;
/* Navi1x+ */
if (gc_version >= IP_VERSION(10, 1, 1))
kfd->device_info.needs_pci_atomics = true;
} else if (gc_version < IP_VERSION(12, 0, 0)) {
/*
* PCIe atomics support acknowledgment in GFX11 RS64 CPFW requires
* MEC version >= 509. Prior RS64 CPFW versions (and all F32) require
* PCIe atomics support.
*/
kfd->device_info.needs_pci_atomics = true;
kfd->device_info.no_atomic_fw_version = kfd->adev->gfx.rs64_enable ? 509 : 0;
} else if (gc_version < IP_VERSION(13, 0, 0)) {
kfd->device_info.needs_pci_atomics = true;
kfd->device_info.no_atomic_fw_version = 2090;
} else {
kfd->device_info.needs_pci_atomics = true;
}
} else {
kfd->device_info.doorbell_size = 4;
kfd->device_info.ih_ring_entry_size = 4 * sizeof(uint32_t);
kfd->device_info.event_interrupt_class = &event_interrupt_class_cik;
kfd->device_info.num_sdma_queues_per_engine = 2;
if (asic_type != CHIP_KAVERI &&
asic_type != CHIP_HAWAII &&
asic_type != CHIP_TONGA)
kfd->device_info.supports_cwsr = true;
if (asic_type != CHIP_HAWAII && !vf)
kfd->device_info.needs_pci_atomics = true;
}
}
struct kfd_dev *kgd2kfd_probe(struct amdgpu_device *adev, bool vf)
{
struct kfd_dev *kfd = NULL;
const struct kfd2kgd_calls *f2g = NULL;
uint32_t gfx_target_version = 0;
switch (adev->asic_type) {
#ifdef CONFIG_DRM_AMDGPU_CIK
case CHIP_KAVERI:
gfx_target_version = 70000;
if (!vf)
f2g = &gfx_v7_kfd2kgd;
break;
#endif
case CHIP_CARRIZO:
gfx_target_version = 80001;
if (!vf)
f2g = &gfx_v8_kfd2kgd;
break;
#ifdef CONFIG_DRM_AMDGPU_CIK
case CHIP_HAWAII:
gfx_target_version = 70001;
if (!amdgpu_exp_hw_support)
pr_info(
"KFD support on Hawaii is experimental. See modparam exp_hw_support\n"
);
else if (!vf)
f2g = &gfx_v7_kfd2kgd;
break;
#endif
case CHIP_TONGA:
gfx_target_version = 80002;
if (!vf)
f2g = &gfx_v8_kfd2kgd;
break;
case CHIP_FIJI:
case CHIP_POLARIS10:
gfx_target_version = 80003;
f2g = &gfx_v8_kfd2kgd;
break;
case CHIP_POLARIS11:
case CHIP_POLARIS12:
case CHIP_VEGAM:
gfx_target_version = 80003;
if (!vf)
f2g = &gfx_v8_kfd2kgd;
Annotation
- Immediate include surface: `linux/bsearch.h`, `linux/pci.h`, `linux/slab.h`, `kfd_priv.h`, `kfd_device_queue_manager.h`, `kfd_pm4_headers_vi.h`, `kfd_pm4_headers_aldebaran.h`, `cwsr_trap_handler.h`.
- Detected declarations: `function kfd_device_info_set_sdma_info`, `function kfd_device_info_set_event_interrupt_class`, `function kfd_device_info_init`, `function kfd_cwsr_init`, `function KFD_GC_VERSION`, `function kfd_gws_init`, `function kfd_smi_init`, `function kfd_init_node`, `function kfd_cleanup_nodes`, `function kfd_setup_interrupt_bitmap`.
- 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.