drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c- Extension
.c- Size
- 26258 bytes
- Lines
- 968
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
drm/drm_drv.hamdgpu.hamdgpu_trace.hamdgpu_vm.hamdgpu_job.h
Detected Declarations
struct amdgpu_vm_pt_cursorfunction amdgpu_vm_pt_level_shiftfunction amdgpu_vm_pt_num_entriesfunction amdgpu_vm_pt_entries_maskfunction amdgpu_vm_pt_sizefunction amdgpu_vm_pt_parentfunction amdgpu_vm_pt_startfunction amdgpu_vm_pt_descendantfunction amdgpu_vm_pt_siblingfunction amdgpu_vm_pt_ancestorfunction amdgpu_vm_pt_nextfunction amdgpu_vm_pt_first_dfsfunction amdgpu_vm_pt_continue_dfsfunction amdgpu_vm_pt_next_dfsfunction amdgpu_vm_pt_clearfunction amdgpu_vm_pt_createfunction amdgpu_vm_pt_allocfunction amdgpu_vm_pt_freefunction amdgpu_vm_pt_free_listfunction amdgpu_vm_pt_add_listfunction for_each_amdgpu_vm_pt_dfs_safefunction amdgpu_vm_pt_free_rootfunction for_each_amdgpu_vm_pt_dfs_safefunction amdgpu_vm_pde_updatefunction amdgpu_vm_pte_update_noretry_flagsfunction amdgpu_vm_pte_update_flagsfunction amdgpu_vm_pte_fragmentfunction amdgpu_vm_ptes_updatefunction amdgpu_vm_pt_map_tablesfunction for_each_amdgpu_vm_pt_dfs_safe
Annotated Snippet
struct amdgpu_vm_pt_cursor {
uint64_t pfn;
struct amdgpu_vm_bo_base *parent;
struct amdgpu_vm_bo_base *entry;
unsigned int level;
};
/**
* amdgpu_vm_pt_level_shift - return the addr shift for each level
*
* @adev: amdgpu_device pointer
* @level: VMPT level
*
* Returns:
* The number of bits the pfn needs to be right shifted for a level.
*/
static unsigned int amdgpu_vm_pt_level_shift(struct amdgpu_device *adev,
unsigned int level)
{
switch (level) {
case AMDGPU_VM_PDB3:
case AMDGPU_VM_PDB2:
case AMDGPU_VM_PDB1:
case AMDGPU_VM_PDB0:
return 9 * (AMDGPU_VM_PDB0 - level) +
adev->vm_manager.block_size;
case AMDGPU_VM_PTB:
return 0;
default:
return ~0;
}
}
/**
* amdgpu_vm_pt_num_entries - return the number of entries in a PD/PT
*
* @adev: amdgpu_device pointer
* @level: VMPT level
*
* Returns:
* The number of entries in a page directory or page table.
*/
static unsigned int amdgpu_vm_pt_num_entries(struct amdgpu_device *adev,
unsigned int level)
{
unsigned int shift;
shift = amdgpu_vm_pt_level_shift(adev, adev->vm_manager.root_level);
if (level == adev->vm_manager.root_level)
/* For the root directory */
return round_up(adev->vm_manager.max_pfn, 1ULL << shift)
>> shift;
else if (level != AMDGPU_VM_PTB)
/* Everything in between */
return 512;
/* For the page tables on the leaves */
return AMDGPU_VM_PTE_COUNT(adev);
}
/**
* amdgpu_vm_pt_entries_mask - the mask to get the entry number of a PD/PT
*
* @adev: amdgpu_device pointer
* @level: VMPT level
*
* Returns:
* The mask to extract the entry number of a PD/PT from an address.
*/
static uint32_t amdgpu_vm_pt_entries_mask(struct amdgpu_device *adev,
unsigned int level)
{
if (level <= adev->vm_manager.root_level)
return 0xffffffff;
else if (level != AMDGPU_VM_PTB)
return 0x1ff;
else
return AMDGPU_VM_PTE_COUNT(adev) - 1;
}
/**
* amdgpu_vm_pt_size - returns the size of the page table in bytes
*
* @adev: amdgpu_device pointer
* @level: VMPT level
*
* Returns:
* The size of the BO for a page directory or page table in bytes.
*/
static unsigned int amdgpu_vm_pt_size(struct amdgpu_device *adev,
Annotation
- Immediate include surface: `drm/drm_drv.h`, `amdgpu.h`, `amdgpu_trace.h`, `amdgpu_vm.h`, `amdgpu_job.h`.
- Detected declarations: `struct amdgpu_vm_pt_cursor`, `function amdgpu_vm_pt_level_shift`, `function amdgpu_vm_pt_num_entries`, `function amdgpu_vm_pt_entries_mask`, `function amdgpu_vm_pt_size`, `function amdgpu_vm_pt_parent`, `function amdgpu_vm_pt_start`, `function amdgpu_vm_pt_descendant`, `function amdgpu_vm_pt_sibling`, `function amdgpu_vm_pt_ancestor`.
- 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.