drivers/gpu/drm/drm_gpuvm.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_gpuvm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_gpuvm.c- Extension
.c- Size
- 96284 bytes
- Lines
- 3251
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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
drm/drm_drv.hdrm/drm_gpuvm.hdrm/drm_print.hlinux/export.hlinux/interval_tree_generic.hlinux/mm.h
Detected Declarations
function drm_gpuva_for_each_opfunction for_each_vm_bo_in_listfunction __restore_vm_bo_listfunction restore_vm_bo_listfunction cond_spin_unlockfunction __drm_gpuvm_bo_list_addfunction drm_gpuvm_bo_is_zombiefunction drm_gpuvm_bo_list_addfunction drm_gpuvm_check_overflowfunction drm_gpuvm_warn_check_overflowfunction drm_gpuvm_in_mm_rangefunction drm_gpuvm_in_kernel_nodefunction drm_gpuvm_range_validfunction drm_gpuvm_gem_object_freefunction drm_gpuvm_resv_object_allocfunction drm_gpuvm_initfunction drm_gpuvm_finifunction drm_gpuvm_freefunction drm_gpuvm_putfunction exec_prepare_objfunction drm_exec_initfunction __drm_gpuvm_prepare_objectsfunction for_each_vm_bo_in_listfunction drm_gpuvm_prepare_objects_lockedfunction drm_exec_initfunction drm_gpuvm_prepare_rangefunction drm_gpuvm_for_each_va_rangefunction drm_gpuvm_exec_lockfunction drm_exec_until_all_lockedfunction fn_lock_arrayfunction drm_gpuvm_exec_lock_arrayfunction drm_gpuvm_exec_lock_rangefunction drm_exec_until_all_lockedfunction __drm_gpuvm_validatefunction for_each_vm_bo_in_listfunction drm_gpuvm_validate_lockedfunction list_for_each_entry_safefunction drm_gpuvm_validatefunction drm_gpuvm_resv_add_fencefunction drm_exec_for_each_locked_objectfunction drm_gpuvm_bo_createfunction drm_gpuvm_bo_destroy_not_in_listsfunction drm_gpuvm_bo_destroy_not_in_lists_kreffunction drm_gpuvm_bo_destroyfunction drm_gpuvm_bo_putfunction drm_gpuvm_bo_into_zombiefunction drm_gpuvm_bo_defer_zombie_cleanupfunction drm_gpuvm_bo_defer_free
Annotated Snippet
* drm_gpuva_for_each_op(op, ops) {
* struct drm_gpuva *va;
*
* switch (op->op) {
* case DRM_GPUVA_OP_MAP:
* va = driver_gpuva_alloc();
* if (!va)
* ; // unwind previous VA space updates,
* // free memory and unlock
*
* driver_vm_map();
* drm_gpuva_map(gpuvm, va, &op->map);
* drm_gpuva_link(va, vm_bo);
*
* break;
* case DRM_GPUVA_OP_REMAP: {
* struct drm_gpuva *prev = NULL, *next = NULL;
*
* va = op->remap.unmap->va;
*
* if (op->remap.prev) {
* prev = driver_gpuva_alloc();
* if (!prev)
* ; // unwind previous VA space
* // updates, free memory and
* // unlock
* }
*
* if (op->remap.next) {
* next = driver_gpuva_alloc();
* if (!next)
* ; // unwind previous VA space
* // updates, free memory and
* // unlock
* }
*
* driver_vm_remap();
* drm_gpuva_remap(prev, next, &op->remap);
*
* if (prev)
* drm_gpuva_link(prev, va->vm_bo);
* if (next)
* drm_gpuva_link(next, va->vm_bo);
* drm_gpuva_unlink(va);
*
* break;
* }
* case DRM_GPUVA_OP_UNMAP:
* va = op->unmap->va;
*
* driver_vm_unmap();
* drm_gpuva_unlink(va);
* drm_gpuva_unmap(&op->unmap);
*
* break;
* default:
* break;
* }
* }
* drm_gpuvm_bo_put(vm_bo);
* driver_unlock_va_space();
*
* return 0;
* }
*
* 2) Receive a callback for each &drm_gpuva_op to create a new mapping::
*
* struct driver_context {
* struct drm_gpuvm *gpuvm;
* struct drm_gpuvm_bo *vm_bo;
* struct drm_gpuva *new_va;
* struct drm_gpuva *prev_va;
* struct drm_gpuva *next_va;
* };
*
* // ops to pass to drm_gpuvm_init()
* static const struct drm_gpuvm_ops driver_gpuvm_ops = {
* .sm_step_map = driver_gpuva_map,
* .sm_step_remap = driver_gpuva_remap,
* .sm_step_unmap = driver_gpuva_unmap,
* };
*
* // Typically drivers would embed the &drm_gpuvm and &drm_gpuva
* // structure in individual driver structures and lock the dma-resv with
* // drm_exec or similar helpers.
* int driver_mapping_create(struct drm_gpuvm *gpuvm,
* u64 addr, u64 range,
* struct drm_gem_object *obj, u64 offset)
* {
* struct driver_context ctx;
Annotation
- Immediate include surface: `drm/drm_drv.h`, `drm/drm_gpuvm.h`, `drm/drm_print.h`, `linux/export.h`, `linux/interval_tree_generic.h`, `linux/mm.h`.
- Detected declarations: `function drm_gpuva_for_each_op`, `function for_each_vm_bo_in_list`, `function __restore_vm_bo_list`, `function restore_vm_bo_list`, `function cond_spin_unlock`, `function __drm_gpuvm_bo_list_add`, `function drm_gpuvm_bo_is_zombie`, `function drm_gpuvm_bo_list_add`, `function drm_gpuvm_check_overflow`, `function drm_gpuvm_warn_check_overflow`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration 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.