The scheduler decides which context runs on which data master (DM), and when. It is driven by interrupts (see execution-environment): the BG task re-evaluates what is blocked, and the IRQ task reacts to completions and reschedules.
A data master is a GPU work unit with its own queue. DM indices are the public
PVR_FWIF_DM_* values (fwcommoncontext.dm):
| DM | PVR_FWIF_DM_* |
Unit |
|---|---|---|
| 0 | GP |
general purpose |
| 1 | TDM |
transfer (TDM) |
| 2 | GEOM |
geometry (TA) |
| 3 | FRAG |
fragment (3D), also transfer through 3D |
| 4 | CDM |
compute |
| 6 | GEOM2 |
second geometry (multicore only; not used on this single-core SoC) |
The internal organisation is free. The behaviour requires, per DM:
priority;run_node and waiting_node of
rogue_fwif_fwcommoncontext (see data-structures). Lists of
different DMs are independent: each DM has its own;And globally:
Triggered by completion (IRQ task) or re-evaluation (BG task):
for each DM, in visiting order, if pending or deferred:
if the DM already runs a context and nothing of higher priority waits: skip
if the DM is held (lockup / freelist / power): log and skip
take the context at the top of the run list
resolve the remaining dependencies (fences); if ready:
if the inter-DM overlap rules block it: defer
if a higher-priority context waits behind the running one:
request a context store of the running one (preemption) and defer
else: record the DM's execution state and dispatch
(see client-ccb → "Dispatching a task")
When a higher-priority context waits behind a lower-priority one running on a DM, the firmware asks the running context to save its state and yields the DM:
Preemption only happens on DMs where the OS config flags enable context switching
(ROGUE_FWIF_INICFG_OS_CTXSWITCH_{FRAG,CDM,GEOM,TDM}_EN). With the flags at 0 there is no
context switch. Observed sequences in observed-sequences.
Black-box observation of the open v1.1 image on the board.
GEOM_EN | FRAG_EN | CDM_EN set in
rogue_fwif_osdata.fw_os_config_flags.vkfwtest pre-3d, pre-ta,
pre-cdm).fw_com_ctx_flags.When the firmware decides to store. When a context of higher priority becomes ready on a
DM that is running a lower-priority context. Trace CSW id 38: Higher priority context
scheduled for DM <n>. Prios (OSid, OSid Prio, Context Prio): Current: 0, 0, 0 New: 0, 0, 1.
Hard Context Switching: 0. In all three runs the decision came from priority. No store
was triggered by a deadline or by the host.
Fragment (DM 3): stored and resumed (10 times in pre-3d).
"Higher priority context scheduled for DM 3 …"
"*** 3D context store start"
"*** 3D context store complete" ~7 k timer ticks later, together with the 3D
completion event ("3D finished, HWRTData0State=3")
"3D FWCtx <ctx> needs resume" fw_com_ctx_flags of the stored context = 0x1
(ROGUE_FWIF_CONTEXT_FLAGS_NEED_RESUME)
… the higher-priority 3D runs …
"*** 3D FWCtx <ctx> resume"
"Kick 3D: FWCtx <ctx> @ <same cCCB offset>, … CSW resume:1"
CSW resume:1, after its PM context 1 state is reloaded
(“Loading stack-pointers … on context 1”, “3D RTData … ready on HW context 1”).context_state_addr stayed the same across all
the stores.Geometry (DM 2): the store completes only when the TA finishes (pre-ta).
"Higher priority context scheduled for DM 2 …"
"*** TA context store start"
"TA finished" ~170 ms later
"*** TA context store complete"
… higher-priority geometry runs; the stored context's fragment then runs normally
(CSW resume:0) …
No geometry resume (CSW resume:1 on a TA kick) was observed. The geometry is not
interrupted mid-way: the store request is satisfied at the end of the TA.
Compute (DM 4): the store faults on this stack (pre-cdm).
"Higher priority context scheduled for DM 4 …"
"*** CDM FWCtx store start"
"MMU fault event: 0x00000200"
"BIF0 page fault detected (Core 0 MMU Status: 0x…1041 Req Status: 0x…1000000000d0)"
"GPU-0 has locked up" → HWR
"Analysis DM4: Lockup FWCtx: <low-priority ctx>. Need to skip to next command"
"Recovery DM4: FWCtx … skipped to command @ …" (the stored compute command is discarded)
"Kick Compute: <high-priority ctx> …" (runs and finishes)
0xd0) and an HWR. The preempted command is discarded, not
resumed.Register side of the 3D store and resume (answers Q16m item 4, O). A vkfwtest pre-3d
run was made with fragment context switching on (ctx_switch=0x4). There were 40
store/resume trace events and no recovery. The registers were sampled every ~10 µs:
0x1000) was never
seen non-zero (a pulse shorter than a sample). The stored render ends with
PIXELBE_END_RENDER like a normal one.PM_CAT_BASE_*1, and its region headers in 0x0F20.ROGUE_CR_ISP_RENDER (0x0F08) gets bit 4 (0x10) and
0x1020 takes a new value (0x25003, 0x2E007, 0x3900A, 0x3C02B, … across
successive resumes). This matches the resume path of
kick-compute-and-3d phase F: the per-core saved state into
0x1020, then ISP_RENDER |= 0x10.0x0F08 returns to 0 at the next fragment load.0x0298 and 0x01C8 read 0 throughout.3D context store and resume register protocol (answers Q40, D):
PIXELBE_END_RENDER:
PIXELBE_END_RENDER fires and a store had been requested (BCAST[0x1000] = 1,
only issued while (CR[ROGUE_CR_ISP_RENDER] & 3) != 3 and not in PR running), clear
the store-requested flag and clear the low byte of fw_com_ctx_flags (&= ~0xFF).CR[0x0130] (EVENT_STATUS) and CR[0x1038] (ISP context-switch status)
for each core c (c = 0 on single-core BXE-2-32):
(CR[0x0130] & 0x8) != 0 AND (CR[0x1038] & 1) == 0.(CR[0x1038] & 1) == 1:
zero frag_ctx_state.frag_reg_pm_deallocated_mask_status (+0x00) and
frag_reg_dm_pds_mtilefree_status (+0x04), and proceed with normal completion.rogue_fwif_frag_ctx_state on store:
1 entry on single-core BXE-2-32):
frag_ctx_state.frag_reg_isp_store[c] (+0x0C + 4*c) = CR[0x1008 + c * 0x80000]
(CR[0x1008] on BXE-2-32).CR[0x03F8] until (val & 0xC2) == 0xC2 (PM 3D store idle handshake; on
timeout, clear BCAST[EVENT_CLEAR] = 0x4108 and flush).frag_ctx_state.frag_reg_pm_deallocated_mask_status (+0x00) = CR[0x0360].frag_ctx_state.frag_reg_dm_pds_mtilefree_status (+0x04) = CR[0x0370].fw_com_ctx_flags |= stored_core_mask (bit 0 = NEED_RESUME on BXE-2-32) and
emit trace CSW_7 ("3D FWCtx 0x%08.8x needs resume").BCAST[0x03D8], CR[0x03E0], CR[0x01C0],
and before BCAST[0x0F00] = 1):
(fw_com_ctx_flags & 0xFF) == 0): write CR[0x0298] = 0 and
CR[0x01C8] = 0.(fw_com_ctx_flags & 0xFF) != 0):
fw_com_ctx_flags: write
CR[0x1020 + c * 0x80000] = frag_ctx_state.frag_reg_isp_store[c] (single register
CR[0x1020] on BXE-2-32);BCAST[ROGUE_CR_ISP_RENDER] = CR[ROGUE_CR_ISP_RENDER] | 0x10 (bit 4 = resume);CR[0x0298] = frag_ctx_state.frag_reg_pm_deallocated_mask_status (+0x00);CR[0x01C8] = frag_ctx_state.frag_reg_dm_pds_mtilefree_status (+0x04).fw_com_ctx_flags & 0xFF is cleared at the next 3D finished (before checking whether a
new store happened) or immediately after BCAST[0x0F00] = 1.PM_3D_MEM_FREE (0x0130 & 0x100), PM 3D timeout disable/restore,
RTA layer advance/re-kick, command retire (read_offset remains on the same FRAG
command so it is resumed later), and UFO updates.hwrtdata.state (+0xAC): transitions 4 (FINALRENDER) → 6 (3DCONTEXTSTORED,
not 3), followed by the 3-step PM-MMU invalidation (SLC 0x10, BIF_CTRL_INVAL 4,
0x1348) unless on a non-last RTA layer;BCAST[EVENT_CLEAR] = 0x8 (or 0x4008 if ZLS store);TA (geometry / DM 2) context store and resume register protocol (answers Q43, D):
(dm_queue[2].flags & 1) != 0 and no store is already pending.
All base addresses and task descriptors come from the render context’s
static_render_context_state.ctxswitch_regs[0] (struct rogue_fwif_geom_registers_caswitch
at render context +0x130 for DM 2; +0x1E8 for secondary DM 6), indexed by
buf = geom_ctx_state.using_buffer (u16 at +0x20, 0 = A, 1 = B):
CR[0x0428/0x042C] (64-bit) = geom_reg_vdm_context_state_base_addr (+0);CR[0x0CC0/0x0CC4] (64-bit) = geom_reg_ta_context_state_base_addr (+16);CR[0x0438/0x043C] (64-bit) = geom_state[buf].geom_reg_vdm_context_store_task0 (+24);CR[0x0440] (32-bit, low word) = geom_state[buf].geom_reg_vdm_context_store_task1 (+32);CR[0x0448/0x044C] (64-bit) = geom_state[buf].geom_reg_vdm_context_store_task2 (+40);CR[0x0450/0x0454] (64-bit) = geom_state[buf].geom_reg_vdm_context_resume_task0 (+48),
with its low 32 bits OR’d with cmd_geom.regs.vdm_context_resume_task0_size (at
cmd_geom +0x38, or +0x60 from the 40-byte cCCB command header);CR[0x0458] (32-bit, low word) = geom_state[buf].geom_reg_vdm_context_resume_task1 (+56);CR[0x0460/0x0464] (64-bit) = geom_state[buf].geom_reg_vdm_context_resume_task2 (+64);geom_reg_vdm_context_store_task3..4 and resume_task3..4 are not written on
BXE-2-32 — they are only used when VDM_OBJECT_LEVEL_LLS is present.)CR[0x0468] = 1 (VDM_CONTEXT_STORE_START).TA_FINISHED (EVENT_STATUS bit 5, 0x20) — the
same event as a normal TA completion (not TA_TERMINATE / OOM). When TA_FINISHED arrives
with a store pending:
CR[0x0430] (VDM_CONTEXT_STORE_STATUS)
until (val & 1) == 1.(CR[0x0430] & 2) != 0 (bit 1 = NEED_RESUME):
0 (store request arrived too late, TA finished normally): clear
hwrtdata.flags &= ~0x400 and continue normal TA completion;1 (stored): save CR[0x0418/0x041C] (64-bit VDM resume pointer) into
geom_ctx_state.vdm_context_resume_addr (+0x00/+0x04), set
hwrtdata.flags |= 0x400, still run VHeap store (CR[0x0260] = 1), TPC flush
(CR[0x0C50] = 0x40000000), RTC flush (CR[0x0CB8] = 2), and DM 2 cache flush, and
do not retire the GEOM command.hwrtdata.flags & 0x400 is set):
BCAST[0x0408/0x040C] = ctxswitch_regs[0].geom_reg_vdm_context_state_base_addr
(instead of cmd_geom.regs.vdm_ctrl_stream_base);geom_ctx_state.using_buffer ^= 1 (1 - cur);CR[0x0418/0x041C] = geom_ctx_state.vdm_context_resume_addr;CR[0x0400] = 1).CDM (compute / DM 4) context store and resume register protocol (D):
(dm_queue[4].flags & 1) != 0 and no store is already pending:
write BCAST[0x0488] = 1 (CDM_CONTEXT_STORE_START).COMPUTE_FINISHED when store was requested):
BCAST[EVENT_CLEAR] = 4, clear the store-requested flag, and poll CR[0x04A0]
(CDM_CONTEXT_STORE_STATUS) until (val & 1) == 1.c = 0 on BXE-2-32): if (CR[0x04A0 + c * 0x80000] & 2) != 0,
set stored_core_mask |= (1 << c).stored_core_mask == 0 (finished normally): clear fw_com_ctx_flags &= ~0xFF, flush
DM 4 caches, and retire the command normally.stored_core_mask != 0 (stored): set
fw_com_ctx_flags = (fw_com_ctx_flags & ~0xFF) | stored_core_mask, flush DM 4 caches,
do not retire the CDM command, release DM 4, schedule the next context, and
deactivate the BIF memory context.(fw_com_ctx_flags & 0xFF) != 0):
BCAST[0x0480/0x0484], BCAST[0x17A8/0x17AC],
BCAST[0x0498/0x049C]).0) or B (1) from the context-state buffer flag (& 1), and for each
core c with bit c set in fw_com_ctx_flags (c = 0 on BXE-2-32):
CR[0x04D8/0x04DC + c * 0x80000] = selected A/B resume state buffer address;CR[0x04E0 + c * 0x80000] = cmd_cdm.cdm_resume_pds1 (cmd + 0x64).BIF_CTRL_INVAL = 0x1C).BCAST[0x0478] = 1): write CR[0x0490 + c * 0x80000] = 1
(CDM_CONTEXT_RESUME_START, CR[0x0490] = 1 on BXE-2-32).Before starting a context on a DM, the firmware checks whether it may run now:
ROGUE_FWIF_INICFG_DISABLE_DM_OVERLAP) and
another DM is running;O) — vkfwtest stress (4 concurrent devices) on manufacturer firmware:
with the updated Mesa (pvr-bxe-2-32, with VK_SUBPASS_EXTERNAL barriers) +
kernel powervr 1.1.0 + manufacturer open firmware v1.1 (build 6976702 OS),
vkfwtest -k stress passes 10/10 consecutive runs (1572–1809 ms, and 14/14
total including the full battery and repeatability runs) with zero dmesg lockups,
overruns, or page faults. Earlier manufacturer-FW stress failures occurred with pre-fix
Mesa builds lacking VK_SUBPASS_EXTERNAL barriers.D): when concurrent contexts have equal priority (as in vkfwtest
stress), preemption / context-switch requests are not issued; preemption is only
requested when a strictly higher-priority context arrives (new_prio > running_prio).D): DM 2 (TA) and DM 3 (3D)
do overlap across different contexts, so when loading HWRTData into PM context C
(0 = TA, 1 = 3D) while the opposite PM context O (1 or 0) is running on another
DM, the PM load must synchronise shared vs. separate freelists:
HWRTData handoff: if DM 3 (C = 1) loads an HWRTData still tracked in PM
context 0, save PM context 0’s catalogues and clear its tracked slot (when not in SPM).CR[0x02A0] / CR[0x02A8]): for each
freelist slot i ∈ {0 (local), 1 (global)}, compare new_fl = hwrtdata.freelists[i],
cur_fl = pm_fl[C][i], and other_fl = pm_fl[O][i]. If cur_fl != new_fl:
cur_fl != NULL && cur_fl == other_fl: pause O before touching PM registers, and
do not store cur_fl from C (since O actively owns it);cur_fl != NULL: store cur_fl from C;other_fl == new_fl: pause O and store other_fl from O before loading
new_fl into C so C receives O’s up-to-date stack pointer.O = 0, when DM 2 is running): CR[0x02A0] |= 1, poll
CR[0x02A8] & 1 == 1 (unpause: CR[0x02A0] &= ~1, poll == 0).O = 1, when DM 3 is running a 3D render, not TQ_3D):
CR[0x02A0] |= 2, poll CR[0x02A8] & 2 == 2 (unpause: CR[0x02A0] &= ~2, poll
== 0).CR[0x02B0]): after storing/loading the freelists and
before unpausing CR[0x02A0], write:
CR[0x02B0] = ((other_fl[0] != new_fl[0]) << 1) | (other_fl[1] != new_fl[1])
(bit 1 = different local freelist between TA and 3D; bit 0 = different global
freelist; 0 = shared).
CR[0x02A0], then invalidate the PM-MMU page
catalogue for 1 << C whenever HWRTData changed or on a first kick.CR[0x02B0] update while two
different contexts run concurrently on DM 2 and DM 3 corrupts PM freelist/page-table state
across contexts (triggering BIF0 page faults and DM 3 lockups).Interactions with the partial-render subsystem (geometry out of PM memory) are in partial-render-spm. The scheduler respects the SPM state: for example, it does not schedule the final fragment while a partial render is pending.
host writes the cCCB ─► KCCB KICK ─► context check: process fences
├─ blocked → DM wait list (re-evaluated every BG)
└─ ready → run list (priority) + DM marked pending
scheduling cycle (in DM visiting order)
└─ dispatch by command type:
├─ GEOM → geometry kick ├─ FRAG → fragment kick
├─ TQ_3D → transfer kick └─ CDM → compute kick
GPU finishes → EVENT_STATUS → IRQ task
└─ DM completion handling
└─ retire the command → process updates → IRQ to the host