hwr.c — Hardware recovery
Hardware recovery (docsClean hardware-recovery.md, “Reset
sequence”).
Triggered by an MMU page fault (interrupt task or poll) or by the watchdog
when a data master has been busy for longer than its deadline. The GPU
units are reset with a SOFT_RESET pulse that leaves the MIPS core and
the MTS wrapper alone, then re-initialised, and every running command is
discarded (its updates still run, so the host is never left waiting).
-
CTX_FLAGS_NEED_RESUME_BIT
ROGUE_FWIF_CONTEXT_FLAGS_NEED_RESUME(3D, core 0).
-
static uint64_t hcs_deadline[DM_MAX]
CR_TIMERdeadline of the pending store per data master (0: none).
-
static uint32_t hcs_ms_seen
The last
hcs_deadline_msseen, to trace a change (MAIN_133).
-
HWR_TIMEOUT_DEFAULT_MS
Watchdog deadline when the context gives none, in milliseconds.
Normally the context’s
max_deadline_msapplies (the mainline host sets 30 s; its own job timeout is 60 s). 2 s was too short for large dispatches (E020).
-
static uint32_t hwr_counter
Number of recoveries since boot.
-
static uint32_t running_job_ref(const struct dm_state *s)
Get the job reference of the command a data master runs.
- Parameters:
s – The data master’s state.
- Returns:
The command’s
ext_job_ref(reported to the host), or 0.
-
void hwr_recover(uint32_t reason, uint64_t mmu_status, uint64_t req_status)
Recover the GPU.
Hold scheduling: report the reset in progress to the host.
Quiesce the BIF, MMU and SLC (“Detailed bus quiesce”, answer to Q29b item 4).
Disable partial renders.
Two-stage soft reset of the GPU units.
Re-initialise the units, unstall the BIF, clean the TPU and SLC, re-program the BIF catalogue, unpause the PM; forget the PM state and ask the host to rebuild the free lists of the HWRTData in use.
Discard the running commands (their updates still run).
Write the HWR log entry and send a context-reset notification per lost job, then resume scheduling.
- Parameters:
reason –
HWR_REASON_MMU_FAULTorHWR_REASON_LOCKUP.mmu_status –
BIF_FAULT_BANK0_MMU_STATUSof a page fault, else 0.req_status –
BIF_FAULT_BANK0_REQ_STATUSof a page fault, else 0; its address field is reported as the fault address.
-
void hcs_arm(uint32_t dm)
Arm the HCS watchdog for a context-store request.
- Parameters:
dm – The data master asked to store its context.
-
void hcs_disarm(uint32_t dm)
Disarm the HCS watchdog: the store completed (or the task finished).
- Parameters:
dm – The data master.
-
static bool hcs_check(uint64_t now)
Force the context switch of a data master whose store missed its HCS deadline (
HWR_60,MAIN_132): the data master is recovered.- Parameters:
now – The current
CR_TIMER.
- Returns:
truewhen a recovery was started.
-
void hwr_watchdog(void)
Detect a data master that runs for too long; called from the timer tick.
Compares each busy data master’s run time with its context’s
max_deadline_ms(orHWR_TIMEOUT_DEFAULT_MS) and starts a lockup recovery for the first one over it. A context store that missed its HCS deadline is recovered first.