STRUCT PANTHOR_DEVICE(9)
π struct panthor_device(9) π
okay bestie, welcome to the Kernel API Manual entry for struct panthor_device β aka the big main-character struct of the Panthor DRM driver π
. This is the whole device, like the entire vibe of your GPU in one giant C struct. Grab a strawberry drink, we're going in π
β¨ NAME β¨
struct panthor_device β Panthor device. Yes that's it. That's the name. Iconic, minimal, ate π
π¦ SYNOPSIS π¦
struct panthor_device {
struct drm_device base;
const struct panthor_soc_data *soc_data;
phys_addr_t phys_addr;
void __iomem *iomem;
struct {
struct clk *core;
struct clk *stacks;
struct clk *coregroup;
} clks;
bool coherent;
struct drm_panthor_gpu_info gpu_info;
struct drm_panthor_csif_info csif_info;
struct drm_panthor_mmu_info mmu_info;
struct panthor_hw *hw;
struct panthor_pwr *pwr;
struct panthor_gpu *gpu;
struct panthor_fw *fw;
struct panthor_mmu *mmu;
struct panthor_scheduler *scheduler;
struct panthor_devfreq *devfreq;
struct {
struct shrinker *shrinker;
struct drm_gem_lru unused;
struct drm_gem_lru mmapped;
struct drm_gem_lru gpu_mapped_shared;
struct list_head vms;
long gpu_mapped_count;
atomic_t retry_count;
#ifdef CONFIG_DEBUG_FS;
unsigned long nr_pages_reclaimed_on_last_scan;
#endif;
} reclaim;
struct {
struct mutex lock;
struct completion done;
} unplug;
struct {
struct workqueue_struct *wq;
struct work_struct work;
atomic_t pending;
bool fast;
} reset;
struct {
atomic_t state;
struct mutex mmio_lock;
struct page *dummy_latest_flush;
atomic_t recovery_needed;
} pm;
u32 profile_mask;
unsigned long fast_rate;
#ifdef CONFIG_DEBUG_FS;
struct {
struct mutex lock;
struct list_head node;
} gems;
#endif;
};
likeβ¦ look at her. so many fields. so much going on. she's literally the whole device in a trench coat π§
π Members π
okay so here's the field-by-field breakdown, no skipping, we're doing ALL of them because that's the assignment bestie π«Ά
baseβ the basedrm_device. the foundation, the roots, the DRM-ness of it all β¨soc_dataβ optional SoC data. optional meaning it might be NULL, don't come for her πphys_addrβ the physical address of theiomemregion. the real-world address, not the vibes-based one π«iomemβ the CPU mapping of theIOMEMregion. so the CPU can actually peek at GPU registers πclksβ the GPU clocks. and yes, there are three of them tucked in there:core,stacks, andcoregroupβ°coherentβtrueif the CPU and GPU are memory coherent.true= they share a brain cell,false= they don't π§gpu_infoβ GPU information. the lore πcsif_infoβ command stream interface information. the command stream's whole backstory π¬mmu_infoβ MMU info. (not even the manpage put a period on that one, so neither will I π)hwβ GPU-specific data. every GPU's got its own little quirks, this is where they live πpwrβ power control management data. wattage business β‘gpuβ GPU management data π₯fwβ FW management data. firmware, not friend-with-benefits, keep up πmmuβ MMU management data. memory management unit doing memory management unit things ποΈschedulerβ scheduler management data. she decides whose turn it is πdevfreqβ device frequency scaling management data. the frequency-scaling corner of the struct πreclaimβ reclaim related stuff. this whole little sub-struct is the memory-reclaiming department, and bestie it is dramatic, so let's meet everyone πΈ
π§Ί reclaim β the reclaim department π§Ί
reclaim.shrinkerβ the shrinker instance. yes it's called a shrinker. no it's not about your therapist's advice, it's about reclaiming pages πreclaim.unusedβ BOs with unused pages.
basically ALL buffers that got mmapped, vmapped or GPU mapped and then unmapped. there should be no contention on these buffers, which makes them ideal to reclaim. lowkey the easiest win in the whole struct β
reclaim.mmappedβmmap-ed buffers.
those are relatively easy to reclaim since we don't need user agreement β we can simply teardown the mapping and let it fault on the next access. no permission slip needed, we just do it π¦
reclaim.gpu_mapped_sharedβ shared BO LRU list.
that's the most tricky BO type to reclaim, because it involves tearing down all mappings in all VMs where this BO is mapped, which increases the risk of contention and thus decreases the likeliness of success. highkey stressful fr fr π
reclaim.vmsβ VM LRU list.
VMs that have reclaimable BOs only mapped to a single VM are placed in this LRU. reclaiming such BOs implies waiting for VM idleness (no in-flight GPU jobs targeting this VM), meaning we can't reclaim those if we're in a context where we can't block/sleep. so likeβ¦ sometimes we just can't, and that's a whole thing π΄
reclaim.gpu_mapped_countβ global counter of pages that are GPU mapped.
this lets us get the number of reclaimable pages without walking the vms and gpu_mapped_shared LRUs. shortcut queen, we love her π
reclaim.retry_countβ number of times we ran the shrinker without being able to reclaim stuff.
used to stop scanning GEMs when too many attempts were made without progress. she's the "okay we tried, we're done here" counter π
reclaim.nr_pages_reclaimed_on_last_scanβ number of pages reclaimed on the last shrinker scan. (this one's only hanging out here whenCONFIG_DEBUG_FSis on, bestie β it's inside the#ifdefπ)
π unplug, reset, pm, and the rest π
unplugβ device unplug related fields. holds alock(amutex) anddone(acompletion), so everyone knows when the unplug saga is over π«Άresetβ reset related fields. has a workqueuewq, aworkitem, apendingatomic, and afastbool. reset business, very serious, do not disturb πpmβ power management related data. power management said "I contain multitudes":state,mmio_lock,dummy_latest_flush, andrecovery_neededπprofile_maskβ user-set profiling flags for job accounting. user-set, so like, that's on them π―fast_rateβ maximum device clock frequency. set by DVFS. the speed limit, basically ποΈgemsβ device-wide list of GEM objects owned by at least one file. (debug-fs-only field,CONFIG_DEBUG_FSmoment β¨)gems.lockβ protects the device-wide list of GEM objects. the bodyguard of the list πͺ
π SEE ALSO π
go read these next, iykyk:
- Kernel file
./drivers/gpu/drm/panthor/panthor_device.hstruct panthor_soc_data(9) enum panthor_device_pm_state(9)struct panthor_irq(9)struct panthor_file(9)panthor_device_schedule_reset(9)panthor_device_reset_is_pending(9)panthor_exception_is_fault(9)PANTHOR_IRQ_HANDLER(9)
okay that's the whole page, you made it, I'm so proud of you π₯Ήπ this came from ./drivers/gpu/drm/panthor and it's dated October 2026 β so yeah, notes from the future, periodt. mwah, go read a real manpage now 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