STRUCT PANTHOR_SCHEDULER(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct panthor_scheduler(9) β€” like, the whole scheduler object, bestie

okay so this is a page from the Kernel API Manual, and it's literally about struct panthor_scheduler β€” the object that manages the scheduler for panthor. It's giving "kernel internals but make it cute" ✨ ngl this struct is a whole main character with so many fields, so grab a πŸ“ and let's go.


✨ NAME ✨

struct panthor_scheduler β€” the object used to manage the scheduler πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

struct panthor_scheduler {
    struct panthor_device *ptdev;
    struct workqueue_struct *wq;
    struct workqueue_struct *heap_alloc_wq;
    struct delayed_work tick_work;
    struct work_struct sync_upd_work;
    struct work_struct fw_events_work;
    atomic_t fw_events;
    u64 resched_target;
    u64 last_tick;
    u64 tick_period;
    struct mutex lock;
    struct {
      struct list_head runnable[PANTHOR_CSG_PRIORITY_COUNT];
      struct list_head idle[PANTHOR_CSG_PRIORITY_COUNT];
      struct list_head waiting;
    } groups;
    struct panthor_csg_slot csg_slots[MAX_CSGS];
    u32 csg_slot_count;
    u32 cs_slot_count;
    u32 as_slot_count;
    u32 used_csg_slot_count;
    u32 sb_slot_count;
    bool might_have_idle_groups;
    struct {
      bool has_ref;
    } pm;
    struct {
      struct mutex lock;
      atomic_t in_progress;
      struct list_head stopped_groups;
    } reset;
  };

πŸ’– MEMBERS πŸ’–

here's the tour of every single field, no skips, no cap πŸ’œ

  • ptdev β€” the device, obviously 🫢
  • wq β€” the workqueue used by our internal scheduler logic and by drm_gpu_scheduler.

It's for the scheduler tick, group updates, and other kinds of FW event processing that can't be handled in the threaded interrupt path. It also gets passed to the drm_gpu_scheduler instances embedded in panthor_queue. iconic ✨

  • heap_alloc_wq β€” the workqueue used to schedule tiler_oom works.

We literally have a whole dedicated queue just for heap chunk allocation works, so that we don't block the rest of the scheduler when an allocation tries to reclaim memory. considerate queen behavior πŸ‘‘

  • tick_work β€” the work that gets executed on a scheduling tick. ⏰
  • sync_upd_work β€” the work used to process synchronization object updates.

We use this work to unblock queues/groups that were waiting on a synchronization object. πŸŽ€

  • fw_events_work β€” the work used to process FW events outside the interrupt path.

Even though the interrupt is threaded, any event processing that needs to take panthor_scheduler::lock has to be processed outside the interrupt path, so we don't block the tick logic when it calls panthor_fw_{csg,wait}_wait_acks. And since most of the event processing requires taking this lock, we just delegate all FW event processing to the scheduler workqueue. delegation slay πŸ’…

  • fw_events β€” a bitmask encoding pending FW events. πŸ”₯
  • resched_target β€” when the next tick should occur.

Expressed in jiffies. ⏱️

  • last_tick β€” when the last tick occurred.

Expressed in jiffies. fr fr

  • tick_period β€” the tick period, in jiffies.
  • lock β€” the lock protecting access to all the scheduler fields.

It should be taken in the tick work, in the irq handler, and anywhere the groups fields are touched. protect her at all costs 😭

  • groups β€” the various lists used to classify groups.
  • groups.runnable β€” the runnable group lists.

When a group has queues that want to execute something, its panthor_group::run_node should be inserted here.

There's one list per-priority. 🌈

  • groups.idle β€” the idle group lists.

When all queues of a group are idle (either because they have nothing to execute, or because they're blocked), the panthor_group::run_node field should be inserted here.

One list per-priority, again. πŸ’€

  • groups.waiting β€” the list of groups whose queues are blocked on a synchronization object.

Insert panthor_group::wait_node here when a group is waiting for synchronization objects to be signaled.

This list gets evaluated in the sync_upd_work work. πŸ¦‹

  • csg_slots β€” FW command stream group slots.
  • csg_slot_count β€” the number of command stream group slots exposed by the FW.
  • cs_slot_count β€” the number of command stream slots per group slot exposed by the FW.
  • as_slot_count β€” the number of address space slots supported by the MMU.
  • used_csg_slot_count β€” the number of command stream group slots currently used. 🎯
  • sb_slot_count β€” the number of scoreboard slots.
  • might_have_idle_groups β€” true if an active group might have become idle.

This will force a tick, so other runnable groups can be scheduled if one or more active groups became idle. highkey important πŸ’€

  • pm β€” power management related fields.
  • pm.has_ref β€” true if the scheduler owns a runtime PM reference. πŸ”Œ
  • reset β€” reset related fields.
  • reset.lock β€” the lock protecting the other reset fields.
  • reset.in_progress β€” true if a reset is in progress.

It gets set to true in panthor_sched_pre_reset and back to false in panthor_sched_post_reset. 🧚

  • reset.stopped_groups β€” the list containing all groups that were stopped before a reset.

Insert panthor_group::run_node in the pre_reset path. 🌸


πŸ‘€ SEE ALSO πŸ‘€

okay bestie, here's the whole friend group β€” go read these too, iykyk:

Kernel file ./drivers/gpu/drm/panthor/panthor_sched.c Scheduler(9), struct panthor_csg_slot(9), enum panthor_csg_priority(9), struct panthor_syncobj_32b(9), struct panthor_syncobj_64b(9), struct panthor_queue(9), enum panthor_group_state(9), struct panthor_group(9), group_queue_work(9), sched_queue_work(9), sched_queue_delayed_work(9), struct panthor_group_pool(9), struct panthor_job(9), group_bind_locked(9), group_unbind_locked(9), cs_slot_prog_locked(9), cs_slot_reset_locked(9), csg_slot_sync_priority_locked(9), cs_slot_sync_queue_state_locked(9), sched_process_global_irq_locked(9), panthor_sched_report_fw_events(9), panthor_sched_report_mmu_fault(9), panthor_fdinfo_gather_group_mem_info(9)


and that's the whole page, periodt πŸ’…βœ¨ this gem lives over in ./drivers/gpu/drm/panthor, dated October 2026 β€” thanks for reading my little kernel group chat, love u, bye πŸ«ΆπŸ’–πŸŽ€

πŸ“¦ where this page comes from