drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c- Extension
.c- Size
- 44790 bytes
- Lines
- 1705
- 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/slab.hlinux/dma-buf.hlinux/export.hdrm/drm_drv.hdrm/amdgpu_drm.hdrm/drm_cache.hamdgpu.hamdgpu_trace.hamdgpu_amdkfd.hamdgpu_vram_mgr.hamdgpu_vm.hamdgpu_dma_buf.h
Detected Declarations
function filesfunction amdgpu_bo_user_destroyfunction amdgpu_bo_is_amdgpu_bofunction amdgpu_bo_placement_from_domainfunction amdgpu_bo_create_reservedfunction amdgpu_bo_create_kernelfunction amdgpu_bo_create_isp_userfunction amdgpu_bo_create_kernel_atfunction amdgpu_bo_free_kernelfunction amdgpu_bo_free_isp_userfunction amdgpu_bo_validate_sizefunction amdgpu_bo_support_uswcfunction amdgpu_bo_createfunction amdgpu_bo_create_userfunction amdgpu_bo_create_vmfunction amdgpu_bo_kptrfunction ttm_kmap_obj_virtualfunction amdgpu_bo_kmapfunction amdgpu_bo_unreffunction amdgpu_bo_pinfunction amdgpu_bo_unpinfunction amdgpu_ttm_initfunction amdgpu_bo_initfunction amdgpu_bo_set_tiling_flagsfunction amdgpu_bo_get_tiling_flagsfunction amdgpu_bo_set_metadatafunction amdgpu_bo_get_metadatafunction amdgpu_bo_move_notifyfunction amdgpu_bo_release_notifyfunction amdgpu_bo_fault_reserve_notifyfunction amdgpu_bo_fencefunction amdgpu_bo_sync_wait_resvfunction amdgpu_bo_sync_waitfunction amdgpu_bo_gpu_offsetfunction amdgpu_bo_fb_aper_addrfunction amdgpu_bo_gpu_offset_no_checkfunction amdgpu_bo_mem_stats_placementfunction amdgpu_bo_get_preferred_domainfunction amdgpu_bo_print_info
Annotated Snippet
if (adev->gmc.mem_partitions && mem_id >= 0) {
places[c].fpfn = adev->gmc.mem_partitions[mem_id].range.fpfn;
/*
* memory partition range lpfn is inclusive start + size - 1
* TTM place lpfn is exclusive start + size
*/
places[c].lpfn = adev->gmc.mem_partitions[mem_id].range.lpfn + 1;
} else {
places[c].fpfn = 0;
places[c].lpfn = 0;
}
places[c].mem_type = TTM_PL_VRAM;
places[c].flags = 0;
if (flags & AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED)
places[c].lpfn = min_not_zero(places[c].lpfn, visible_pfn);
else
places[c].flags |= TTM_PL_FLAG_TOPDOWN;
if (abo->tbo.type == ttm_bo_type_kernel &&
flags & AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS)
places[c].flags |= TTM_PL_FLAG_CONTIGUOUS;
c++;
}
if (domain & AMDGPU_GEM_DOMAIN_DOORBELL) {
places[c].fpfn = 0;
places[c].lpfn = 0;
places[c].mem_type = AMDGPU_PL_DOORBELL;
places[c].flags = 0;
c++;
}
if (domain & AMDGPU_GEM_DOMAIN_GTT) {
places[c].fpfn = 0;
places[c].lpfn = 0;
places[c].mem_type =
abo->flags & AMDGPU_GEM_CREATE_PREEMPTIBLE ?
AMDGPU_PL_PREEMPT : TTM_PL_TT;
places[c].flags = 0;
/*
* When GTT is just an alternative to VRAM make sure that we
* only use it as fallback and still try to fill up VRAM first.
*/
if (abo->tbo.resource && !(adev->flags & AMD_IS_APU) &&
domain & abo->preferred_domains & AMDGPU_GEM_DOMAIN_VRAM)
places[c].flags |= TTM_PL_FLAG_FALLBACK;
c++;
}
if (domain & AMDGPU_GEM_DOMAIN_CPU) {
places[c].fpfn = 0;
places[c].lpfn = 0;
places[c].mem_type = TTM_PL_SYSTEM;
places[c].flags = 0;
c++;
}
if (domain & AMDGPU_GEM_DOMAIN_GDS) {
places[c].fpfn = 0;
places[c].lpfn = 0;
places[c].mem_type = AMDGPU_PL_GDS;
places[c].flags = 0;
c++;
}
if (domain & AMDGPU_GEM_DOMAIN_GWS) {
places[c].fpfn = 0;
places[c].lpfn = 0;
places[c].mem_type = AMDGPU_PL_GWS;
places[c].flags = 0;
c++;
}
if (domain & AMDGPU_GEM_DOMAIN_OA) {
places[c].fpfn = 0;
places[c].lpfn = 0;
places[c].mem_type = AMDGPU_PL_OA;
places[c].flags = 0;
c++;
}
if (!c) {
places[c].fpfn = 0;
places[c].lpfn = 0;
places[c].mem_type = TTM_PL_SYSTEM;
places[c].flags = 0;
c++;
}
Annotation
- Immediate include surface: `linux/list.h`, `linux/slab.h`, `linux/dma-buf.h`, `linux/export.h`, `drm/drm_drv.h`, `drm/amdgpu_drm.h`, `drm/drm_cache.h`, `amdgpu.h`.
- Detected declarations: `function files`, `function amdgpu_bo_user_destroy`, `function amdgpu_bo_is_amdgpu_bo`, `function amdgpu_bo_placement_from_domain`, `function amdgpu_bo_create_reserved`, `function amdgpu_bo_create_kernel`, `function amdgpu_bo_create_isp_user`, `function amdgpu_bo_create_kernel_at`, `function amdgpu_bo_free_kernel`, `function amdgpu_bo_free_isp_user`.
- 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.