From 6c6c2466ffd6f816af9191ab021457b10f12f67a Mon Sep 17 00:00:00 2001 From: Jonathan Goyvaerts Date: Sat, 28 Nov 2026 21:01:30 -0300 Subject: [PATCH] drm/asahi: g17: discard a collateral blame's render without a lost device A reason-0 restart on G17P names one queue, and the firmware picks it without knowing whose work hangs the GPU. Since bb68e8865c8bd 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 --- drivers/gpu/drm/asahi/g17/recovery.rs | 93 +++++++++++++------ .../drm/asahi/g17/runtime/render/settle.rs | 6 +- 2 files changed, 70 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/asahi/g17/recovery.rs b/drivers/gpu/drm/asahi/g17/recovery.rs index 51a92a0581cda..58589ce6cf490 100644 --- a/drivers/gpu/drm/asahi/g17/recovery.rs +++ b/drivers/gpu/drm/asahi/g17/recovery.rs @@ -392,7 +392,7 @@ pub(super) fn service( report_clients(host, request.generation, &entries, request.blamed); let (listed, exact, fallback) = (entries.listed, entries.exact, entries.fallback); - let (cancelled, blame, leftover, charged) = + let (cancelled, blamed_error, leftover, charged) = classify(host, entries, request.blamed, attribution, request.generation); if listed != 0 && host.is_m5() { // The M5 table only classifies (read_entries): each command is retired from its own @@ -414,10 +414,14 @@ pub(super) fn service( "G17: GPU recovery (reason {:?}): firmware blamed queue {}, {}\n", sources.firmware_reason(), qid, - if blame { "failing its oldest render" } else { "attribution cleared it; spared" } + match blamed_error { + None => "attribution cleared it; spared", + Some(error) if error == EIO => "failing its oldest render", + Some(_) => "unconfirmed: discarding its oldest render", + } ); - if blame { - host.settle_blamed_render(qid, EIO); + if let Some(error) = blamed_error { + host.settle_blamed_render(qid, error); } } if cancelled != 0 { @@ -515,9 +519,12 @@ fn read_entries(host: &mut H) -> Entries { /// that landed on a starved bystander would leave the real culprit's spared work immune: never /// guilty, never poisoned, never forgiven and never killed, until the restart storm limit /// (2026-11-19 19:12 UTC, 2026-11-20 15:03 UTC). -/// Also returns whether the firmware's blamed QID is still guilty after attribution: a blamed -/// render that had not started while others had (or with no culprit at all) is innocent, and its -/// work is spared like that of every other innocent VM instead of failing with EIO. +/// Also returns the error the firmware's blamed render fails with. None when attribution cleared +/// it: a blamed render that had not started while others had (or with no culprit at all) is +/// innocent, and its work is spared like that of every other innocent VM. ECANCELED when the +/// blame is collateral: the render is discarded and never replayed, and, as for every command a +/// recovery discards, its client is not told (`Completion::report`), so a bystander blamed once +/// keeps its device. EIO when evidence or a repeat confirms the blame, or ownership is unknown. /// Then whether every guilty VM had failed before this restart and it dropped one of their /// commands: a failed VM publishes nothing new, so such restarts end with its queued work. /// Last, whether the restart is charged to the guilty VMs ([`VmStatus::charge_restart`], with @@ -530,7 +537,7 @@ fn classify( blamed: Option, attribution: Attribution, generation: u64, -) -> (u128, bool, bool, bool) { +) -> (u128, Option, bool, bool) { let mut guilty_qids = entries.guilty | blamed.map_or(0, |qid| 1u128 << qid); let cancelled = entries.cancelled; match attribution { @@ -544,9 +551,12 @@ fn classify( // 01:46 UTC, m4.179: t3code, then Hyprland), and a slow innocent render can be the oldest // running one, so the first such blame is collateral and only a repeat makes the VM guilty. let unconfirmed = matches!(attribution, Attribution::Firmware | Attribution::Suspects(_)); - let blame = blamed.is_some_and(|qid| guilty_qids & (1u128 << qid) != 0); + let blamed_error = |collateral: u128| { + blamed.filter(|&qid| guilty_qids & (1u128 << qid) != 0) + .map(|qid| if collateral & (1u128 << qid) != 0 { ECANCELED } else { EIO }) + }; if guilty_qids == 0 && !no_culprit { - return (0, blame, false, false); + return (0, blamed_error(0), false, false); } let mut guilty: [Option>; MAX_GUILTY_VMS] = Default::default(); let mut count = 0; @@ -595,7 +605,7 @@ fn classify( } } if unresolved || (count == 0 && collateral == 0 && !no_culprit) { - return (0, blame, false, false); + return (0, blamed_error(0), false, false); } for qid in (0..QIDS).filter(|qid| collateral & (1u128 << qid) != 0) { queues.note_collateral(qid, generation); @@ -635,7 +645,7 @@ fn classify( let charged = count != 0 && guilty[..count].iter().zip(&held).fold(true, |charged, (status, held)| { status.as_ref().is_some_and(|status| status.charge_restart(held.get())) && charged }); - (cancelled & !(guilty_qids & !collateral) & spared, blame, leftover, charged) + (cancelled & !(guilty_qids & !collateral) & spared, blamed_error(collateral), leftover, charged) } @@ -947,8 +957,9 @@ mod tests { /// last recovery gave its work (`Pair::classify`) and its collateral mark /// (`Pair::note_collateral`), which a retirement of its work clears. A blamed render fails as /// `settle_blamed_render` fails it: guilty work poisons its VM, work an earlier recovery - /// spared fails without poisoning it (`Completion::poisons`), and work that failed already - /// is not failed again. + /// spared fails without poisoning it (`Completion::poisons`) and, discarded as collateral, + /// without reaching its client (`Completion::report`), and work that failed already is not + /// failed again. struct Cascade([Option; 4], u64); impl Cascade { @@ -1002,8 +1013,12 @@ mod tests { let entries = Entries { exact_qids: dropped, ..Entries::default() }; self.1 += 1; let generation = self.1; - let (_, blame, leftover, _) = classify(self, entries, Some(blamed), attribution, generation); - // The listed commands fail: a guilty VM's poison it, others' are discarded. + let (_, blamed_error, leftover, _) = classify(self, entries, Some(blamed), attribution, generation); + // The blamed render fails first, inside `service`; the listed commands fail after the + // firmware resumes: a guilty VM's poison it, others' are discarded. + if let Some(error) = blamed_error { + self.settle_blamed_render(blamed, error); + } for pair in self.0.iter_mut().flatten() { if !pair.failed && pair.qids.iter().any(|qid| dropped & (1u128 << qid) != 0) { if pair.class == Some(Class::Guilty) { @@ -1012,9 +1027,6 @@ mod tests { pair.failed = true; } } - if blame { - self.settle_blamed_render(blamed, EIO); - } leftover } } @@ -1058,7 +1070,10 @@ mod tests { } pair.failed = true; if pair.class == Some(Class::Spared) { - pair.status.report_failure(error); + // A discarded command stays out of the status, as `Completion::report` keeps it. + if error != ECANCELED { + pair.status.report_failure(error); + } } else { pair.class = Some(Class::Guilty); pair.status.record(error); @@ -1109,16 +1124,17 @@ mod tests { queues.restart(41, 1 << 41); assert!(c.recovery_guilty()); queues.restart(45, 1 << 45); - assert!(!b.recovery_guilty() && b.get() == 0); + assert!(!b.recovery_guilty() && b.get() == 0 && b.reported_error() == 0); // b's next command retires: blamed again, it is collateral again, its VM unpoisoned. queues.retire(44); queues.restart(45, 1 << 45); - assert!(!b.recovery_guilty() && b.get() == 0); - // Blamed a third time with nothing retired since: guilty. Its client already saw a - // lost device at each blame; now its VM is poisoned too. + assert!(!b.recovery_guilty() && b.get() == 0 && b.reported_error() == 0); + // Blamed a third time with nothing retired since: guilty. Only now does its client see + // a lost device, and its VM is poisoned. queues.restart(45, 1 << 45); assert!(b.recovery_guilty()); assert_ne!(b.get(), 0); + assert_ne!(b.reported_error(), 0); } #[test] @@ -1276,11 +1292,36 @@ mod tests { counted += usize::from(!queues.restart(101, 1 << 101)); assert!(deqp.recovery_guilty() && deqp.get() != 0); assert!(queues.restart(101, 1 << 101)); - assert!(!t3code.recovery_guilty() && t3code.get() == 0); - assert!(!hyprland.recovery_guilty() && hyprland.get() == 0); + assert!(!t3code.recovery_guilty() && t3code.get() == 0 && t3code.reported_error() == 0); + assert!(!hyprland.recovery_guilty() && hyprland.get() == 0 && hyprland.reported_error() == 0); assert_eq!(counted, 4); } + #[test] + fn the_m4_201_gen_8_bystander_keeps_its_device() { + // 2026-11-28 23:46:02 UTC (m4.201, storm chain, gen 8, reason 0): deqp-vk's memory_model + // spin (14/15, 32 groups in flight in gens 8 and 9) hangs beside t3code (40/41), + // quickshell (46/47) and other deqp-vk clients. No slot keys, no MMU fault, and the + // oldest running render had other VMs' compute beside it, so only the firmware named a + // queue: t3code's 41, whose tiler had started, flagged guilty and cancelled. Its oldest + // render failed with EIO and t3code saw a lost device. Gen 9 then blamed deqp-vk's 11. + let (deqp, t3code, quickshell, other) = (vm(), vm(), vm(), vm()); + let mut queues = + Cascade::new([([14, 15], &deqp), ([40, 41], &t3code), ([46, 47], &quickshell), ([10, 11], &other)]); + queues.restart(41, (1 << 15) | (1 << 41) | (1 << 47) | (1 << 11)); + // The blamed render is discarded, never replayed, and t3code keeps its device. + assert!(!t3code.recovery_guilty() && t3code.get() == 0 && t3code.reported_error() == 0); + queues.submit(40); + queues.restart(11, (1 << 15) | (1 << 11)); + assert!(!other.recovery_guilty() && other.get() == 0 && other.reported_error() == 0); + assert!(t3code.reported_error() == 0 && quickshell.reported_error() == 0); + // The mark stays: blamed again with nothing of it retired, t3code's VM is guilty and + // its client is told. + queues.restart(41, 1 << 41); + assert!(t3code.recovery_guilty()); + assert_ne!(t3code.reported_error(), 0); + } + #[test] fn unknown_25g83_keys_still_preserve_firmware_blame() { let mut host = Halted::new(false); diff --git a/drivers/gpu/drm/asahi/g17/runtime/render/settle.rs b/drivers/gpu/drm/asahi/g17/runtime/render/settle.rs index 2b45a4ab8e390..32f99d533d872 100644 --- a/drivers/gpu/drm/asahi/g17/runtime/render/settle.rs +++ b/drivers/gpu/drm/asahi/g17/runtime/render/settle.rs @@ -147,9 +147,9 @@ impl crate::g17::Firmware { .and_then(|pair| pair.oldest_packet()); if let Some(packet) = packet { // Unclassified work counts as innocent, and a blamed group must never be replayed. - // Work an earlier recovery spared is collateral here (classify() blames before its - // collateral check) and stays spared, so its failure stays non-sticky; the blame - // itself is recorded apart from the class, and refuses any replay of it. + // Collateral work stays spared: its failure stays non-sticky, and with ECANCELED + // (`recovery::classify`) its client is not told. The blame itself is recorded apart + // from the class, and refuses any replay of it. packet.completion.note_blamed(); if !packet.completion.spared() { packet.completion.classify(crate::g17::recovery::Class::Guilty);