drivers/gpu/drm/panthor/panthor_heap.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/panthor/panthor_heap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/panthor/panthor_heap.c- Extension
.c- Size
- 16383 bytes
- Lines
- 633
- 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.
- 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
linux/iosys-map.hlinux/rwsem.hdrm/drm_print.hdrm/panthor_drm.hpanthor_device.hpanthor_gem.hpanthor_gpu_regs.hpanthor_heap.hpanthor_mmu.h
Detected Declarations
struct panthor_heap_chunk_headerstruct panthor_heap_chunkstruct panthor_heapstruct panthor_heap_poolfunction panthor_heap_ctx_stridefunction panthor_get_heap_ctx_offsetfunction panthor_free_heap_chunkfunction panthor_alloc_heap_chunkfunction panthor_free_heap_chunksfunction panthor_alloc_heap_chunksfunction panthor_heap_destroy_lockedfunction panthor_heap_destroyfunction panthor_heap_createfunction panthor_heap_return_chunkfunction panthor_heap_growfunction memoryfunction panthor_heap_pool_releasefunction panthor_heap_pool_putfunction panthor_heap_pool_getfunction panthor_heap_pool_createfunction panthor_heap_pool_destroyfunction panthor_heap_pool_size
Annotated Snippet
struct panthor_heap_chunk_header {
/**
* @next: Next heap chunk in the list.
*
* This is a GPU VA.
*/
u64 next;
/** @unknown: MBZ. */
u32 unknown[14];
};
/**
* struct panthor_heap_chunk - Structure used to keep track of allocated heap chunks.
*/
struct panthor_heap_chunk {
/** @node: Used to insert the heap chunk in panthor_heap::chunks. */
struct list_head node;
/** @bo: Buffer object backing the heap chunk. */
struct panthor_kernel_bo *bo;
};
/**
* struct panthor_heap - Structure used to manage tiler heap contexts.
*/
struct panthor_heap {
/** @chunks: List containing all heap chunks allocated so far. */
struct list_head chunks;
/** @lock: Lock protecting insertion in the chunks list. */
struct mutex lock;
/** @chunk_size: Size of each chunk. */
u32 chunk_size;
/** @max_chunks: Maximum number of chunks. */
u32 max_chunks;
/**
* @target_in_flight: Number of in-flight render passes after which
* we'd let the FW wait for fragment job to finish instead of allocating new chunks.
*/
u32 target_in_flight;
/** @chunk_count: Number of heap chunks currently allocated. */
u32 chunk_count;
};
#define MAX_HEAPS_PER_POOL 128
/**
* struct panthor_heap_pool - Pool of heap contexts
*
* The pool is attached to a panthor_file and can't be shared across processes.
*/
struct panthor_heap_pool {
/** @refcount: Reference count. */
struct kref refcount;
/** @ptdev: Device. */
struct panthor_device *ptdev;
/** @vm: VM this pool is bound to. */
struct panthor_vm *vm;
/** @lock: Lock protecting access to @xa. */
struct rw_semaphore lock;
/** @xa: Array storing panthor_heap objects. */
struct xarray xa;
/** @gpu_contexts: Buffer object containing the GPU heap contexts. */
struct panthor_kernel_bo *gpu_contexts;
/** @size: Size of all chunks across all heaps in the pool. */
atomic_t size;
};
static int panthor_heap_ctx_stride(struct panthor_device *ptdev)
{
u32 l2_features = ptdev->gpu_info.l2_features;
u32 gpu_cache_line_size = GPU_L2_FEATURES_LINE_SIZE(l2_features);
return ALIGN(HEAP_CONTEXT_SIZE, gpu_cache_line_size);
}
static int panthor_get_heap_ctx_offset(struct panthor_heap_pool *pool, int id)
{
return panthor_heap_ctx_stride(pool->ptdev) * id;
Annotation
- Immediate include surface: `linux/iosys-map.h`, `linux/rwsem.h`, `drm/drm_print.h`, `drm/panthor_drm.h`, `panthor_device.h`, `panthor_gem.h`, `panthor_gpu_regs.h`, `panthor_heap.h`.
- Detected declarations: `struct panthor_heap_chunk_header`, `struct panthor_heap_chunk`, `struct panthor_heap`, `struct panthor_heap_pool`, `function panthor_heap_ctx_stride`, `function panthor_get_heap_ctx_offset`, `function panthor_free_heap_chunk`, `function panthor_alloc_heap_chunk`, `function panthor_free_heap_chunks`, `function panthor_alloc_heap_chunks`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- 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.