STRUCT PANTHOR_VM(9)
okay bestie, welcome to struct panthor_vm(9) from the Kernel API Manual β yes, we're doing kernel struct lore today and it's lowkey iconic π
π NAME π
struct panthor_vm β VM object. That's the name, that's the vibe: virtual memory main character energy β¨
β¨ SYNOPSIS β¨
struct panthor_vm {
struct drm_gpuvm base;
struct drm_gpu_scheduler sched;
struct drm_sched_entity entity;
struct panthor_device *ptdev;
u64 memattr;
struct io_pgtable_ops *pgtbl_ops;
void *root_page_table;
struct mutex op_lock;
struct panthor_vm_op_ctx *op_ctx;
struct drm_mm mm;
struct mutex mm_lock;
struct {
u64 start;
u64 end;
} kernel_auto_va;
u64 user_va_range;
struct {
int id;
refcount_t active_cnt;
struct list_head lru_node;
} as;
struct {
struct panthor_heap_pool *pool;
struct mutex lock;
} heaps;
struct list_head node;
bool for_mcu;
bool destroyed;
bool unusable;
bool unhandled_fault;
struct {
u64 start;
u64 size;
} locked_region;
struct {
struct drm_gem_lru lru;
struct list_head lru_node;
} reclaim;
struct panthor_gem_object *dummy;
};
π₯ Members π₯
baseβ Inherit fromdrm_gpuvm. We delegate all the VA management to the commondrm_gpuvmframework and only implement hooks to update the MMU page table. delegation slay πschedβ Scheduler used for asynchronousVM_BINDrequest. We use a 1:1 scheduler here.entityβ Scheduling entity representing theVM_BINDqueue. There's currently one bind queue per VM. It doesn't make sense to allow more given the VM operations are serialized anyway.ptdevβ Device.memattrβ Value to program to theAS_MEMATTRregister.pgtbl_opsβ Page table operations.root_page_tableβ Stores the root page table pointer.op_lockβ Lock used to serialize operations on a VM. The serialization of jobs queued to theVM_BINDqueue is already taken care of bydrm_sched, but we need to serialize synchronous and asynchronousVM_BINDrequest. This is what this lock is for.op_ctxβ The context attached to the currently executing VM operation.NULLwhen no operation is in progress.mmβ Memory management object representing the auto-VA/kernel-VA. Used to auto-allocate VA space for kernel-managed objects (tiler heaps, ...). For the MCU VM, this is managing the VA range that's used to map all shared interfaces. For user VMs, the range is specified by userspace, and must not exceed half of the VA space addressable.mm_lockβ Lock protecting themmfield.kernel_auto_vaβ Automatic VA-range for kernel BOs.kernel_auto_va.startβ Start of the automatic VA-range for kernel BOs.kernel_auto_va.endβ End of the automatic VA-range for kernel BOs.
user_va_rangeβ Upper boundary of VAs VM users can map objects against.asβ Address space related fields.as.idβ ID of the address space this VM is bound to. A value of-1means the VM is inactive/not bound.as.active_cntβ Number of active users of this VM.as.lru_nodeβ Used to insert the VM inpanthor_mmu::as::lru_list(the original says βinsteadβ β typo era, but the intent is insert π). Active VMs should not be inserted in the LRU list.
heapsβ Tiler heap related fields.heaps.poolβ The heap pool attached to this VM. Will stayNULLuntil someone creates a heap context on this VM.heaps.lockβ Lock used to protect access topool.
nodeβ Used to insert the VM inpanthor_mmu::vm::list.for_mcuβ True if this is the MCU VM.destroyedβ True if the VM was destroyed. No further bind requests should be queued to a destroyed 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.
We also provide a way to query a VM state, so userspace can destroy it and create a new one.
As an analogy, this would be mapped to a VK_ERROR_DEVICE_LOST situation, where the logical device needs to be re-created.
unhandled_faultβ Unhandled fault happened. This should be reported to the scheduler, and the queue/group be flagged as faulty as a result.locked_regionβ Information about the currently locked region currently.locked_region.startβ Start of the locked region.locked_region.sizeβ Size of the locked region.
reclaimβ Fields related to BO reclaim.reclaim.lruβ LRU of BOs that are only mapped to this VM.reclaim.lru_nodeβ Node used to insert the VM inpanthor_device::reclaim::vms.
dummyβ Dummy object used for sparse mappings. VM's must keep a reference to the file context-wide dummy BO because they can outlive the file context, which includes the VM pool holding the original dummy BO reference.
π Description π
A VM is an object representing a GPU (or MCU) virtual address space. It embeds the MMU page table for this address space, a tree containing all the virtual mappings of GEM objects, and other things needed to manage the VM.
Except for the MCU VM, which is managed by the kernel, all other VMs are created by userspace and mostly managed by userspace, using the DRM_IOCTL_PANTHOR_VM_BIND ioctl.
A portion of the virtual address space is reserved for kernel objects, like heap chunks, and userspace gets to decide how much of the virtual address space is left to the kernel (half of the virtual address space by default).
π SEE ALSO π
Kernel file ./drivers/gpu/drm/panthor/panthor_mmu.c β and the whole friend group: struct panthor_as_slot(9), struct panthor_mmu(9), struct panthor_vm_pool(9), struct panthor_vma(9), struct panthor_vm_op_ctx(9), struct panthor_vm_bind_job(9), alloc_pt(9), free_pt(9), panthor_vm_has_unhandled_faults(9), panthor_vm_is_unusable(9), panthor_vm_active(9), panthor_vm_idle(9), panthor_vm_as(9), panthor_vm_alloc_va(9), panthor_vm_free_va(9), panthor_vm_get_bo_for_va(9), panthor_vm_pool_create_vm(9), panthor_vm_pool_destroy_vm(9), panthor_vm_pool_get_vm(9), panthor_vm_pool_destroy(9), panthor_vm_pool_create(9), panthor_mmu_suspend(9), panthor_mmu_resume(9), panthor_mmu_pre_reset(9), panthor_mmu_post_reset(9), panthor_vm_put(9), panthor_vm_get(9), panthor_vm_get_heap_pool(9), panthor_vm_heaps_sizes(9), panthor_vm_resv(9), panthor_vm_bind_job_put(9), panthor_vm_create(9), panthor_vm_bind_job_create(9), panthor_vm_bind_job_prepare_resvs(9), panthor_vm_bind_job_update_resvs(9), panthor_vm_bind_exec_sync_op(9), panthor_vm_map_bo_range(9), panthor_vm_unmap_range(9), panthor_vm_prepare_mapped_bos_resvs(9), panthor_mmu_unplug(9), panthor_mmu_init(9), panthor_mmu_debugfs_init(9), panthor_mmu_pt_cache_init(9), panthor_mmu_pt_cache_fini(9).
made with π from ./drivers/gpu/drm/panthor Β· October 2026 Β· struct panthor_vm(9) β now go map something responsibly, bestie π«Ά
π¦ 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