Skip to content

drm/asahi: g17: discard a collateral blame's render without a lost device - #3573

Merged
RyanTheTide merged 1 commit into
aurora-silicon:mainfrom
jgoyvaerts:m4pro/g17-collateral-blame-keeps-device
Dec 5, 2026
Merged

RyanTheTide merged 1 commit into
aurora-silicon:mainfrom
jgoyvaerts:m4pro/g17-collateral-blame-keeps-device

Conversation

@jgoyvaerts

@jgoyvaerts jgoyvaerts commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

What: A G17P restart whose blame only the firmware gives (no slot keys, no latched MMU fault, no pass record that names the VM) is collateral the first time, so the VM is not found guilty. But the blamed render still failed with EIO. A spared command's EIO reaches the VM status, and Borealis reads that as a lost device, so a desktop client the firmware blamed by mistake lost its device anyway. Now a collateral blame discards that render with ECANCELED, like every other command a recovery discards: it is never replayed, and its client is not told. Confirmed blame, a repeat, and blame on work whose owner can't be resolved still fail with EIO.
Tested: J616s M4 Pro (14-core, 16K pages), on test kernel 7.3.0-m4.202 with this change backported onto main a851ca0 as 05b8830f2d65, not the exact head: the #2504 memory_model spin beside the live desktop, 29 recoveries, 7 unconfirmed firmware blames each logged "unconfirmed: discarding its oldest render", 0 desktop clients lost their device before an unrelated firmware crash 4 min in (result). QEMU arm64 KUnit (asahi kunitconfig) at 6c6c246: 929 run, 928 pass, 1 skip, 0 fail. tools/asahi host tests: no g17 failures (29 failure lines, all outside g17, same as on the base). A mutation that puts collateral back to EIO fails 3 cases: the new gen-8 case, the m4.179 case and the retiring-bystander case.
Risk: two-way door · M4 and M5 (the shared G17 recovery classify/service path). A real culprit that is blamed first without evidence now keeps submitting until its second blame, which costs one more restart. bb68e88 already counted on that restart. An echo blame can still cost a bystander its device: the firmware blames a pair again for its own already-failed, pre-discard groups, and the repeat rule takes that as confirmation (1 of 41 repeat poisons in the m4.205 storm run, a desktop chromium process).
Not yet: a hardware run at the exact head on current main. Not run on M5. The echo case is not fixed: in the m4.205 storm run, chromium's pair was blamed at two reason-3 restarts 123 ms apart, both firmware-only. The second blame landed on a group already queued (and already failed) at the first, so the repeat rule poisoned the VM and chromium lost its device. The root fix is being researched: stop the firmware running a pair's already-failed groups after a collateral discard. Until then this PR keeps today's repeat rule. A root fix for the echo is being probed on the M4 Pro: whether its firmware can be stopped from running a pair's already-failed groups. A repeat rule that counts only newer work waits for that probe and ships only with a working fix.

Details

classify() worked out whether the blamed QID was guilty before its collateral check. So service() called settle_blamed_render(qid, EIO) even when the blame was collateral. The packet is Spared, so fail_while_owned → !discarded(EIO) → VmStatus::report_failure(EIO), which writes the status word the client reads.

classify() now returns the error for the blamed render:

  • None: attribution cleared it (unchanged);
  • ECANCELED: the blame is collateral. settle_blamed_render still marks the packet blamed (no replay) and fails it through the same path settle_cancelled_renders uses for spared cancelled work;
  • EIO: evidence, a repeat or an earlier guilt confirms the blame, or ownership is unresolved.

The collateral mark and the repeat rule (note_collateral/collateral_before) are unchanged: a pair blamed again before any of its work retires still makes its VM guilty, and only then is its client told.

The decision uses only what the firmware and GPU report (slot keys, MMU fault banks, pass records, the recovery table), plus the host's own record of earlier blames. No chip, board or process-name gates.

The Cascade test stand-in now fails the blamed render before the listed commands, as service() does, and keeps a discarded command out of the status as Completion::report does.

Evidence

The case, from the kernel log of one recovery (reason 0) during a dEQP-VK run beside a desktop:

  • slot_mask 0x10000, sampled 0, known_keys 0; both MMU fault banks clear.
  • The firmware blamed queue 41, a desktop client's render pair (40/41). Its front render had its tiler start written and its fragment end unwritten. The table record for 41 was 0x297 (GUILTY|CANCELLED); the other 17 records were valid only.
  • No "blames queues" or "suspects queues" line, so attribution was Firmware. render_culprit returned None because other VMs' compute was in flight.
  • deqp-vk's memory_model spin (dEQP-VK.memory_model.write_after_read.ext.u64.coherent.atomic_atomic.atomicrmw.queuefamily.payload_local.image.guard_local.physbuffer.frag) held 32 groups on its queue in this restart and the next one. The next restart blamed another deqp-vk client, and the spin case passed.
  • Log: firmware blamed queue 41, failing its oldest render, then GPU work of a client failed (EIO, reported at g17/completion.rs:1064, client …); the client sees a lost device.

New KUnit case: asahi_g17_recovery_snapshot.the_m4_201_gen_8_bystander_keeps_its_device.

KUnit (QEMU arm64, asahi kunitconfig), 6c6c2466ffd6: Ran 929 tests: passed: 928, skipped: 1
mutation `{ ECANCELED } else { EIO }` -> `{ EIO } else { EIO }`: Ran 19 tests: passed: 16, failed: 3
  a_bystander_that_retires_between_blames_stays_collateral
  the_m4_179_bystander_blames_poison_only_the_culprit
  the_m4_201_gen_8_bystander_keeps_its_device

…vice

A reason-0 restart on G17P names one queue, and the firmware picks it
without knowing whose work hangs the GPU. Since bb68e88 a blame
that no evidence confirms (no slot keys, no latched MMU fault, no pass
record that names the VM) is collateral the first time: the VM is not
found guilty and only a repeat before any of the pair's work retires
makes it so. That commit meant the bystander to keep its device. It
did not: service() still failed the blamed render with EIO, and a
spared command's EIO reaches the VM status (Completion::report), which
Borealis reads as a lost device.

On the J616s (m4.201, 2026-11-28 23:46:02 UTC, storm chain, gen 8)
deqp-vk's memory_model spin held 32 groups on its pair through gens 8
and 9. The firmware blamed t3code's queue 41, whose tiler had started.
The keys read 0 and the oldest running render had other VMs' compute
beside it, so nothing confirmed or moved the blame. t3code's VM stayed
innocent, as designed, but its oldest render failed with EIO and
t3code lost its device. Gen 9 blamed another deqp-vk client.

Have classify() return the error for the blamed render. Collateral
blame fails it with ECANCELED, the error of every other command a
recovery discards: it is still never replayed (note_blamed), and its
client is not told. Confirmed blame, a repeat, and blame on work whose
owner cannot be resolved still fail it with EIO. The recovery log says
"unconfirmed: discarding its oldest render" for the collateral case.

A real culprit blamed first, without evidence, now keeps submitting
until its second blame. The commit above already counted on that extra
restart; now it actually happens.

The test stand-in now keeps a discarded command out of the status as
Completion::report does. A new case replays gen 8 and checks that
t3code keeps its device and turns guilty on a repeat. The bystander
cases now also check that the client is not told. Without the change,
the new case and the m4.179 and retiring-bystander cases fail.

Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
@jgoyvaerts

Copy link
Copy Markdown
Contributor Author

J616s (M4 Pro): the bystander case passes, up to an unrelated firmware crash.

Kernel: our test kernel 7.3.0-m4.202. It carries this PR as 05b8830f2d65, a backport of head 6c6c2466ffd6 onto main a851ca0edfc9 plus our carried patches. It is not a build of the exact head.

Run: 2026-11-29 03:30:23-03:34:15 UTC, as one guarded chain. The #2504 memory_model spin case ran about every 10 s beside the live desktop (Hyprland, quickshell, a chromium-based app, a browser).

Results:

  • 29 GPU recoveries, all reason 0.
  • 7 times the firmware blamed a queue that attribution could not confirm. Each logged "firmware blamed queue N, unconfirmed: discarding its oldest render".
  • 0 desktop clients lost their device. All 4 client failures were the deqp-vk test processes.

On m4.201 without this change, the same chain lost a desktop client at its first unconfirmed blame (gen 8, 22 s in).

Caveat: the chain did not finish cleanly. 4 minutes in, the firmware crashed (agx_scheduler) 46 ms after a compute-exit kill of a context whose render pair held guilty work. That crash belongs to a separate firmware-crash investigation, not to this change. Every client, Hyprland included, lost its device at the crash itself, as with any firmware crash. So "no lost device after an unconfirmed blame" is shown for the 4 minutes before the crash, not for a full run.

@jgoyvaerts

Copy link
Copy Markdown
Contributor Author

m4.205 storm run (J616s M4 Pro, three dq-fast passes plus the #2504 memory_model spin, 493 recoveries): I classified every repeat that poisoned a VM. A repeat is an echo when the firmware's guilty record names a render the pair had already published at the earlier, unconfirmed discard. It is new work when the render was published after the discard.

  • 41 repeat poisons (recovery.rs:628): 13 echoes, 20 new work, 8 unclassified (no guilty record for the blamed queue).
  • Echoes: 1 desktop client (chromium, two reason-3 restarts 123 ms apart on the same 4 already-failed renders; it lost its device) and 12 deqp-vk hangers (10 of them with 32 groups queued).
  • So most hangers are caught by an echo too. Sparing echoes alone would let a spinner with queued groups cause up to about 31 more restarts. That is why this PR keeps today's repeat rule. The root fix being looked at instead is to stop the firmware running a pair's already-failed groups after a collateral discard, so every later blame lands on new work.

@jgoyvaerts
jgoyvaerts marked this pull request as ready for review December 4, 2026 02:30
@jgoyvaerts
jgoyvaerts requested review from a team and DjDeveloperr as code owners December 4, 2026 02:30
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Merge readiness at 6c6c2466: not ready yet

Check Detail
CI at head ok 23 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 6c6c2466
Conflicts ok none
PR text ok Risk: two-way · M4 and M5 (the shared G17 recovery classify/service path). A real culprit that is blamed first without evidence now keeps submitting until its second blame, which costs one more restart. bb68e88 already counted on that restart. An echo blame can still cost a bystander its device: the firmware blames a pair again for its own already-failed, pre-discard groups, and the repeat rule takes that as confirmation (1 of 41 repeat poisons in the m4.205 storm run, a desktop chromium process).

Areas: area:gpu

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 6c6c246 on code.

Checked:

  • The recovery classifier uses ECANCELED for a collateral discard. Explicit, corroborated, repeated or unresolved blame retains the existing EIO handling.
  • The settlement path clears the replay flag for discarded work. Completion of that work keeps the spared VM usable and preserves device-lost reporting for actual hangs.
  • The exact-head host and Apple/KUnit checks passed.

Follow-ups:

  • Track a repeat blame for render work already discarded in #4369.

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving under the merge gate: the App review passed at 6c6c2466 (adversarial pass by a non-author lane), the real CI is green at this head, and there's a hardware row at this head.

@RyanTheTide
RyanTheTide merged commit af2bad9 into aurora-silicon:main Dec 5, 2026
45 of 47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants