kick.c — Data-master kicks
Data-master kicks and completion handling: the BIF page-catalogue slots, the compute and transfer kicks, the dispatch of a task to its kick function, and the completion events with their per-job cache flush.
See docsClean data-masters.md, kick-compute-and-3d.md and
kick-geometry-ta.md.
-
BIF_SLOTS
Number of BIF page-catalogue slots; slot 0 belongs to the firmware.
-
static uint64_t bif_pc[BIF_SLOTS]
Page catalogue bound to each slot; all ones when the slot is free.
-
static uint32_t bif_next
The next slot to try when a new page catalogue must be bound.
-
static bool bif_slot_in_use(uint32_t slot)
Check whether a running task uses a BIF slot.
- Parameters:
slot – The slot.
- Returns:
truewhen a busy data master was kicked with this slot.
-
uint32_t bif_activate(fwaddr_t memctx_addr, uint32_t dm)
Bind a memory context to a BIF catalogue slot.
A page catalogue already bound keeps its slot. Otherwise the next slot not used by a running task is taken (slot 1 if every slot is busy); the SLC is flushed (page tables may sit stale in it, E015),
CR_BIF_CAT_BASEnis written and the MMU caches are invalidated. The slot is recorded in the memory context’spage_cat_base_reg_set.- Parameters:
memctx_addr – Firmware address of the
fwmemcontext.dm – The data master that will use it (only traced).
- Returns:
The slot, 1 to 7.
-
void bif_set_index(uint32_t dm, uint32_t slot)
Select the BIF slot a data master’s requests use.
Writes the data master’s field of
CR_BIF_CAT_BASE_INDEX(geometry bits 0..2, fragment 8..10, compute 16..18, TDM 19..21). Other data masters are ignored.- Parameters:
dm – The data master.
slot – The slot.
-
uint64_t kick_bif_pc(uint32_t slot)
Get the page catalogue bound to a BIF slot (used by the HWR code).
- Parameters:
slot – The slot.
- Returns:
The page catalogue’s bus address, or 0 when the slot is free.
-
void bif_rebuild(void)
Re-program every bound page catalogue after a GPU soft reset, and invalidate the MMU caches.
-
bool kick_defer
Set by
kick_task()when the command must stay queued: neither run nor retired.
-
void kick_init(void)
Forget every BIF slot binding (at boot and at power-off).
-
void slc_flush_inval(void)
Flush and invalidate the whole system-level cache, and wait (at most 10 ms) until the flush is done.
-
void dm_start(uint32_t dm, fwaddr_t ctxaddr, uint32_t cmd_off, uint32_t evmask, uint32_t finish_sfid, uint32_t slot)
Record that a data master starts a task.
Called by each kick function just before its trigger write. Fills the data master’s
dm_stateand sets its bit in the debug registerCR_SCRATCH15. The geometry and fragment kicks sethwrtafterwards.- Parameters:
dm – The data master.
ctxaddr – Firmware address of the context.
cmd_off – Offset of the command in the client CCB.
evmask –
CR_EVENT_STATUSbits that complete the task.finish_sfid – Trace entry written on completion.
slot – The BIF slot the task uses.
Kick a compute (CDM) command.
Programs the multicore compute control, binds the memory context, writes
the control stream, border colour table, context state and the context
switch PDS programs, then starts the CDM. Completion is
EV_COMPUTE_FINISHED.
- param ctxaddr:
Firmware address of the context.
- param ctx:
The compute context.
- param hdr:
The command header.
- param cmd:
The compute command.
- param cmd_off:
Offset of the command in the client CCB.
- returns:
the CDM is running.
- rtype:
true
-
struct [anonymous]
The compute context switch in progress (as
cswin frag.c).
-
static bool cdm_csw_enabled(void)
Whether compute may be preempted (
OS_CTXSWITCH_CDM_EN, orEXP_CSW_FORCE).
-
void cdm_csw_request(fwaddr_t new_ctx)
Ask the running compute to store its context, for a higher-priority one (
BCAST[0x0488] = 1,CSW_5).- Parameters:
new_ctx – Firmware address of the waiting context.
-
static bool cdm_csw_end(struct dm_state *s)
Finish a compute whose store was requested, at
COMPUTE_FINISHED.Waits for
CR[0x04A0]bit 0; bit 1 says the kernel was stored. The context’s low flag byte then holds the stored core mask (CSW_4,CSW_1) and the command stays at the head of its queue; otherwise the flags are cleared and the compute completes normally.- Parameters:
s – The compute data master’s state.
- Returns:
truewhen the compute was stored.
-
fwaddr_t cdm_csw_yield_to(fwaddr_t ctxaddr)
The context a stored compute context must let run first.
- Parameters:
ctxaddr – Firmware address of a context about to kick a compute.
- Returns:
The higher-priority context it yields to, or 0.
-
void cdm_csw_yield_done(void)
Stop yielding the compute data master.
-
void cdm_hwr_reset(void)
Forget a compute context switch (after a hardware recovery).
-
static bool kick_tq3d(fwaddr_t ctxaddr, struct fwcommoncontext *ctx, const struct ccb_cmd_header *hdr, const struct cmd_transfer *cmd, uint32_t cmd_off)
Kick a transfer command on the fragment data master (
TQ_3D).Writes the register table of
kick-compute-and-3d.md(answer to Q13): background object, the fast-2D region registers whenisp_renderselects fast 2D, USC output and clear values, screen, tile size and origin, tiles in flight (min(ISP_CTL[15:12] + 1, 2)), ISP control and anti-aliasing, the end-of-render PDS program and the PBE words of the four render targets. It then launches the pixel pipe (answer to Q14). Completion isEV_PIXELBE_END_RENDER.- Parameters:
ctxaddr – Firmware address of the context.
ctx – The render context.
hdr – The command header.
cmd – The transfer command.
cmd_off – Offset of the command in the client CCB.
- Returns:
the fragment data master is running.
- Return type:
true
-
static void dump_words(uint32_t tag, const void *base, uint32_t bytes)
Dump memory to the debug trace, 32 bytes per entry (E027).
Each block of 8 words is a
DBG_2tag (tag | byte offset) followed by aDBG_9entry with the words. The debug group must be enabled (log type mask0x80007FFE).- Parameters:
tag – Block tag,
0xD0000000 | block id.base – Start of the memory; nothing is dumped when
NULL.bytes – Size to dump.
-
static void dump_render_cmd(uint32_t id, fwaddr_t ctxaddr, struct fwcommoncontext *ctx, const void *payload, uint32_t size)
Dump the host structures behind a geometry or fragment command (E027).
Dumps the command, its HWRTData, the HWRTData’s common part and free lists, and for a geometry command the render context’s static state and context state, so that they can be matched by value against the registers the specification observed. Built only with
EXP_DUMP_RENDER.- Parameters:
id –
CCB_CMD_GEOMorCCB_CMD_FRAG.ctxaddr – Firmware address of the render context.
ctx – The render context.
payload – The command.
size – The command’s size.
-
bool kick_task(uint32_t dm, fwaddr_t ctxaddr, struct fwcommoncontext *ctx, const struct ccb_cmd_header *hdr, const void *payload, uint32_t cmd_off)
Start a task command on its data master.
Dispatches by command type to the compute, transfer, geometry or fragment kick.
NULL,ABORT,PRE_TIMESTAMPandFBSC_INVALIDATEcomplete at once. AFRAG_PRruns only when the SPM armed a partial render for its HWRTData; otherwise it completes without running, unless that HWRTData’s geometry still runs (it may still run out of memory), in which casekick_deferkeeps it queued. Unimplemented commands are traced and complete without running, so the host never hangs.- Parameters:
dm – The data master chosen by the scheduler.
ctxaddr – Firmware address of the context.
ctx – The context.
hdr – The command header.
payload – The command, right after the header.
cmd_off – Offset of the command in the client CCB.
- Returns:
trueif the data master is now running the task,falseif it completed at once (or must wait, seekick_defer).
-
static void mmu_fault(void)
Handle an MMU page fault while a data master runs.
Traces the fault status of bank 0, clears the event and starts the hardware recovery (
hwr_recover()).
-
void kick_events(uint32_t ev)
Handle GPU events.
An MMU page fault starts the recovery; a PM out-of-memory event while the geometry runs goes to the SPM (
spm_oom()). Each busy data master whose completion event is set then finishes: a render-target array moves to its next layer instead (frag_rta_next()); otherwise the geometry post-processing runs, the caches are flushed, the fragment post-processing runs, and the task is retired (sched_dm_done()).- Parameters:
ev – The
CR_EVENT_STATUSbits that were set.
-
void sched_poll(void)
Poll
CR_EVENT_STATUSfor the events the running tasks wait for.A backstop for a missed MTS interrupt task: called from the timer tick and the background task. Page faults, and out-of-memory while the geometry runs, are polled too.
-
bool kick_resource_busy(uint32_t type, fwaddr_t addr)
Check whether a running task uses a resource the host wants to free.
- Parameters:
type –
CLEANUP_*type (not used: every type is compared with the running HWRTData).addr – Firmware address of the resource.
- Returns:
truewhen a busy data master uses it.