drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h- Extension
.h- Size
- 18220 bytes
- Lines
- 581
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/list.hlinux/types.hlinux/mm.hlinux/kthread.hlinux/workqueue.hlinux/mmu_notifier.hlinux/memremap.hkgd_kfd_interface.hdrm/drm_client.hamdgpu_sync.hamdgpu_vm.hamdgpu_xcp.hkfd_topology.hamdgpu_ptl.h
Detected Declarations
struct amdgpu_devicestruct kfd_process_devicestruct amdgpu_reset_contextstruct kfd_mem_attachmentstruct kgd_memstruct amdgpu_amdkfd_fencestruct amdgpu_kfd_devstruct amdkfd_process_infoenum TLB_FLUSH_TYPEenum kfd_mem_attachment_typeenum kgd_engine_typefunction amdkfd_fence_check_mmfunction amdgpu_amdkfd_remove_all_eviction_fencesfunction amdgpu_amdkfd_bo_validate_and_fencefunction amdgpu_amdkfd_gpuvm_init_mem_limitsfunction kgd2kfd_init_zone_devicefunction kgd2kfd_initfunction kgd2kfd_exitfunction kgd2kfd_device_initfunction kgd2kfd_device_exitfunction kgd2kfd_suspend_processfunction kgd2kfd_pre_resetfunction kgd2kfd_post_resetfunction kgd2kfd_interruptfunction kgd2kfd_unlock_kfdfunction kgd2kfd_start_sched_all_nodesfunction amdgpu_amdkfd_start_sched_allfunction kgd2kfd_stop_schedfunction kgd2kfd_stop_sched_all_nodesfunction amdgpu_amdkfd_stop_sched_allfunction kgd2kfd_compute_activefunction kgd2kfd_vmfault_fast_pathfunction kgd2kfd_lock_kfd
Annotated Snippet
struct kfd_mem_attachment {
struct list_head list;
enum kfd_mem_attachment_type type;
bool is_mapped;
struct amdgpu_bo_va *bo_va;
struct amdgpu_device *adev;
uint64_t va;
uint64_t pte_flags;
};
struct kgd_mem {
struct mutex lock;
struct amdgpu_bo *bo;
struct dma_buf *dmabuf;
struct amdgpu_hmm_range *range;
struct list_head attachments;
/* protected by amdkfd_process_info.lock */
struct list_head validate_list;
uint32_t domain;
unsigned int mapped_to_gpu_memory;
uint64_t va;
uint32_t alloc_flags;
uint32_t invalid;
struct amdkfd_process_info *process_info;
struct amdgpu_sync sync;
uint32_t gem_handle;
bool aql_queue;
bool is_imported;
};
/* KFD Memory Eviction */
struct amdgpu_amdkfd_fence {
struct dma_fence base;
struct mm_struct *mm;
spinlock_t lock;
char timeline_name[TASK_COMM_LEN];
struct svm_range_bo *svm_bo;
uint16_t context_id;
};
struct amdgpu_kfd_dev {
struct kfd_dev *dev;
int64_t vram_used[MAX_XCP];
uint64_t vram_used_aligned[MAX_XCP];
bool init_complete;
struct work_struct reset_work;
/* Client for KFD BO GEM handle allocations */
struct drm_client_dev client;
/* HMM page migration MEMORY_DEVICE_PRIVATE mapping
* Must be last --ends in a flexible-array member.
*/
struct dev_pagemap pgmap;
};
enum kgd_engine_type {
KGD_ENGINE_PFP = 1,
KGD_ENGINE_ME,
KGD_ENGINE_CE,
KGD_ENGINE_MEC1,
KGD_ENGINE_MEC2,
KGD_ENGINE_RLC,
KGD_ENGINE_SDMA1,
KGD_ENGINE_SDMA2,
KGD_ENGINE_MAX
};
struct amdkfd_process_info {
/* List head of all VMs that belong to a KFD process */
struct list_head vm_list_head;
/* List head for all KFD BOs that belong to a KFD process. */
struct list_head kfd_bo_list;
/* List of userptr BOs that are valid or invalid */
struct list_head userptr_valid_list;
struct list_head userptr_inval_list;
/* Lock to protect kfd_bo_list */
struct mutex lock;
/* Number of VMs */
unsigned int n_vms;
/* Eviction Fence */
struct amdgpu_amdkfd_fence *eviction_fence;
/* MMU-notifier related fields */
Annotation
- Immediate include surface: `linux/list.h`, `linux/types.h`, `linux/mm.h`, `linux/kthread.h`, `linux/workqueue.h`, `linux/mmu_notifier.h`, `linux/memremap.h`, `kgd_kfd_interface.h`.
- Detected declarations: `struct amdgpu_device`, `struct kfd_process_device`, `struct amdgpu_reset_context`, `struct kfd_mem_attachment`, `struct kgd_mem`, `struct amdgpu_amdkfd_fence`, `struct amdgpu_kfd_dev`, `struct amdkfd_process_info`, `enum TLB_FLUSH_TYPE`, `enum kfd_mem_attachment_type`.
- 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.
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.