drivers/gpu/drm/radeon/radeon_object.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/radeon/radeon_object.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/radeon/radeon_object.c- Extension
.c- Size
- 21438 bytes
- Lines
- 795
- 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/io.hlinux/list.hlinux/slab.hdrm/drm_cache.hdrm/drm_prime.hdrm/radeon_drm.hradeon.hradeon_trace.hradeon_ttm.h
Detected Declarations
function radeon_ttm_bo_destroyfunction radeon_ttm_bo_is_radeon_bofunction radeon_ttm_placement_from_domainfunction radeon_bo_createfunction radeon_bo_kmapfunction radeon_bo_kunmapfunction radeon_bo_unreffunction radeon_bo_pin_restrictedfunction radeon_bo_pinfunction radeon_bo_unpinfunction radeon_bo_evict_vramfunction radeon_bo_force_deletefunction radeon_bo_initfunction radeon_bo_finifunction radeon_bo_get_threshold_for_movesfunction radeon_bo_list_validatefunction drm_exec_until_all_lockedfunction list_for_each_entryfunction radeon_bo_get_surface_regfunction radeon_bo_clear_surface_regfunction radeon_bo_set_tiling_flagsfunction radeon_bo_get_tiling_flagsfunction radeon_bo_check_tilingfunction radeon_bo_move_notifyfunction radeon_bo_fault_reserve_notifyfunction radeon_bo_fence
Annotated Snippet
if (ptr) {
*ptr = bo->kptr;
}
return 0;
}
r = ttm_bo_kmap(&bo->tbo, 0, PFN_UP(bo->tbo.base.size), &bo->kmap);
if (r) {
return r;
}
bo->kptr = ttm_kmap_obj_virtual(&bo->kmap, &is_iomem);
if (ptr) {
*ptr = bo->kptr;
}
radeon_bo_check_tiling(bo, 0, 0);
return 0;
}
void radeon_bo_kunmap(struct radeon_bo *bo)
{
if (bo->kptr == NULL)
return;
bo->kptr = NULL;
radeon_bo_check_tiling(bo, 0, 0);
ttm_bo_kunmap(&bo->kmap);
}
struct radeon_bo *radeon_bo_ref(struct radeon_bo *bo)
{
if (bo == NULL)
return NULL;
drm_gem_object_get(&bo->tbo.base);
return bo;
}
void radeon_bo_unref(struct radeon_bo **bo)
{
if ((*bo) == NULL)
return;
drm_gem_object_put(&(*bo)->tbo.base);
*bo = NULL;
}
int radeon_bo_pin_restricted(struct radeon_bo *bo, u32 domain, u64 max_offset,
u64 *gpu_addr)
{
struct ttm_operation_ctx ctx = { false, false };
int r, i;
if (radeon_ttm_tt_has_userptr(bo->rdev, bo->tbo.ttm))
return -EPERM;
if (bo->tbo.pin_count) {
ttm_bo_pin(&bo->tbo);
if (gpu_addr)
*gpu_addr = radeon_bo_gpu_offset(bo);
if (max_offset != 0) {
u64 domain_start;
if (domain == RADEON_GEM_DOMAIN_VRAM)
domain_start = bo->rdev->mc.vram_start;
else
domain_start = bo->rdev->mc.gtt_start;
WARN_ON_ONCE(max_offset <
(radeon_bo_gpu_offset(bo) - domain_start));
}
return 0;
}
if (bo->prime_shared_count && domain == RADEON_GEM_DOMAIN_VRAM) {
/* A BO shared as a dma-buf cannot be sensibly migrated to VRAM */
return -EINVAL;
}
radeon_ttm_placement_from_domain(bo, domain);
for (i = 0; i < bo->placement.num_placement; i++) {
/* force to pin into visible video ram */
if ((bo->placements[i].mem_type == TTM_PL_VRAM) &&
!(bo->flags & RADEON_GEM_NO_CPU_ACCESS) &&
(!max_offset || max_offset > bo->rdev->mc.visible_vram_size))
bo->placements[i].lpfn =
bo->rdev->mc.visible_vram_size >> PAGE_SHIFT;
else
bo->placements[i].lpfn = max_offset >> PAGE_SHIFT;
}
r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
if (likely(r == 0)) {
ttm_bo_pin(&bo->tbo);
Annotation
- Immediate include surface: `linux/io.h`, `linux/list.h`, `linux/slab.h`, `drm/drm_cache.h`, `drm/drm_prime.h`, `drm/radeon_drm.h`, `radeon.h`, `radeon_trace.h`.
- Detected declarations: `function radeon_ttm_bo_destroy`, `function radeon_ttm_bo_is_radeon_bo`, `function radeon_ttm_placement_from_domain`, `function radeon_bo_create`, `function radeon_bo_kmap`, `function radeon_bo_kunmap`, `function radeon_bo_unref`, `function radeon_bo_pin_restricted`, `function radeon_bo_pin`, `function radeon_bo_unpin`.
- 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.