drivers/gpu/drm/panthor/panthor_gem.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/panthor/panthor_gem.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/panthor/panthor_gem.c- Extension
.c- Size
- 46559 bytes
- Lines
- 1746
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/cleanup.hlinux/debugfs.hlinux/dma-buf.hlinux/dma-mapping.hlinux/err.hlinux/slab.hlinux/vmalloc.hdrm/drm_debugfs.hdrm/drm_file.hdrm/drm_gpuvm.hdrm/drm_managed.hdrm/drm_prime.hdrm/drm_print.hdrm/panthor_drm.hpanthor_device.hpanthor_drv.hpanthor_fw.hpanthor_gem.hpanthor_mmu.h
Detected Declarations
struct gem_size_totalsfunction panthor_gem_initfunction panthor_gem_debugfs_bo_initfunction panthor_gem_debugfs_bo_addfunction panthor_gem_debugfs_bo_rmfunction panthor_gem_debugfs_set_usage_flagsfunction panthor_gem_debugfs_bo_rmfunction is_gpu_mappedfunction drm_gem_for_each_gpuvm_bofunction panthor_gem_evaluate_reclaim_state_lockedfunction panthor_gem_update_reclaim_state_lockedfunction bo_assert_locked_or_gonefunction panthor_gem_backing_cleanup_lockedfunction panthor_gem_backing_get_pages_lockedfunction panthor_gem_backing_pin_lockedfunction panthor_gem_backing_unpin_lockedfunction panthor_gem_dev_map_cleanup_lockedfunction panthor_gem_dev_map_get_sgt_lockedfunction panthor_gem_get_dev_sgtfunction panthor_gem_vmap_cleanup_lockedfunction panthor_gem_prep_for_cpu_map_lockedfunction panthor_gem_vmap_get_lockedfunction panthor_gem_vmap_put_lockedfunction panthor_gem_free_objectfunction panthor_gem_prime_map_dma_buffunction panthor_gem_prime_unmap_dma_buffunction panthor_gem_prime_begin_cpu_accessfunction list_for_each_entryfunction panthor_gem_prime_end_cpu_accessfunction panthor_gem_prime_exportfunction panthor_gem_prime_importfunction panthor_gem_print_infofunction panthor_gem_pin_lockedfunction panthor_gem_unpin_lockedfunction panthor_gem_pinfunction panthor_gem_unpinfunction panthor_gem_swapin_lockedfunction panthor_gem_evict_lockedfunction panthor_gem_vmap_lockedfunction panthor_gem_vunmap_lockedfunction panthor_gem_mmapfunction panthor_gem_statusfunction insert_pagefunction nonblocking_page_setupfunction blocking_page_setupfunction panthor_gem_any_faultfunction panthor_gem_faultfunction panthor_gem_vm_open
Annotated Snippet
struct gem_size_totals {
size_t size;
size_t resident;
size_t reclaimable;
};
static void panthor_gem_debugfs_print_flag_names(struct seq_file *m)
{
int len;
int i;
static const char * const gem_state_flags_names[] = {
[PANTHOR_DEBUGFS_GEM_STATE_IMPORTED_BIT] = "imported",
[PANTHOR_DEBUGFS_GEM_STATE_EXPORTED_BIT] = "exported",
[PANTHOR_DEBUGFS_GEM_STATE_EVICTED_BIT] = "evicted",
};
static const char * const gem_usage_flags_names[] = {
[PANTHOR_DEBUGFS_GEM_USAGE_KERNEL_BIT] = "kernel",
[PANTHOR_DEBUGFS_GEM_USAGE_FW_MAPPED_BIT] = "fw-mapped",
};
seq_puts(m, "GEM state flags: ");
for (i = 0, len = ARRAY_SIZE(gem_state_flags_names); i < len; i++) {
if (!gem_state_flags_names[i])
continue;
seq_printf(m, "%s (0x%x)%s", gem_state_flags_names[i],
(u32)BIT(i), (i < len - 1) ? ", " : "\n");
}
seq_puts(m, "GEM usage flags: ");
for (i = 0, len = ARRAY_SIZE(gem_usage_flags_names); i < len; i++) {
if (!gem_usage_flags_names[i])
continue;
seq_printf(m, "%s (0x%x)%s", gem_usage_flags_names[i],
(u32)BIT(i), (i < len - 1) ? ", " : "\n\n");
}
}
static void panthor_gem_debugfs_bo_print(struct panthor_gem_object *bo,
struct seq_file *m,
struct gem_size_totals *totals)
{
enum panthor_gem_reclaim_state reclaim_state = bo->reclaim_state;
unsigned int refcount = kref_read(&bo->base.refcount);
int reclaimed_count = atomic_read(&bo->reclaimed_count);
char creator_info[32] = {};
size_t resident_size;
u32 gem_usage_flags = bo->debugfs.flags;
u32 gem_state_flags = 0;
/* Skip BOs being destroyed. */
if (!refcount)
return;
resident_size = bo->backing.pages ? bo->base.size : 0;
snprintf(creator_info, sizeof(creator_info),
"%s/%d", bo->debugfs.creator.process_name, bo->debugfs.creator.tgid);
seq_printf(m, "%-32s%-16d%-11d%-11d%-16zd%-16zd0x%-16lx",
creator_info,
bo->base.name,
refcount,
reclaimed_count,
bo->base.size,
resident_size,
drm_vma_node_start(&bo->base.vma_node));
if (drm_gem_is_imported(&bo->base))
gem_state_flags |= PANTHOR_DEBUGFS_GEM_STATE_FLAG_IMPORTED;
else if (!resident_size && reclaimed_count)
gem_state_flags |= PANTHOR_DEBUGFS_GEM_STATE_FLAG_EVICTED;
if (bo->base.dma_buf)
gem_state_flags |= PANTHOR_DEBUGFS_GEM_STATE_FLAG_EXPORTED;
seq_printf(m, "0x%-8x 0x%-10x", gem_state_flags, gem_usage_flags);
scoped_guard(mutex, &bo->label.lock) {
seq_printf(m, "%s\n", bo->label.str ? : "");
}
totals->size += bo->base.size;
totals->resident += resident_size;
if (reclaim_state != PANTHOR_GEM_UNRECLAIMABLE)
totals->reclaimable += resident_size;
}
static void panthor_gem_debugfs_print_bos(struct panthor_device *ptdev,
struct seq_file *m)
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/debugfs.h`, `linux/dma-buf.h`, `linux/dma-mapping.h`, `linux/err.h`, `linux/slab.h`, `linux/vmalloc.h`, `drm/drm_debugfs.h`.
- Detected declarations: `struct gem_size_totals`, `function panthor_gem_init`, `function panthor_gem_debugfs_bo_init`, `function panthor_gem_debugfs_bo_add`, `function panthor_gem_debugfs_bo_rm`, `function panthor_gem_debugfs_set_usage_flags`, `function panthor_gem_debugfs_bo_rm`, `function is_gpu_mapped`, `function drm_gem_for_each_gpuvm_bo`, `function panthor_gem_evaluate_reclaim_state_locked`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.