STRUCT PANTHOR_DEVICE(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌈 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 base drm_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 the iomem region. the real-world address, not the vibes-based one πŸ’«
  • iomem β€” the CPU mapping of the IOMEM region. 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, and coregroup ⏰
  • coherent β€” true if 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 when CONFIG_DEBUG_FS is on, bestie β€” it's inside the #ifdef πŸŽ€)

πŸ”Œ unplug, reset, pm, and the rest πŸ”Œ

  • unplug β€” device unplug related fields. holds a lock (a mutex) and done (a completion), so everyone knows when the unplug saga is over 🫢
  • reset β€” reset related fields. has a workqueue wq, a work item, a pending atomic, and a fast bool. reset business, very serious, do not disturb πŸ™ˆ
  • pm β€” power management related data. power management said "I contain multitudes": state, mmio_lock, dummy_latest_flush, and recovery_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_FS moment ✨)
  • gems.lock β€” protects the device-wide list of GEM objects. the bodyguard of the list πŸ’ͺ

πŸ‘€ SEE ALSO πŸ‘€

go read these next, iykyk:


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