drivers/gpu/drm/msm/msm_gem_vma.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/msm/msm_gem_vma.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/msm/msm_gem_vma.c- Extension
.c- Size
- 39200 bytes
- Lines
- 1628
- 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.
- 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_file.hdrm/msm_drm.hlinux/file.hlinux/sync_file.hmsm_drv.hmsm_gem.hmsm_gpu.hmsm_mmu.hmsm_syncobj.h
Detected Declarations
struct msm_vm_map_opstruct msm_vm_unmap_opstruct msm_vm_opstruct msm_vm_bind_jobstruct msm_vm_bind_opstruct op_argfunction msm_gem_vm_freefunction msm_gem_vm_unusablefunction vm_logfunction vm_unmap_opfunction vm_map_opfunction msm_gem_vma_unmapfunction vm_unmap_opfunction msm_gem_vma_mapfunction msm_gem_vma_closefunction msm_gem_vma_newfunction GEM_WARN_ONfunction msm_gem_vm_bo_validatefunction drm_gpuvm_bo_for_each_vafunction vm_op_enqueuefunction vma_from_opfunction msm_gem_vm_sm_step_mapfunction msm_gem_vm_sm_step_remapfunction msm_gem_vm_sm_step_unmapfunction msm_vma_job_runfunction job_foreach_bofunction msm_vma_job_freefunction msm_gem_vm_createfunction msm_gem_vm_closefunction drm_gpuvm_for_each_va_safefunction vm_bind_job_createfunction invalid_alignmentfunction lookup_opfunction vm_bind_job_lookup_opsfunction prealloc_countfunction ops_are_same_ptefunction vm_bind_prealloc_countfunction vm_bind_job_lock_objectsfunction vm_bind_job_pin_objectsfunction msm_gem_pin_vma_lockedfunction vm_bind_job_unpin_objectsfunction vm_bind_job_preparefunction locksfunction msm_ioctl_vm_bind
Annotated Snippet
struct msm_vm_map_op {
/** @iova: start address for mapping */
uint64_t iova;
/** @range: size of the region to map */
uint64_t range;
/** @offset: offset into @sgt to map */
uint64_t offset;
/** @sgt: pages to map, or NULL for a PRR mapping */
struct sg_table *sgt;
/** @prot: the mapping protection flags */
int prot;
/**
* @queue_id: The id of the submitqueue the operation is performed
* on, or zero for (in particular) UNMAP ops triggered outside of
* a submitqueue (ie. process cleanup)
*/
int queue_id;
};
/**
* struct msm_vm_unmap_op - unmap a range of pages from pgtable
*/
struct msm_vm_unmap_op {
/** @iova: start address for unmap */
uint64_t iova;
/** @range: size of region to unmap */
uint64_t range;
/** @reason: The reason for the unmap */
const char *reason;
/**
* @queue_id: The id of the submitqueue the operation is performed
* on, or zero for (in particular) UNMAP ops triggered outside of
* a submitqueue (ie. process cleanup)
*/
int queue_id;
};
/**
* struct msm_vm_op - A MAP or UNMAP operation
*/
struct msm_vm_op {
/** @op: The operation type */
enum {
MSM_VM_OP_MAP = 1,
MSM_VM_OP_UNMAP,
} op;
union {
/** @map: Parameters used if op == MSM_VMA_OP_MAP */
struct msm_vm_map_op map;
/** @unmap: Parameters used if op == MSM_VMA_OP_UNMAP */
struct msm_vm_unmap_op unmap;
};
/** @node: list head in msm_vm_bind_job::vm_ops */
struct list_head node;
/**
* @obj: backing object for pages to be mapped/unmapped
*
* Async unmap ops, in particular, must hold a reference to the
* original GEM object backing the mapping that will be unmapped.
* But the same can be required in the map path, for example if
* there is not a corresponding unmap op, such as process exit.
*
* This ensures that the pages backing the mapping are not freed
* before the mapping is torn down.
*/
struct drm_gem_object *obj;
};
/**
* struct msm_vm_bind_job - Tracking for a VM_BIND ioctl
*
* A table of userspace requested VM updates (MSM_VM_BIND_OP_UNMAP/MAP/MAP_NULL)
* gets applied to the vm, generating a list of VM ops (MSM_VM_OP_MAP/UNMAP)
* which are applied to the pgtables asynchronously. For example a userspace
* requested MSM_VM_BIND_OP_MAP could end up generating both an MSM_VM_OP_UNMAP
* to unmap an existing mapping, and a MSM_VM_OP_MAP to apply the new mapping.
*/
struct msm_vm_bind_job {
/** @base: base class for drm_sched jobs */
struct drm_sched_job base;
/** @vm: The VM being operated on */
struct drm_gpuvm *vm;
/** @fence: The fence that is signaled when job completes */
struct dma_fence *fence;
/** @queue: The queue that the job runs on */
struct msm_gpu_submitqueue *queue;
Annotation
- Immediate include surface: `drm/drm_file.h`, `drm/msm_drm.h`, `linux/file.h`, `linux/sync_file.h`, `msm_drv.h`, `msm_gem.h`, `msm_gpu.h`, `msm_mmu.h`.
- Detected declarations: `struct msm_vm_map_op`, `struct msm_vm_unmap_op`, `struct msm_vm_op`, `struct msm_vm_bind_job`, `struct msm_vm_bind_op`, `struct op_arg`, `function msm_gem_vm_free`, `function msm_gem_vm_unusable`, `function vm_log`, `function vm_unmap_op`.
- 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.
- 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.