STRUCT MSM_GEM_VM(9)
π struct msm_gem_vm(9) π
okay bestie, welcome to the Kernel API Manual page for struct msm_gem_vm(9) β this is literally the VM object and we're gonna break it down, no cap. β¨
πΈ NAME πΈ
struct msm_gem_vm β VM object
β¨ SYNOPSIS β¨
here's the literal struct, character for character, do not touch:
struct msm_gem_vm {
struct drm_gpuvm base;
struct rcu_head rcu;
struct drm_gpu_scheduler sched;
struct {
wait_queue_head_t wait;
atomic_t in_flight;
} prealloc_throttle;
struct drm_mm mm;
struct msm_mmu *mmu;
struct mutex mmu_lock;
struct pid *pid;
struct dma_fence *last_fence;
struct msm_gem_vm_log_entry *log;
uint32_t log_shift;
uint32_t log_idx;
int faults;
bool managed;
bool unusable;
};
π Members π
baseβ Inherit fromdrm_gpuvm.rcuβ RCU-delayed free so an exportedschedfence->schedstays valid.schedβ Scheduler used for asynchronousVM_BINDrequest.
Unused for kernel managed VMs (where all operations are synchronous).
prealloc_throttleβ Used to throttleVM_BINDops if too much pre- allocated memory is in flight.
Because we have to pre-allocate pgtable pages for the worst case (ie. new mappings do not share any PTEs with existing mappings) we could end up consuming a lot of resources transiently. The prealloc_throttle puts an upper bound on that.
mmβ Memory management for kernel managed VA allocations
Only used for kernel managed VMs, unused for user managed VMs.
Protected by vm lock. See msm_gem_lock_vm_and_obj, for ex.
mmuβ The mmu object which manages the pgtablesmmu_lockβ Protects access to the mmupidβ For address spaces associated with a specific process, this will be non-NULL:last_fenceβ Fence for last pending work scheduled on the VMlogβ A log of recent VM updateslog_shiftβ length of log is(1 << log_shift)log_idxβ index of next log entry to writefaultsβ the number of GPU hangs associated with this address spacemanagedβ is this a kernel managed VM?unusableβ True if the VM has turned unusable because something bad happened during an asynchronous request.
We don't try to recover from such failures, because this implies informing userspace about the specific operation that failed, and hoping the userspace driver can replay things from there. This all sounds very complicated for little gain.
Instead, we should just flag the VM as unusable, and fail any further request targeting this VM.
As an analogy, this would be mapped to a VK_ERROR_DEVICE_LOST situation, where the logical device needs to be re-created.
π Description π
A VM object representing a GPU (or display or GMU or ...) virtual address space. π¦
In the case of GPU, if per-process address spaces are supported, the address space is split into two VMs, which map to TTBR0 and TTBR1 in the SMMU. TTBR0 is used for userspace objects, and is unique per msm_context/drm_file, while TTBR1 is the same for all processes. (The kernel controlled ringbuffer and a few other kernel controlled buffers live in TTBR1.) β¨
The GPU TTBR0 vm can be managed by userspace or by the kernel, depending on whether userspace supports VM_BIND. All other vm's are managed by the kernel. (Managed by kernel means the kernel is responsible for VA allocation.) π
Note that because VM_BIND allows a given BO to be mapped multiple times in a VM, and therefore have multiple VMA's in a VM, there is an extra object provided by drm_gpuvm infrastructure.. the drm_gpuvm_bo, which is not embedded in any larger driver structure. The GEM object holds a list of drm_gpuvm_bo, which in turn holds a list of msm_gem_vma. A linked vma holds a reference to the vm_bo, and drops it when the vma is unlinked. So we just need to call drm_gpuvm_bo_obtain_locked to return a ref to an existing vm_bo, or create a new one. Once the vma is linked, the ref to the vm_bo can be dropped (since the vma is holding one). π«Ά
π SEE ALSO π
Kernel file ./drivers/gpu/drm/msm/msm_gem.h struct msm_gem_vm_log_entry(9), struct msm_gem_vma(9), msm_gem_lock_vm_and_obj(9) πΈ
and that's the whole vibe, bestie π
β this iconic page comes from ./drivers/gpu/drm/msm, dated October 2026, and the title is literally struct msm_gem_vm(9). slay. π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms