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.

Dependency Surface

Detected Declarations

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

Implementation Notes