drivers/gpu/drm/panthor/panthor_mmu.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/panthor/panthor_mmu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/panthor/panthor_mmu.c- Extension
.c- Size
- 92596 bytes
- Lines
- 3357
- 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_debugfs.hdrm/drm_drv.hdrm/drm_exec.hdrm/drm_file.hdrm/drm_gpuvm.hdrm/drm_managed.hdrm/drm_print.hdrm/gpu_scheduler.hdrm/panthor_drm.hlinux/atomic.hlinux/bitfield.hlinux/delay.hlinux/dma-mapping.hlinux/interrupt.hlinux/io.hlinux/iopoll.hlinux/io-pgtable.hlinux/iommu.hlinux/kmemleak.hlinux/platform_device.hlinux/pm_runtime.hlinux/rwsem.hlinux/sched.hlinux/shmem_fs.hlinux/sizes.hpanthor_device.hpanthor_gem.hpanthor_gpu.hpanthor_gpu_regs.hpanthor_heap.hpanthor_mmu.hpanthor_mmu_regs.h
Detected Declarations
struct panthor_vmstruct panthor_as_slotstruct panthor_mmustruct panthor_vm_poolstruct panthor_vmastruct panthor_vm_op_ctxstruct panthor_vmstruct panthor_vm_bind_jobfunction alloc_ptfunction free_ptfunction wait_readyfunction as_send_cmd_and_waitfunction pack_region_rangefunction panthor_mmu_as_fault_maskfunction panthor_mmu_as_enablefunction panthor_mmu_as_disablefunction panthor_mmu_fault_maskfunction panthor_vm_has_unhandled_faultsfunction panthor_vm_is_unusablefunction panthor_vm_release_as_lockedfunction panthor_vm_activefunction panthor_vm_idlefunction panthor_vm_page_sizefunction panthor_vm_stopfunction panthor_vm_startfunction panthor_vm_asfunction get_pgsizefunction panthor_vm_declare_unusablefunction panthor_vm_unmap_pagesfunction panthor_vm_map_pagesfunction for_each_sgtable_dma_sgfunction flags_to_protfunction panthor_vm_alloc_vafunction panthor_vm_free_vafunction panthor_vm_bo_freefunction panthor_vm_cleanup_op_ctxfunction panthor_vm_op_ctx_return_vmafunction panthor_vm_op_ctx_get_vmafunction panthor_vm_op_ctx_prealloc_vmasfunction panthor_vm_init_op_ctxfunction panthor_vm_op_ctx_prealloc_ptsfunction panthor_vm_prepare_map_op_ctxfunction panthor_vm_prepare_unmap_op_ctxfunction panthor_vm_prepare_sync_only_op_ctxfunction panthor_vm_get_bo_for_vafunction panthor_vm_create_get_user_va_rangefunction panthor_vm_create_check_argsfunction panthor_vm_pool_create_vm
Annotated Snippet
struct panthor_as_slot {
/** @vm: VM bound to this slot. NULL is no VM is bound. */
struct panthor_vm *vm;
};
/**
* struct panthor_mmu - MMU related data
*/
struct panthor_mmu {
/** @iomem: CPU mapping of MMU_AS_CONTROL iomem region */
void __iomem *iomem;
/** @irq: The MMU irq. */
struct panthor_irq irq;
/**
* @as: Address space related fields.
*
* The GPU has a limited number of address spaces (AS) slots, forcing
* us to re-assign them to re-assign slots on-demand.
*/
struct {
/** @as.slots_lock: Lock protecting access to all other AS fields. */
struct mutex slots_lock;
/** @as.alloc_mask: Bitmask encoding the allocated slots. */
unsigned long alloc_mask;
/** @as.faulty_mask: Bitmask encoding the faulty slots. */
unsigned long faulty_mask;
/** @as.slots: VMs currently bound to the AS slots. */
struct panthor_as_slot slots[MAX_AS_SLOTS];
/**
* @as.lru_list: List of least recently used VMs.
*
* We use this list to pick a VM to evict when all slots are
* used.
*
* There should be no more active VMs than there are AS slots,
* so this LRU is just here to keep VMs bound until there's
* a need to release a slot, thus avoid unnecessary TLB/cache
* flushes.
*/
struct list_head lru_list;
} as;
/** @vm: VMs management fields */
struct {
/** @vm.lock: Lock protecting access to list. */
struct mutex lock;
/** @vm.list: List containing all VMs. */
struct list_head list;
/** @vm.reset_in_progress: True if a reset is in progress. */
bool reset_in_progress;
/** @vm.wq: Workqueue used for the VM_BIND queues. */
struct workqueue_struct *wq;
} vm;
};
/**
* struct panthor_vm_pool - VM pool object
*/
struct panthor_vm_pool {
/** @xa: Array used for VM handle tracking. */
struct xarray xa;
};
/**
* struct panthor_vma - GPU mapping object
*
* This is used to track GEM mappings in GPU space.
*/
struct panthor_vma {
/** @base: Inherits from drm_gpuva. */
struct drm_gpuva base;
/** @node: Used to implement deferred release of VMAs. */
struct list_head node;
/**
* @flags: Combination of drm_panthor_vm_bind_op_flags.
*
* Only map related flags are accepted.
*/
u32 flags;
Annotation
- Immediate include surface: `drm/drm_debugfs.h`, `drm/drm_drv.h`, `drm/drm_exec.h`, `drm/drm_file.h`, `drm/drm_gpuvm.h`, `drm/drm_managed.h`, `drm/drm_print.h`, `drm/gpu_scheduler.h`.
- Detected declarations: `struct panthor_vm`, `struct panthor_as_slot`, `struct panthor_mmu`, `struct panthor_vm_pool`, `struct panthor_vma`, `struct panthor_vm_op_ctx`, `struct panthor_vm`, `struct panthor_vm_bind_job`, `function alloc_pt`, `function free_pt`.
- 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.