Repository navigation
drm/asahi: recover from G14 firmware 27.2 command timeouts and faults per client - #3041
Conversation
… per client
When a command runs past its execution allowance or faults, the G14
firmware 27.2 reports it on the event ring (kind 4 timeout with the named
slot at +0xc, kind 0 fault) and stops every queue in a recovery handshake:
it publishes phase 1 at control +0x4c00, advances the u64 generation at
+0x4bf0 and records the stopped work at +0x4298 as {flags, target} pairs.
It runs nothing until the host answers 2 and, at its phase 3, 0. This is
the order G16 and M3 answer in their firmware data.
The runtime decoded neither event. A stuck command stopped the whole GPU
until the host's own timeout failed every client, so a single test client
took the compositor down with it.
Decode both events and answer the handshake. Mark the stopped work: the
published render pair (a render is always published alone) or the oldest
unretired compute command and the rest of its packet. Clear the TPC storage
of a stopped tiler (snapshot flags 0x9) before answering 2, as G16 does.
Then wait for phase 3 with an unchanged generation, answer 0, and wait for
the stopped work to leave its queue. Its stamp is not written, so its
position is what counts. It fails only its own packet and VM, so the client
sees a lost context. Work queued behind it has its clocks restarted and
retires normally. Further recoveries while the work drains are answered up
to four times. If the firmware does not enter recovery, reach phase 3 or
drain, all work fails as before. A host timeout that finds phase 1 without
a seen event takes the same path. A doomed packet records the error in
its VM status even if a racing scheduler timeout claimed its fence first.
The handshake decisions are G16's: which phase the host may answer, how a
snapshot entry decodes and the recovery-storm window (32 in 10 s) come from
its pure, host-tested g16/recovery/logic.rs, included by path rather than
copied. The G14 27.2 record kinds, recovery offsets and the stopped-tiler
rule move to g14_v27_2_abi.rs with host tests
(tools/asahi/g14-v27-2-abi-tests.rs, registered in run-host-tests.py).
Signed-off-by: Ryan Murray <[email protected]>
|
MERGETRAIN6 source review at Refresh completion state and correlate the stopped entry with the tracked command or packet before reporting a per-client loss. If the firmware information is ambiguous, keep the existing fail-stop behavior for that case. Please add a host fixture covering a completed entry still in the host list ahead of the stopped entry, plus a generation change while recovery drains. The earlier J473 H4 is good precursor evidence for the exercised ownership pattern. Assisted-by: LLM (Codex) |
There was a problem hiding this comment.
Formal adversarial pre-PR review bound to head 8da4dbcce37475e5a8b3db8d0e8a37492fb5d093 (stacked on #3031 / m2gpu/g14-v27-2-render ccde92779a5f0c5e52d43e6ae88547b913afea01).
Verdict: REQUEST_CHANGES
The shared g16/recovery/logic.rs reuse via #[path], commit hygiene (§4), and lack of model/board gating (§1/§2) are clean, but there are concrete correctness, memory-safety, and contract blockers in the recovery path plus missing exact-head hardware/CI evidence.
Blockers (§1 Correctness & Safety)
-
Misattribution and false
Ok(())retirement on pipelined compute work (drivers/gpu/drm/asahi/g14_v27_2.rs:894-912, 991-994, 1020-1044, 1123-1188)service_locked()drains the event ring and callsrecover()before callingadvance(state)and retiring already-completed entries at the front ofstate.inflight.blame()ignores both the event'sslotand every decodedSnapshotEntry { flags, event, target }(only logged / checked forstopped_tiler), and blindly marksstate.inflight.first().- When an innocent VM's compute command has already finished on the GPU (still at
inflight[0]beforeadvance()) and a later VM's command times out/faults,blame()dooms the innocent earlier packet,doomed_retired()immediately observesretired_total >= ordinal(Ok(true)),recover()restartsstartedon the actually stopped command,service_locked()kills the innocent VM viafail_doomed(), and the truly stopped command—never markeddoomed—can then leave the queue without a stamp and retire aspacket.retired()(Ok(())). - Additional attribution/state-machine gaps in
recover():self.blame(...)'sboolreturn is ignored (g14_v27_2.rs:993): a halt with nothing published still answers2 -> 3 -> 0and stays healthy instead of correlating against a last-retired target or fail-stopping.if !blamedskipsblame()on rounds1..=FURTHER_RECOVERIES, so a second recovery while draining that stops a different queued command is never markeddoomedand can likewise retire asOk(()).- The drain loop (
g14_v27_2.rs:1020-1039) checks onlyrecovery_phase()? == 1: it does not verify thathalt_count()advanced to a new generation, does not fail-stop on unexpected phases (!= 0 && != 1), and does not checkstate.peer.is_crashed()during the 1 s drain wait.
- Required fix: Refresh/retire completed work before attributing, correlate firmware snapshot
(flags, event, target)/ eventslot/FaultStatusASID against tracked flights (fail-stopping on ambiguity or unmatched entries asg16/engine.rs::recovery_preparedoes), re-attribute on new-generation drain recoveries, and add host-test fixtures covering (a) a completed entry ahead of the stopped entry and (b) a generation change during drain.
-
Undefined Behavior in
Scene::clear_tpc(drivers/gpu/drm/asahi/buffer.rs:204-213)clear_tpc(&self, bytes)creates an immutable slicelet tpc = self.object.tpc.as_slice();(&[u8]fromslice::from_raw_parts,object.rs:688-691, noUnsafeCell) and then writes throughtpc.as_ptr().cast_mut()withcore::ptr::write_bytes. Mutating through a shared&[u8]reference is Rust UB.clear_tpcis also exposed as a safepub(crate)method onScene::veracross all GPU generations even thoughself.object.tpcis a sharedArc<GpuArray<u8>>cached inBufferInner::tpc(buffer.rs:700-717) and relies on an unchecked caller precondition that no concurrent reader/writer exists.- Required fix: Zero through a raw pointer method on
GpuArray<u8>(without fabricating&[u8]) and document/enforce the exclusivity precondition cleanly.
-
Guilty VM is not actually banned from admission (
drivers/gpu/drm/asahi/g14_v27_2.rs:577-589, 676-712, 880-889,m3_submit.rs:288-359)- The PR claims "the guilty VM is latched" and "only that packet and its VM fail", but
fail_doomed()only withdraws the single doomed packet fromstate.pendingand records the error inVmStatus. - Neither
m3_submit::Queue::submit(),mmu::Vm::retain_job(),Runtime::submit(), norRuntime::pump()checksvm.status().get() != 0(compareg16/engine.rs:695). - Consequently, other packets already queued in
state.pendingor the scheduler from the same guilty VM still publish and run after recovery, and a client that submits again without checkingVM_STATUScontinues executing on the GPU. (status.note_recovery_guilty()is also never called.) - Required fix: Reject new submissions and fail/withdraw queued
state.pendingpackets belonging to any VM whoseVmStatusis non-zero (and callstatus.note_recovery_guilty()when blaming a guilty VM).
- The PR claims "the guilty VM is latched" and "only that packet and its VM fail", but
-
Fallback render recovery in
retire_render()strandsstate.rendering(drivers/gpu/drm/asahi/g14_v27_2.rs:864-869)- When
retire_render()hitsCOMMAND_TIMEOUT_MSand findsrecovery_phase()? == 1 && doomed.is_none(), it executesreturn self.recover(state, ETIMEDOUT, -1);. recover()drains TA and FS to completion and returnsOk(()), after whichretire_render()returnsOk(())without takingstate.renderingor callingfail_doomed().service_locked()then callspump(state), which immediately returns becausestate.rendering.is_some(). With TA/FS already retired, no further EP 0x20 interrupt arrives, leaving the doomed fence unsignaled and starving all other clients'state.pendingwork until the 10 s DRM scheduler timeout fireswake().- Required fix: Re-run the retirement check (or loop, as the compute fallback at
g14_v27_2.rs:1174-1180does) afterrecover()returnsOk(())sostate.renderingis taken, slots are retired, andfail_doomed()runs immediately.
- When
-
DMA / resource retirement witness on aborted commands (
drivers/gpu/drm/asahi/g14_v27_2.rs:832-863, 880-889, 1155-1168vsg16/recovery/logic.rs:51-53)- On an aborted (
doomed) command, no completion stamp is written;render_retired()/advance()only proves queue cursor progress. Yetretire_render()andservice_locked()immediately dropRenderFlight/Inflight(releasingVmBind,scene/aux_fb/scene27/tvb_*,preempt), callpacket.release_guard()(allowing immediate user BO unmap/free), and clearstate.busy(allowing pool slot reuse onceregistered(slot)reads 0). - Contrast with the invariant in
g16/recovery/logic.rs:51-53(imported by this PR) andg16/poll.rs:519-524: "A passed abort proves queue progress only and never permits reuse." Either establish and document the exact G1427.2firmware/hardware quiescence guarantee proving that retired-cursor advance after phase3 -> 0guarantees zero further DMA to client BOs,VmBind,scenebuffers, and pool slots, or quarantine aborted slots/guards/owners instead of releasing them.
- On an aborted (
Non-blocking hardening notes
drivers/gpu/drm/asahi/gpu/v27_2.rs:745-761:control_snapshot()slicesself.control.as_slice()[from..]and runsclean_invalidate_poc(at, out.len() * 4)before bounds-checkingfrom + out.len() * 4 <= self.control.len(). Current internal callers are in-bounds, but as apub(crate)fallible helper it should validate the full byte range before slicing/cache-cleaning (likewisecontrol_store()).drivers/gpu/drm/asahi/g14_v27_2.rs:962-1044: Up to1 + FURTHER_RECOVERIES(5) rounds ×(50 ms + 1000 ms + 1000 ms)holdsself.statemutex for up to ~10.25 s, exceeding the 10 s scheduler timeout and blockingsubmit()/withdraw()/sleep_prepare()/stop(). Consider bounding total recovery wall time under the lock.
Checklist Status (§2–§6)
- §2 Scope & No Hacks: PASS — no chip/board/firmware-version gates, no new cmdline/module params, clean
#[path]reuse ofg16/recovery/logic.rs(compiles withoutCONFIG_DRM_ASAHI_G16), no cross-SoC regressions beyondbuffer.rs::clear_tpc(B2). - §3 Docs & PR Body: Needs update once B1/B3 are fixed so "the guilty VM is latched" and per-client isolation match implementation.
- §4 Commit Hygiene: PASS — single commit
8da4dbcce37475e5a8b3db8d0e8a37492fb5d093has human author/committer (Ryan Murray <[email protected]>), humanSigned-off-by:, and zero AI trailers in commits. - §5 Hardware Evidence: Missing (blocker before merge) — as noted in "Still to run", exact-head J473 (
27.2, without lab encoder-params edits; covering render + compute fault/timeout recovery, innocent context survival, pipelined compute attribution, and repeated fault stress) and J413 (13.5regression tuple) are still required. - §6 Build & CI: 0 CI checks ran on
8da4dbcce37475e5a8b3db8d0e8a37492fb5d093(host-tests.ymlskips stacked basem2gpu/g14-v27-2-render;sep-source.ymlpath filters do not matchdrivers/gpu/drm/asahi/**ortools/asahi/**). Locally verifiedrustc --testong14_v27_2_abi.rs(6/6 pass) andg16/recovery/logic.rs(9/9 pass); arm64 kernelrust-buildand KUnit (asahi_g14_fw_queues) have not yet run on this head.
The recovery blamed the first command still in the host's compute list.
That list can hold a command the firmware already completed but the host
has not yet retired, ahead of the one the firmware stopped, so a healthy
client could lose its context while the guilty one carried on.
Each recovery snapshot entry's target is the completion stamp the stopped
command would have written (on the J473: compute stamp 0x7900 written,
entry {0x7, 0x7a00}; tiler stamp 0x2156500 written, entry {0x1f,
0x2156600}). Refresh the retired position, then match every valid entry
against the published render pair's stamps and the unretired compute
commands' stamps. Blame only when all entries of a round name the same
tracked command. A stopped tiler can only be the render pair. Anything
unnamed, mixed or colliding keeps the fail-stop.
Attribute every round, not just the first: work queued behind the first
stopped command can time out while it drains. A further round must carry
a new recovery generation.
The attribution and round rules live in g14_v27_2_abi.rs, with host
tests for a completed entry ahead of the stopped one, render pairs,
ambiguous snapshots and generation changes while draining.
Signed-off-by: Ryan Murray <[email protected]>
|
Thanks, that's a real bug. Fixed in 52166ad, a new commit on top; no force push.
The H3/H4 snapshots each had one entry naming the stopped command's next stamp, so the earlier rows should attribute the same way. A J473 row at this head is still needed. |
|
Re-review of The other open review findings remain in the code. Queue retirement still releases aborted-command state without a separate quiescence witness. The guilty VM still needs admission and pending-queue enforcement, the render timeout fallback still needs to retire and signal the render flight after recovery, and the shared TPC clear still needs a valid exclusive write path. Keep recovery separate from base render qualification while these are addressed. Assisted-by: LLM (Codex) |
There was a problem hiding this comment.
Focused §1–§6 re-review at exact head 52166ad98c80677784ee2cd77dcb69cf5bf8e1eb (stacked on 8da4dbcce37475e5a8b3db8d0e8a37492fb5d093, no force push). Posting as COMMENT so the existing CHANGES_REQUESTED hold remains active while the remaining code blockers and hardware evidence are still open.
Verification of 52166ad98c80 (Snapshot Attribution & Round Generation Fix)
Resolved: Blocker #1 (stale-front selection / snapshot attribution) is cleanly addressed with no new regressions introduced:
- Already-retired compute entries:
recover()now refreshesstate.retired_totalviaself.advance(state)?before scanning the snapshot and excludes retired entries viaf.ordinal > retired(drivers/gpu/drm/asahi/g14_v27_2.rs:988-1003). An already-completed innocent command sitting atstate.inflight[0]is no longer blamed and retires normally inservice_locked(). - Render pair & stopped-tiler rules:
Attribution::add()matches[TILER, FRAGMENT]completion stamps toStopped::Render, blocksstopped_tiler(flags)(flags & 9 == 9) from attributing compute, and fails closed (ambiguous = true->None->Err(EIO)fail-stop) on empty (0entries), unnamed, mixed, or dual-match snapshots (drivers/gpu/drm/asahi/g14_v27_2_abi.rs:106-138). - Per-round attribution & generation check: Every drain recovery round is now attributed and enforces
new_round(previous, generation)(generation != p, failing withEPROTOon repeat;g14_v27_2.rs:981-986,g14_v27_2_abi.rs:142-147). - Locking & ordering: Runs exclusively under
self.statemutex;recovery_phase(),halt_count(),progress(), andrecovery_entry()each performclean_invalidate_poc+poc_barrier()+Acquireloads while firmware is halted at phase 1 beforeanswer_recovery(2)(Release+clean_poc+poc_barrier()). - Host tests: Re-ran
rustc --test drivers/gpu/drm/asahi/g14_v27_2_abi.rsat52166ad98c80— 10/10 pass.
Remaining Open Blockers (Verified Unchanged at 52166ad98c80)
- Shared TPC clear UB / exclusivity (
drivers/gpu/drm/asahi/buffer.rs:204-213):Scene::clear_tpc(&self, bytes)still fabricates an immutable&[u8]slice (self.object.tpc.as_slice()) and writes throughtpc.as_ptr().cast_mut()viawrite_byteson a sharedArc<GpuArray<u8>>exposed as a safepub(crate)method. - Guilty VM admission & pending-queue enforcement (
drivers/gpu/drm/asahi/g14_v27_2.rs:578-590, 677-713, 881-890):submit()andpump()still do not reject VMs with non-zeroVmStatus,fail_doomed()still only removes the single doomed packet fromstate.pending(leaving other queued packets from the same guilty VM to publish), andstatus.note_recovery_guilty()is still not called. - Render timeout fallback strands
state.rendering(drivers/gpu/drm/asahi/g14_v27_2.rs:865-870): Returningself.recover(state, ETIMEDOUT, -1)directly leavesstate.renderingpopulated afterrecover()drains TA/FS, blockingpump()and leaving the doomed fence unsignaled until a later wakeup/scheduler timeout. - Queue retirement without a separate quiescence witness on aborted commands (
drivers/gpu/drm/asahi/g14_v27_2.rs:833-864, 881-890, 1178-1192vsg16/recovery/logic.rs:51-53): Aborted commands still immediately dropRenderFlight/Inflight, release packet guards, and clearstate.busyon retired-cursor advance alone without either an established G1427.2firmware/hardware quiescence guarantee or quarantine.
Additional Pre-existing Recovery Note (Worth Fixing Alongside the 4 Blockers)
- Unconsumed
EVENT_RINGrecord after multi-round or fallback recovery (drivers/gpu/drm/asahi/g14_v27_2.rs:965-1068, 1146-1157):state.root.drain()(gpu/v27_2.rs:818-834) drains telemetry rings only, notEVENT_RING. If a further recovery round during drain (rounds >= 1), a fallback timeout recovery, or a racing fault+timeout pair leaves an already-answeredTimeout/Faultrecord inEVENT_RING, the nextservice_locked()pass consumes it, callsrecover(), waitsPHASE1_WAIT_MS(50 ms) while firmware is already back at phase 0, and triggersfail_all(ETIMEDOUT)across healthy clients. (Also, the drain loop atg14_v27_2.rs:1043-1062still does not fast-fail on unexpected phases!= 0 && != 1orstate.peer.is_crashed().)
Checklist Status (§1–§6 at 52166ad98c80)
- §1 No model gating: PASS — no chip, SoC, board, or firmware-version gates.
- §2 Production-ready, no hacks: PASS — default kernel cmdline, no sleeps/retries over races, clean shared
g16/recovery/logic.rs. - §3 Safety: OPEN — 4 code blockers above still open.
- §4 Clean-room & attribution: PASS — both commits (
8da4dbcce374,52166ad98c80) carry human author/committer (Ryan Murray <[email protected]>), humanSigned-off-by:, zero AI trailers in commit messages, and no force push. - §5 Hardware evidence: OPEN — exact-head J473 (
27.2, without lab encoder-params edits) and J413 (13.5regression tuple) runs are still required before merge. - §6 Naming & CI: Naming PASS (Borealis / Aurora conventions). 0 CI check runs / 0 commit statuses ran on
52166ad98c80(stacked basem2gpu/g14-v27-2-render); locally verifiedg14_v27_2_abi.rsunit tests (10/10 pass).
Review of the G14 27.2 per-client recovery found these gaps: - A stopped command leaves its queue without a completion stamp. That proves queue progress, not that the GPU no longer reaches its memory, which is the G16 Retirement::Aborted rule. The runtime still released the command's VM job guard, binding and scene. Now the error completion quarantines the guard, and the stopped command's flight (packet, binding, scene) is kept for the rest of the boot, as stop() does for everything. Pool slots are still reused only after the firmware unregisters them. - The guilty VM was not barred from running more work. Blaming now latches its VmStatus (note_recovery_guilty + record) before the work drains. submit() refuses packets of a failed VM, and pump() fails the ones already queued instead of publishing them, as G16 does. - A render timeout that found the firmware in recovery recovered but left the render flight in place. Nothing then signalled its fence or published the queue behind it until the scheduler timeout. Retire it right after the recovery. - Scene::clear_tpc wrote through a shared slice and was available to every GPU generation. It is now an unsafe fn of the G14 27.2 scene only, and zeroes through a raw-pointer GpuArray<u8> helper with its exclusivity precondition stated. - While stopped work drains, a crashed coprocessor or a phase the protocol does not allow now fails the recovery. The whole recovery starts no round after 5 s, so the state lock is released inside the scheduler's job timeout. Control-object reads and writes validate their byte range first. Signed-off-by: Ryan Murray <[email protected]>
|
Thanks for the thorough review. Everything is addressed at f55ae32 (two new commits on top; no force push):
Hardening notes: control-object reads and writes check their byte range before slicing or cache maintenance. Rounds start only within a 5 s budget, so the lock is held for at most about 7 s, inside the 10 s job timeout. Full arm64 build at f55ae32 is OK with 0 warnings in the changed files. ABI host tests pass 10/10. A J473 row at this exact head is next (kit |
|
Independent source review of One resource lifetime issue remains. Please track retained resources under the runtime and bound their cumulative retention. If that limit is reached, use the existing fail-stop path while preserving the DMA guard until a proven quiescent state. Please keep #3041 separate from the fleet cut. The J473 and J413 hardware rows at this head remain separate. Assisted-by: LLM (Codex) |
There was a problem hiding this comment.
Focused §1–§6 exact-head re-review at f55ae32f692706ff409508610b3a39e969f3f508 (now rebased/retargeted onto integration/aurora after #3031 merged; 3 human-signed commits, no force push).
Verdict: REQUEST_CHANGES
All 4 code blockers from the 52166ad98c80 review and the prior hardening notes are cleanly addressed, and the base branch is now integration/aurora. However, 3 concrete code issues remain in the recovery/quarantine path (including the unconsumed EVENT_RING note and two quarantine-tracking issues), alongside pending CI runs and exact-head §5 J473/J413 hardware evidence.
Cleared Since 52166ad98c80
Scene::clear_tpcUB / exclusivity (object.rs:722-732,buffer.rs:305-308,g14_v27_2_render.rs:86-89,g14_v27_2.rs:1070-1080): Resolved. Moved off genericimpl Scene::veronto#[cfg(CONFIG_DRM_ASAHI_G14_V27_2)] impl SceneG14V13_5asunsafe fn, zeroing directly throughGpuArray<u8>::zero_prefix(self.rawpointer without fabricating&[u8]) with documented# Safetypreconditions satisfied underself.stateduring firmware phase 1 halt. (Tiny non-blocking nit: duplicate summary doc line atg14_v27_2_render.rs:80-81.)- Guilty VM admission & pending-queue enforcement (
g14_v27_2.rs:415-426, 610, 712-716, 943, 955): Resolved.blame()callslatch_guilty()(status.note_recovery_guilty()+status.record(error)) before drain;submit()rejects failed VMs withErr(EIO);pump()fails already-queued packets from failed VMs viastate.fail_publication(&packet, EIO)instead of publishing them. - Render timeout fallback stranding
state.rendering(g14_v27_2.rs:901-907): Resolved.retire_render()now re-invokesself.retire_render(state)immediately afterself.recover(state, ETIMEDOUT, -1)?succeeds (bounded depth 1 sincedoomedis set), takingstate.rendering, retiring slots, signaling the error fence, and unblockingpump(). - Aborted-command guard/flight quarantine (
g14_v27_2.rs:431-433, 891-893, 925-933, 1247-1249): Primary retirement path resolved (fail_doomed()no longer callspacket.release_guard();Packet::finish(Err(err))quarantines theVmJobGuardandquarantine(flight)retains the flight/binding/scene; pool slots reuse only afterCommandPool::registered(slot)reads 0), subject to the two quarantine-lifetime blockers below. - Hardening notes: Resolved.
RootV27_2::control_range()validates byte bounds and 4-byte alignment before slicing/cache maintenance (gpu/v27_2.rs:745-771),RECOVERY_BUDGET_MS(5 s) bounds lock hold time within the 10 s scheduler timeout (g14_v27_2.rs:81, 1018-1021), and the drain loop fast-fails onstate.peer.is_crashed()or unexpected phases viarecovery_logic::action()(g14_v27_2.rs:1110-1121). - Base branch: Retargeted to
integration/aurora.
Remaining Code Blockers (§3 Safety & Correctness)
Runtime::withdraw()can release a quarantinedVmJobGuard(drivers/gpu/drm/asahi/g14_v27_2.rs:621-634,m3_submit.rs:180-188):quarantine(flight)removes the doomed flight fromstate.rendering/state.inflightand callscore::mem::forget(flight), sostate.owns(packet)becomesfalseeven thoughpacket.vm_jobstill holds the quarantinedVmJobGuard.- If a racing DRM scheduler
Job::timed_out()subsequently sees!runtime.healthy()(e.g., on a later failure or duringRuntime::stop()betweenself.healthy.store(false)atg14_v27_2.rs:1346andguard.take()at line1359) and callsruntime.withdraw(&job.packet),withdraw()sees!state.owns(packet)and callspacket.release_guard(), dropping the quarantinedVmJobGuardand allowingdrain_mappings()to unmap the quarantined VM's user pages.
- Unbounded
core::mem::forgetquarantine retention (aligning with#7125073939,drivers/gpu/drm/asahi/g14_v27_2.rs:431-433, 893, 1249):- Because
recovery_logic::admit()resets its counter every 10 s window, slow faults can retainVmBindcontext slots, buffer slots, and scenes indefinitely viacore::mem::forget(flight)with no cumulative cap. - Combined fix for #1 and #2: Track quarantined flights inside
Stateup to a bounded cumulative cap (failing closed viafail_all()when exhausted while keeping guards quarantined), and include quarantined flights instate.owns(packet)(and/or guardPacket::release_guard()against releasing a quarantined guard).
- Because
- Unconsumed
EVENT_RINGrecord after multi-round (rounds >= 1) or fallback timeout recovery (drivers/gpu/drm/asahi/g14_v27_2.rs:905, 1010-1134, 1212-1223, 1266,gpu/v27_2.rs:827-844):- Still open at
f55ae32f6927.state.root.drain()drains telemetry rings only, notEVENT_RING. - When a second recovery round occurs during drain (
rounds >= 1) or when a fallback timeout recovery runs fromretire_render()/ compute timeout afterprocess_events(), firmware'sTimeout/Faultrecord for that already-answered recovery remains unread inEVENT_RING. On the nextservice_locked()wakeup,process_events()consumes that stale record and callsrecover(), which waitsPHASE1_WAIT_MS(50 ms) against phase 0 and triggersfail_all(ETIMEDOUT)across every innocent client. - Fix: Drain/consume stale
Timeout/Faultrecords belonging to the handled recovery (without droppingGroworChannelErrorrecords) or verify recovery phase/generation before escalating a stale event record tofail_all(ETIMEDOUT).
- Still open at
Checklist Status (§1–§6 at f55ae32f6927)
- §1 No model gating: PASS — no chip, SoC, board, or firmware-version gates.
- §2 Production-ready, no hacks: PASS — default kernel cmdline, clean shared
g16/recovery/logic.rs. - §3 Safety: OPEN — 3 code blockers above (
withdraw()guard release on quarantined packet, bounded quarantine tracking inState, and unconsumedEVENT_RINGrecord). - §4 Clean-room & attribution: PASS — all 3 commits (
8da4dbcce374,52166ad98c80,f55ae32f6927) carry human author/committer (Ryan Murray <[email protected]>), humanSigned-off-by:, 0 AI commit trailers, no force pushes. - §5 Hardware evidence: OPEN — exact-head J473 (
27.2, default cmdline, without lab encoder-params edits) and J413 (13.5regression tuple: 0 SELinux denials, 0 failed units, 0 new kernel errors) runs are still pending. - §6 Naming & CI: Naming PASS (Borealis / Aurora conventions; zero forbidden naming in diff/PR body). Base is now
integration/aurora, but 0 CI check runs / 0 commit statuses have executed onf55ae32f6927yet. Locally verifiedrustc --test drivers/gpu/drm/asahi/g14_v27_2_abi.rs(10/10 pass) andrustc --test drivers/gpu/drm/asahi/g16/recovery/logic.rs(9/9 pass).
|
J473 row at the exact head f55ae32 passes. Our own traces; default cmdline; GNOME on both monitors with a bystander glxgears; same repro as H4 but no lab changes.
A first attempt ran the runner's default three s2idle cycles on the lab Stage 2 and reset during the second, before the repro, so it gave no recovery result. That Stage 2 has no #2953 fix. Still open: the J413 regression row, and CI on the integration base. |
|
Proposal for the remaining retention finding at
Smallest bound I can see: a per-boot count of doomed flights, checked in
Sketch// g14_v27_2_abi.rs (host-tested with the other ABI rules)
/// Stopped commands one boot may keep (`quarantine`): each pins a VM binding (a user UAT
/// context) and, for render, a scene. Half the user contexts, so innocent clients keep the rest.
pub(crate) const QUARANTINE_LIMIT: u32 = 31;
/// Whether `more` newly stopped commands still fit next to the `kept` ones.
pub(crate) const fn quarantine_fits(kept: u32, more: u32) -> bool {
match kept.checked_add(more) { Some(total) => total <= QUARANTINE_LIMIT, None => false }
}
#[test]
fn quarantine_is_bounded_per_boot() {
assert!(quarantine_fits(0, 1));
assert!(quarantine_fits(QUARANTINE_LIMIT - 1, 1));
assert!(!quarantine_fits(QUARANTINE_LIMIT, 1));
assert!(!quarantine_fits(QUARANTINE_LIMIT - 1, 2));
assert!(!quarantine_fits(u32::MAX, 1));
assert!(quarantine_fits(QUARANTINE_LIMIT, 0)); // a re-named, already doomed packet
}// g14_v27_2.rs
const _: () = assert!(g14_v27_2_abi::QUARANTINE_LIMIT as usize <= mmu::UAT_USER_CTX / 2);
// (mmu::UAT_USER_CTX becomes pub(crate))
struct State {
// ...
/// Commands doomed by a recovery this boot; each is kept until shutdown (`quarantine`).
quarantined: u32,
}
fn blame(&self, state: &mut State, error: Error, slot: i32, work: Stopped) -> Result {
match work {
Stopped::Render => {
let Some(flight) = state.rendering.as_mut() else { return Err(EIO); };
let more = u32::from(flight.doomed.is_none());
if !g14_v27_2_abi::quarantine_fits(state.quarantined, more) {
return self.quarantine_spent(state);
}
state.quarantined += more;
flight.doomed = Some(error);
// ... unchanged
}
Stopped::Compute(stamp) => {
let Some(packet) = /* unchanged */ else { return Err(EIO); };
let more = state.inflight.iter()
.filter(|f| Arc::ptr_eq(&f.packet, &packet) && f.doomed.is_none())
.count() as u32;
if !g14_v27_2_abi::quarantine_fits(state.quarantined, more) {
return self.quarantine_spent(state);
}
state.quarantined += more;
// ... unchanged: mark doomed, latch_guilty, log
}
}
Ok(())
}
/// Recovery would keep more stopped work than one boot may: fail all work instead (the
/// caller's fail-all path keeps published work owned, as before recovery existed).
fn quarantine_spent(&self, state: &State) -> Result {
dev_err!(self.dev, "GPU: {} stopped commands kept this boot; not recovering more\n",
state.quarantined);
Err(EIO)
}Hardware check: the existing H5 repro, run 32 times in one boot (spaced more than 10 s apart, so the storm limit never trips). The first 31 recover per client. The next one fails all work with the new message and 0 Oops, and the host stays up. This does not address the separate Assisted-by: LLM (Claude:Opus 5.5 via Antigravity) |
|
Merge readiness at
Areas: Updated by pr-readiness on every push, edit and review, and every 30 minutes. Rules: merge policy · labels. |
1 similar comment
|
Merge readiness at
Areas: Updated by pr-readiness on every push, edit and review, and every 30 minutes. Rules: merge policy · labels. |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Code review of head 1. Unread
|
Brings the G14 firmware 27.2 recovery up to main 255761f (the source of the m2combo22 kit): pool slot double buffers with the publish-only flip and cursor re-advance (#3182), compute sampler heaps (#3198), the pool stall report and the deep-sleep warm restart. Conflicts were additive: State keeps both the recovery fields and hardware_unreachable/commit_stop, the ABI file keeps both the recovery records and the Globals/compute/pool helpers with both test sets, and run-host-tests.py runs both g14-v27-2-abi-tests.rs and pmp-alloc-tests.rs. Stopped commands keep #3182's slot rule: their slot is retired the normal way, and its next command goes to the slot's other buffer, so the stopped command stays intact until the firmware unlinks the slot again. Signed-off-by: Ryan Murray <[email protected]>
A command the firmware stopped in a recovery left its queue without a completion stamp. That proves queue progress, not that the GPU no longer reaches its memory, so its VM job guard must not be released. But quarantine() took the flight off rendering/inflight and forgot it. The packet then no longer counted as owned, and a later withdraw() from the scheduler's timeout or cancel path, or fail_all(), could release its guard and let the client's mappings change under the firmware. Track kept work in the runtime instead. blame() adds the packet to State::kept before anything is marked, and the stopped flights, with their VM binding and scene, go to State::kept_flights when they leave the queue. owns() now covers kept packets, so withdraw(), fail_all() and fail_publication() leave the guard alone. fail_doomed() asks only whether a queue still holds the packet. stop() already keeps the whole state for the boot. kept has QUARANTINE_LIMIT (31) places, allocated at start, so keeping a packet never allocates. Each kept packet pins its VM's user UAT context, so the limit is half of the 63 user contexts. Once it is reached, blame() fails and the recovery takes the fail-all path, which keeps all published work owned. The storm window limits the rate of recoveries but not the total, so a slow trickle of stopped work could otherwise use up every context. Signed-off-by: Ryan Murray <[email protected]>
The firmware posts a fault or timeout record on the event ring and then opens its recovery round (phase 1). The host can answer a round before it reads that record: a further round opened while stopped work drained, or a round the command timeout found at phase 1. The record then stays in the ring. The next service pass read it, waited 50 ms for a phase 1 that never came, and failed all work. One recovered fault could so take down every client a moment later. Keep a ledger of reports read and rounds answered (g14_v27_2_abi::RecoveryLedger). recover() returns Ok(false) when no round opens. The service then consumes a report whose round was already answered, with a warning, and keeps the fail-all only for a report that has no round. Records read in one pass count as one report, so a fault and a timeout for the same stop do not look like two. recover() also starts from the last generation answered, so a round the host already answered is never answered again. Signed-off-by: Ryan Murray <[email protected]>
A J473 row has to tell a firmware-reported stop from a silent hang. Up
to now a round logged up to eight snapshot lines and a separate blame
line, and the command timeout log had no recovery words at all.
Each round now logs one warning with the error, the slot the event
named, the last event ring kinds, the snapshot ({flags, target} in hex,
the first four entries and the count), and the blamed client with its
stamps (compute: the stopped command's stamp and the queue's current
stamp; render: the tiler and fragment stamps). log_timeout() also
prints the recovery generation, phase and snapshot, so every command
timeout and recovery failure shows the control words at that moment.
peek_event() now returns the raw kind word for the event history.
Signed-off-by: Ryan Murray <[email protected]>
… round The driver's 5 s command timeout is a backstop for the firmware's own recovery, but it still acted alone. The compute path answered a round open at phase 1 only when the front command was not blamed yet, and the render path only when the render was not stopped. Recovery also restarted the clocks of queued compute work but not of the render in flight. So a render that waited out a round for another client could reach the timeout and fail every client. Ask the firmware first, in both paths (g14_v27_2_abi:: command_timeout_action). With a round open, recover: the snapshot names the stopped command by stamp (stopped_compute(), which never names a retired command), only that client fails, and the others' work resumes after phase 0 with its clock restarted. Only with no round open, a silent hang, does the timeout still fail all work. It then logs the queue positions, the recovery generation, phase and snapshot, the MMU fault status, the last event ring kinds and the report and round counts, so a row tells a silent hang from a missed report. sleep_prepare() also refuses while the firmware has a round open, so no round crosses a system sleep. Signed-off-by: Ryan Murray <[email protected]>
Keeping a stopped flight used KVec::push(), which drops the value when the allocation fails. That would release the flight's VM binding and scene while the firmware may still reach them. Reserve the place first and leak the flight if that fails. Its packet is kept either way, so the client's guard stays. Keep compute and render flights in two lists instead of one enum. A RenderFlight is much larger than an Inflight, so the enum would have made every kept compute flight as large as a render one. Signed-off-by: Ryan Murray <[email protected]>
After a recovery round, the host waited for every command of the guilty packet to leave the queue within RECOVERY_DRAIN_MS. Only the command the snapshot named was stopped: the packet's later commands run normally. A hung client usually has several dispatches queued, and if one of them also runs past the drain budget, the round ended in "stopped work did not leave the queue" and failed every client, which is what the recovery is there to avoid. Wait for the stopped command only. The packet's later commands are already marked and are failed as they retire; if one of them hangs too, the firmware stops it in a round of its own. Signed-off-by: Ryan Murray <[email protected]>
The recovery ledger keeps the last answered generation and refuses a round that repeats it. After a deep-sleep warm restart the firmware may count generations from its start again, so the first real round after wake could be refused with EPROTO and fail all work. No round can cross a sleep (sleep_prepare refuses while one is open), so start the ledger afresh once the firmware is back. Signed-off-by: Ryan Murray <[email protected]>
|
Both blockers from the 11-25 review are addressed at
Also from an independent review of the merge: the drain now waits only for the command the firmware stopped ( J473 rows at |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: approve at fa824cfae022. Both blockers from my earlier review are fixed, so I'm dismissing it.
Blocker 1 (a stopped flight could lose its VM job guard): fixed in d39ba214 and c49b2ded.
blame()now callsreserve_kept()before it marks anything. The packet goes intoState::kept, which is allocated withQUARANTINE_LIMITplaces at start, so keeping it never allocates.owns()counts kept packets, sowithdraw(),fail_all()andfail_publication()can no longer release a stopped packet's guard.fail_publication()checksguard_releasable(false, kept). The stopped flight itself goes tokept_compute/kept_renders. If that push can't allocate, the flight is leaked withmem::forget, so it is never dropped.- At the limit,
reserve_kept()returnsEIOand the caller fails all work, with published work still owned. - The host test
a_withdrawn_stopped_packet_keeps_its_guardcovers it.
Blocker 2 (unread Fault/Timeout records brick the GPU): fixed in 5d3c9dc9.
RecoveryLedgercounts one report perprocess_events()pass and records each answered generation.recover()starts from the last round already answered and returnsOk(false)when no round opens. A report whose round was already answered is then consumed with a warning instead of failing all work.- A missing later round inside a recovery is still
EPROTO. - The command-timeout path retires the render only when a round actually happened.
- Host tests cover a report read before, during and after its round.
Also checked
2213f981: the drain now waits only for the stopped command.fa824cfa: the ledger and window are reset across a warm restart.- Shared drm/asahi files: the only changes there are new helpers,
Scene::clear_tpcinbuffer.rsand the zero-prefix helper inobject.rs. Only the G14 27.2 runtime calls them, so other generations don't change and no second-generation row is needed. - J473 rows at this head:
- 3 deliberate compute hangs, each recovered per client, with the bystander, gnome-shell and fresh clients unaffected;
- GB6 Vulkan 8/8 and compute 48/48;
- s2idle followed by fresh Vulkan.
- CI and commits: CI is green at this head, main was merged in with a merge commit (no force-push), and every commit is signed off.
Not blocking: as the PR body says, the silent compute.heavy stall (no event, phase 0) still fails all work.
Merging is left to the PR Merge Lane.
Superseded by the review at fa824cf
|
Correction to the Evidence and Not yet sections: the trigger is not a fresh shader compile.
So it is the clock-raise class from #3075, still open for a max-ALU ramp after #3162. Not yet item 1 is unchanged in effect: the stall posts no recovery round, so this PR still cannot contain it per client. The fix belongs in the 27.2 power/perf init and is tracked outside this PR. |
What: When a command runs past its allowance or faults, the G14 firmware 27.2 reports it on the event ring (kind 4 timeout, kind 0 fault) and stops every queue until the host answers its recovery handshake: generation +0x4bf0, phase +0x4c00 (1 -> 2 -> 3 -> 0), snapshot of the stopped work at +0x4298. Main ignores both events. One stuck command therefore stops the GPU, and after 5 s the host fails the whole runtime: every client, gnome-shell included, gets EIO until reboot, even after s2idle. This change answers the handshake and fails only the client that owns the stopped command. The other clients keep running. The 5 s host timeout still fails everything, but only when the firmware has no recovery round open, and it now logs the recovery words and the last event kinds first.
This revision merges main (#3182 pool slots, #3198 samplers, deep-sleep warm restart) and fixes Dj's two blockers:
withdraw()can no longer release its job guard.Tested: J473 (M2 mini, firmware 27.2) rows, default cmdline, GNOME on both monitors, kernel = main 255761f + this branch:
fa824cfa: deliberate compute hang x3 (GL compute spinning on an atomic) pass: each time the firmware timed it out itself (<0.3 s, event 4), recovery blamed only that client by stamp, answered in 1 ms; a vkcube bystander, gnome-shell (same PID), fresh vulkaninfo/vkcube and a compute.heavy all worked after every hang; 0 fail-all; s2idle + fresh Vulkan after: pass.fa824cfa: Geekbench 6 Vulkan x8 with timestamps and the full clock range pass 8/8 (0 firmware crashes, 0 timeouts), fresh clients pass after.fa824cfa: gpubench compute light/heavy alu/bw, 48 runs, pass, 0 GPU errors, s2idle + fresh Vulkan pass.c49b2ded(before the last two commits): 48/48 compute with a bystander + GB6 Vulkan x8 8/8 pass.Host tests:
run-host-tests.py --only g14-v27-2pass (24 tests, 7 new), m3-runtime 1/1, m3-stamp 3/3, g16 recovery logic 11/11; asahi_core.o and clippy clean in the changed code.Risk: two-way · only Macs running the G14 firmware 27.2 runtime (J473 today). The handshake decisions are G16's existing
g16/recovery/logic.rs, included by path; no g15/g16 file is changed. With no recovery round the behaviour is main's (fail all), now with a log line saying why.Not yet:
compute.heavystall that started this (see Evidence) is a silent firmware stall with no recovery round, so this PR does not contain it per client: it still fails all work, now with a log saying so. Fixing it needs its cause (fresh-compile only, identical program) or a host-started recovery, which neither 27.2 nor G16/M4 has today.Details
State::keptbefore anything is marked;owns()counts kept packets, sowithdraw(),fail_all()andfail_publication()never release their guard. Kept work stays for the boot (at most 31 clients; then fail-all, still owned).RecoveryLedgercounts reports read and rounds answered; a report whose round was already answered is consumed with a warning.submit()refuses it andpump()fails its queued packets.Evidence
Our own traces,
traces/gpu/20261126-m2gpu-heavy/(README) andtraces/gpu/20261124-m2gpu-hang/(H1-H5, the protocol):gpubench-vk compute.heavytimed out and every later client got EIO, even after s2idle (PEER-ROWS batch14,traces/gpu/20261126-peer-rows-batch14-j473/).MESA_SHADER_CACHE_DISABLE=trueit fails again on this branch. The compiled program is identical either way (59 instructions, 21 GPRs, no scratch).