Scheduler and kicks
This page describes client CCB scheduling in src/sched.c, BIF catalogue
management and compute/transfer kicks in src/kick.c, and the experimental
geometry/fragment render kicks in src/geom.c and src/frag.c.
Data master support summary
DM |
ID |
cCCB task types |
Implementation state |
|---|---|---|---|
|
0 |
— |
Firmware internal (BG context) |
|
1 |
|
Retired immediately ( |
|
2 |
|
Experimental with |
|
3 |
|
|
|
4 |
|
Unimplemented tasks are retired immediately so their trailing updates still run and host fences signal without hanging the driver.
Context table and client CCB walk (src/sched.c)
sched_kick() (called from KCCB_KICK) finds or allocates an entry in
ctxs[64] keyed by context_fw_addr (rogue_fwif_fwcommoncontext),
increments submitted_commands on up to 3 cleanup control blocks (queuing
them in an 8-entry per-context FIFO), updates write_offset and
wrap_mask in the context’s cCCB control block, marks the context pending,
and invokes sched_run().
Each cCCB command begins with a 0x28-byte rogue_fwif_ccb_cmd_header
(magic 0x2ABC in high half, bit 0x8000 marking a task, cmd_size
bytes of payload; next offset (roff + 0x28 + cmd_size) & wrap_mask):
ctx_process() loop (at most 64 commands per pass):
roff == woff -> context idle (pending = false, dep_offset = roff)
a task of this context runs -> stop
bad magic -> trace MAIN_171, mark context dead
TASK:
DM busy or forced idle -> stop (retry later)
kick_task() == running -> stop (command stays at read_offset)
kick_task() == done -> retire now (pop cleanup FIFO), continue
FENCE / FENCE_PR -> all UFOs satisfied? else stop & record last_failed_ufo
UPDATE / RMW / UNFENCED_* -> write (or add) values, notify host
PRIORITY -> update ctx.priority
PADDING / POST_TIMESTAMP -> skip
UFO semantics:
FENCE:*addr == value;FENCE_PR: signed*addr - value >= 0(used by Mesa for timeline dependencies);UPDATE:*addr = value;RMW_UPDATE:*addr += value;Sync checkpoint (bit 0 of UFO address set): fence passes on
SIGNALEDorERRORED; update writesSIGNALED.
sched_run() walks pending contexts round-robin for up to 8 passes while
progress is made, updates pow_state, and notifies the host once if any
visible state changed.
Completion and cleanup
Active kicks store {ctx, cmd_off, event_mask, finish_sfid, kick_time,
bif_slot} in dms[dm] and set bit dm in scratch 0x1A78. When an
EVENT_STATUS bit in event_mask fires (via HW2 IRQ task or timer
poll), kick_events() clears the event, runs dm_cache_flush(dm)
(Compute, fragment (3D) and transfer kicks), clears the busy bit, traces the
finish SFID and calls sched_dm_done() to advance read_offset, bump
executed_commands and re-schedule trailing updates in the same pass.
KCCB_CLEANUP returns CLEANUP_BUSY while a FWCOMMONCONTEXT has a
running task or non-empty cCCB (unless dead), or while a running DM still
references an HWRTDATA, FREELIST or ZSBUFFER; otherwise it frees
the entry and returns 0.
BIF catalogue slot management (src/kick.c)
Before kicking a DM, the context’s fwmemcontext.pc_dev_paddr is bound to
one of BIF_CAT_BASE1..7 (slot 0 is never used for clients):
An already-bound context reuses its slot.
Otherwise a free slot (not used by a busy DM) is chosen round-robin, the SLC is flushed (E015),
BIF_CAT_BASEn = pc & 0xFF_FFFF_F000is written,BIF_CTRL_INVAL = 0xFinvalidates PT/PD/PC/TLB, and the slot index is stored back intofwmemcontext.page_cat_base_reg_set.The DM’s field in
BIF_CAT_BASE_INDEX(0x1240) is pointed to the slot.bif_rebuild()restores all active bindings after HWR.
Compute kick (kick_cdm)
Follows docsClean/BXE-2-32/kick-compute-and-3d:
Read
MULTICORE_SYSTEM(0xF308); writeBCAST[0xF330] = (execute_count << 8) | 1.Bind BIF slot and set
CAT_BASE_INDEXCDM field (bits 18:16).Write 64-bit
BCAST[0x0480](cdm_ctrl_stream_base),BCAST[0x17A8](tpu_border_colour_table) andBCAST[0x0498](cdm_context_state_base_addr).Emit trace
MAIN_122.Write
CDM_CONTEXT_PDS0/1andCDM_TERMINATE_PDS/1(0x04A8..0x04C0) fromfwcomputecontext.ctxswitch_regs.Clear
COMPUTE_FINISHED, mark DM 4 busy, and triggerBCAST[0x0478] = 1(always the last write).
Unused rogue_fwif_compute_regs fields (tpu, cdm_item,
compute_cluster, tpu_tag_cdm_ctrl) are not written because their
gating features/BRNs are absent on BXE-2-32.
Transfer kick (kick_tq3d)
Follows the transfer table in docsClean/BXE-2-32/kick-compute-and-3d (verified in E014, E017, E020, E022, E023):
Write
MULTICORE_FRAGMENT_CTRL_COMMON (0xF310) = 1and bind the BIF slot for DM 3 (CAT_BASE_INDEXbits 10:8) before any ISP/PBE write.Program transfer, ISP and PBE registers:
Only when
FAST_2D((isp_render & 3) == 2): write0x0F20(isp_mtile_base),0x0F28(isp_rgn) and0x0FC8/0x0FCC = 0/0xE4(writing them unconditionally caused PBE writes to address 0; E022).Write
0x0FA8/0x0FAC = 0x88888888only ifisp_aa & 3; write0x0388 = 0; leave0x06B0(PDS_BGRND2) untouched.Set tiles-in-flight
0x0FD8 = min(ISP_CTL[15:12] + 1, 2).Program PBE in two planar banks:
WORD0_MRTn = 0x1510 + 8nandWORD1_MRTn = 0x1550 + 8n.Program end-of-tile PDS
event_pixel_pds_info/code/datainto0x0628/0x0618/0x0620.
Launch with
ISP_RENDER = isp_renderimmediately followed byBCAST[0x0F00] = 1(writingISP_RENDERearlier lost the first tile of multi-tile transfers; E023), then pokeMTS_SCHEDULE = 0.Completion:
PIXELBE_END_RENDER, per-DM cache flush and traceMAIN_4.
Geometry and fragment kicks
On by default since E041 (-DEXP_NO_RENDER retires them unrun, the
old behaviour); developed in E027–E041:
Geometry (
src/geom.c): loads PM context 0 (local/global free-list staging registers + load commands0x0208/0x20B0, ALIST/MLIST SP load commands0x0288/0x0190, skipping the PM load on non-first kicks per E039), binds BIF slot for TA after PM writes (E034), writes TE/PPP/VDM registers (including0x0CB0TA context-state base found via canary in E028), enables geometry context0x0C68, triggers0x0400 = 1, and writes back PM state on completion.Fragment (
src/frag.c): loads PM context 1 (local/global free-list load commands0x0200/0x20A8, ALIST/MLIST SP load commands0x0288/0x0190; E036, E037), programs ZLS depth/stencil registers (0x0F48..0x0F68),0x0F28 = 4 * mtile_stride, multisample words0x0FA0/0x0FA8, ISP and PBE banks, launches viaISP_RENDER+0x0F00 = 1, waits forPIXELBE_END_RENDERandPM_3D_MEM_FREE(E038), and writes back updated free-list counts. The wait forPM_3D_MEM_FREEis bounded byPM_3D_MEM_FREE_TIMEOUT_US(20 ms, E066): a partial render at the free list maximum needs about 9 ms, and giving up earlier lets the geometry reload a free list the PM is still writing.PM contexts (
src/pm.c, E041):pm_slots[]records which HWRTData and free lists each PM context holds. Before another HWRTData is loaded into a context, its live free-list state is stored back (pm_slot_evict), but only while the context is dirty: the fragment load (context 0) and the end of the fragment (context 1) already store it. Without the store, two render contexts that interleave hung the SoC; without the dirty flag, a stale store overwrote the freed pages. Every load and store emits the reference’sLoad Freelist/Store Freelisttrace lines.TA finished (
geom_done, E042): VHEAP store (not on a last kick), TPC flush0x0C50with its poll, RTC flush when an RTC is programmed, then the full geometry cache flush before retirement.Out-of-memory (
src/pm.c, E041, E042): the global free list is extended. Ready pages are added inside aPM_PAGE_MANAGEOPpause and the TA resumes with0x0328; without ready pages the TA is stopped (0x0320,0x0CF0) until a grow update (0x0328+0x0CF8) or a partial render (FRAG_PR). While a partial render is armed, the scheduler passes the fragment context’sFENCE_PRwhen it only waits for the geometry itself and kicks theFRAG_PRbehind it without moving the queue (E043);FRAG_PRstays queued between partial renders (dm_state.keep).PM-MMU invalidation (E043): SLC
0x10,BIF_CTRL_INVAL = 4and0x1348at every PM load and every 3D finished; a first geometry kick also runs0x0258and the PM reset pulses0x0290/0x0198.Known gap: the restart after a second partial render faults (Q30).