Skip to content

drm/asahi: g16: fall back to extended render tiers when tier-0 slots are quarantined - #4185

Merged
DjDeveloperr merged 1 commit into
mainfrom
fix/g16-render-tier-quarantine-fallback
Dec 3, 2026
Merged

DjDeveloperr merged 1 commit into
mainfrom
fix/g16-render-tier-quarantine-fallback

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

What: After enough firmware recoveries quarantine render pass slots 0 to 7, every new single-pass render client fails with ECANCELED, although slots 8 to 47 have free slots. A fresh VM only learns "a base slot is quarantined" (one bit), backs Tier 0 (slots 0..8), and the engine then finds nothing in those slots it could ever claim. Pass the mask of quarantined render slots instead, as PB slots already do, and back the smallest tier that has enough slots outside it. See aurora-silicon/mesa#1585.

A faulted slot stays quarantined. The mask is only read; the slot ledger (Lifetime), claim, pick and quarantine code is unchanged. The new test checks at its end that all 8 slots are still quarantined and still refuse a claim.

Tested: J773g (M4 mini, T8132) at this head merged with main: vulkaninfo, gpubench 14 of 14, Vulkan CTS 15 of 15, 0 quarantined slots, 0 recoveries (row). J516s (M3 Pro, T6030) at this head: 0 recoveries and 0 quarantined slots after 113k+ CTS cases (row). Host tests (failing before, passing after) and the arm64 W=1 build of drivers/gpu/drm/asahi/ pass, also on the merge with main ebfc4f60bdd1 (Evidence).

Risk: two-way · M3, M3 Pro, M4 (the GPUs on the g16 runtime). Nothing changes while no render slot is quarantined.

Not yet: the fallback itself on hardware. It needs at least 8 quarantined render slots; the one J516s attempt hit a firmware fail-stop on its first fault, before any slot was quarantined. So far the fallback has run only in the host tests.

Details

Root cause. Seen on a J516s after 11 recoveries: render_owners: retired 33 quarantined 15 reusable 32, and each new client failing at once.

  • Shared::base_render_quarantined is one AtomicBool, handed to SUBMIT as PrepareHints::expand_render_ext.
  • For a new single-pass VM (active_passes 0, one render) target_render_slots() then wants 3 slots and stops at Tier 0's end, 8.
  • render_exhausted_within(8) is true when nothing in 0..8 can become claimable: all quarantined, or one healthy slot left that nothing can displace. publish_checked() completes the job with ECANCELED. Every later SUBMIT does the same, as the VM never grows.

The change.

  • quarantined_render_mask (u64, RENDER_SLOTS is 48) replaces the bit, from Lifetime::quarantined_mask(), which now covers 64 owners instead of 32. The compute mask is unchanged (24 units).
  • target_render_slots_for() counts only slots outside the mask against live passes + this submission + one displacement slot, and takes the smallest tier that covers them (skip_quarantined_render_slots()). Two such slots always make progress: once the engine drains, the older of two retired owners is displaced.
  • If no tier covers the need, it takes the one with the most healthy slots and never grows into a tier that adds none, so a GPU with every slot quarantined doesn't back 158 MiB for a job that is about to fail with the class error (render_exhausted()), as today.
  • The same counting helps multi-pass VMs: ten passes with 8 of 18 slots quarantined now back 32.
  • single_vm_target is computed as before, so a fallback tier alone doesn't grow the PB heap to 256 MiB.

Cost. A VM that falls back to Tier 1 backs Tiers 0 and 1 (55 MiB): the slots are contiguous, so the quarantined Tier 0 slots get storage they won't use. Only after Tier 0 has been used up by recoveries.

Limits. A job that was accepted before the recovery and holds only exhausted slots is still cancelled; the next SUBMIT of that VM grows. Storage growth stays best effort: if its allocation fails, the job fails as before. This does not address what causes the recoveries.

Evidence

Head cc7c4893660fed0a015c8f5e09f5f216b754a798 on a05d99c9dbc2 (main has moved 10 commits since, none in these files).

Merge with main ebfc4f60bdd1 (tree 854b8bcafc56; its g16/ is the same as in the J773g kernel's merge 8967201e3ddf): asahi-m4 26 of 26 scripts (test-resources 100 passed), g16 2 of 2, g15 19 of 19 and m3-recovery 2 of 2 in the hosted-CI image; arm64 LLVM=1 W=1 drivers/gpu/drm/asahi/ (G15 and G16 on) builds with the same 38 warnings as main.

Host tests, asahi-m4/test-resources.py (compiles the production slot ledger and tier code), in the hosted-CI image (ubuntu 24.04, rust 1.96.0):

source result
main a05d99c9dbc2 + the new tests (calling its 1-bit hint) 98 passed, 1 failed: quarantined_tier0_backs_a_fresh_vm_from_a_higher_tier: "a fresh VM backs 8 slots, all quarantined: ECANCELED"
this PR 100 passed, 0 failed
this PR without the fallback 98 passed, 2 failed (same message)
this PR, any one healthy slot counted as enough 99 passed, 1 failed
  • quarantined_tier0_backs_a_fresh_vm_from_a_higher_tier: publishes and quarantines slots 0..8, prepares a fresh single-pass VM, checks it backs 18 slots, renders 54 times from slots 8..18 only, and that slots 0..8 are still quarantined and refuse a claim.
  • render_tiers_count_only_slots_outside_quarantine: the tier for partial and full quarantines, multi-pass demand, the 15-slot census, the fewest healthy slots, and no change over every demand without a quarantine.
  • all_render_slots_quarantined_stays_exhausted: all 48 quarantined stays exhausted, with nothing to pick (passes before and after).

tools/asahi/run-host-tests.py --only: asahi-m4 1/1 (the whole suite), g16 2/2, g15-display-order 1/1, m3-recovery 2/2.

arm64 LLVM=1 W=1 drivers/gpu/drm/asahi/ (asahi profile, DRM_ASAHI=m, G15 and G16 on, clang 23, rustc 1.100): builds, no new warning. Base and head print the same 39 warnings of that newer toolchain, line for line; asahi_core.o differs between them. checkpatch on the diff: 0 errors, 0 warnings.

…are quarantined

A firmware recovery quarantines the render pass slots of the work it aborts
until the next boot. A fresh VM learns only whether a base slot is
quarantined, one bit, and answers it by backing Tier 0 (slots 0..8). Once
all of those are quarantined too, the engine finds nothing it could ever
claim among the VM's slots and cancels its job (ECANCELED), although
Tiers 1 to 3 (slots 8..48) have free slots. On a J516s with 15 of 48 slots
quarantined and 32 reusable, every new single-pass render client failed that
way.

Give SUBMIT the mask of quarantined render slots instead of the bit, as it
already has for PB slots, and back the smallest tier whose slots outside the
mask cover the live passes, this submission and one displacement slot. Where
no tier covers them, back the one with the most, so a VM never grows into a
tier that has none. Nothing changes while no slot is quarantined, and the PB
heap still follows the VM's own demand.

A quarantined slot stays quarantined: the mask is only read, and the slot
ledger is unchanged.

Signed-off-by: DjDeveloperr <hey@djdev.me>

@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.

The render tier selection counts usable slots across all 48 positions while leaving the quarantine ledger and slot claims alone. The zero-mask path keeps the previous target, and the healthy count cannot choose a smaller tier. The host tests cover an exhausted first tier, mixed masks and full exhaustion. Hardware qualification remains pending.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Independent review of cc7c4893660f by a reviewing agent that didn't write it. No code blocker. Not mergeable yet because no hardware run exists.

Checked

  • A quarantined slot can't be reused. The mask is read-only capacity accounting. Lifetime::available() is false for Quarantined, claim() goes through it, and cancel(), publish_on() and retire() each need a state a quarantined slot can't be in. quarantine() is the only writer of that state and nothing writes it back. The ledger is created once with the firmware object, so its mask starts empty and only grows.
  • The render and compute masks stay apart. They are separate fields (AtomicU64 and AtomicU32) filled from separate ledgers. as u32 on the compute mask loses nothing: 24 units.
  • All three places that quarantine slots publish the new mask afterwards (poll.rs twice, engine.rs once).
  • No quarantine, no change: the new step returns its input for mask 0. A target the VM already has is never lowered.
  • T8132, T6030 and T8122 all use this path (resources.rs has no chip check), so G16 is affected as well as G15.

Run on the merge with main dbfe45ac89b6 (Ubuntu 24.04 CI image): asahi-m4 1/1, g16 2/2. Main's commits since the base touch none of these files, so your arm64 build of this head stands.

Left before merge

  1. J516s (T6030): a run that reaches a quarantined tier 0 (at least 8 quarantined render slots, render_owners in debugfs), then a new single-pass client renders instead of ECANCELED.
  2. J773g (T8132): a no-regression run at this head (gpubench render rows, CTS smoke, render_owners quarantined 0, 0 recoveries). The normal path is shared, so a second generation is owed.
    Small note: the storage for the quarantined Tier 0 is real memory cost (55 MiB) but only after recoveries.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J516s (Apple MacBook Pro 16-inch, M3 Pro, T6030, G15S B1, os-fw 27.2 / 26B123) hardware row attempt at exact head cc7c4893660f (7.3.0-pr4185-gcc7c4893660f, boot_id=62e989e4-e91c-4673-9f66-0bb55659bf59): INCONCLUSIVE (did not reach >= 8 quarantined render slots).

  • Pre-fault state: recoveries=0, render_owners quarantined=0, compute_owners quarantined=0, render_failed=0 (clean boot after 113k+ CTS cases passed with 0 recoveries).
  • What happened on the very first fault-injection case (dEQP-VK.synchronization2.op.multi_queue.binary_semaphore.write_image_tess_eval_read_copy_image.image_64x64x8_r32_sfloat_exclusive, Tier 0 render pair 0 TA 0x1e5d200/0x1e5d300, before any slot was quarantined):
    • G16: fault_scan: GPU powered down (event=0x70, flights=1)
    • fwlog[3] seq=2: ERROR: PIO poll from agfGCPMSUpdateDashboard timeout after 250us [type:34 reg:0xd10080 expected:0x0 got:0x3 max:250us]
    • fwlog[3] seq=3: ERROR: PIO poll from AGFHALWaitForPerfStateCS timeout after 250us [type:39 reg:0xd4c000 expected:0x0 got:0x10 max:250us]
    • M4 GPU recovery exceeded 1000 ms: firmware never published phase 3 (phase 2, 1 flights)
    • G16: fail-stop (ETIMEDOUT): host ceiling S1 -> S1 (3/3 selectors written), temperature 40979 mC
    • G16: fail-stop (ETIMEDOUT); GPU unusable until reboot / [drm] device wedged, needs recovery (followed by EIO teardown across active clients).
  • 41 s after fail-stop: rcu_preempt stall reported CPUs 7 and 10 unresponsive to NMI (After 10 seconds, these CPUS still haven't responded to the NMI: 7 and 10), and the hardware watchdog rebooted the machine cleanly (pstore empty).
  • Status: Because firmware recovery timed out at phase 2 on the first fault (0 slots quarantined -> fail-stop teardown -> NMI-unresponsive CPU hang), the Tier 1–3 fallback path past 8 quarantined render slots was not reached. Needs a base-kernel comparison (without drm/asahi: g16: fall back to extended render tiers when tier-0 slots are quarantined #4185) and a clean retry once the boot queue clears.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Keeping this PR in draft until the two remaining hardware rows run.

What is left before leaving draft

  1. J773g (T8132, G16G, os-fw 27.2 / 26B123) no-regression G16 row at main (2eceb1f24262) + cc7c4893660f: gpubench-vk render/compute/transfer rows (including multi-process render slot pressure) and Vulkan CTS render/blit/compute smoke, verifying render_owners quarantined 0, compute_owners quarantined 0, recoveries 0, and zero GPU/DART faults or kernel warnings (shared normal render-tier path across T8132/T6030/T8122). Queued next.
  2. J516s (T6030, G15S, os-fw 27.2 / 26B123) Tier-1+ fallback row at main (with the T6030 PCIe PWREN fix #4213) + cc7c4893660f: reach >= 8 quarantined render slots (render_owners in aurora-g16/stats) using a recoverable render fault rather than the phase-2 fail-stop case from the earlier inconclusive attempt, then verify a fresh single-pass render client succeeds instead of returning ECANCELED and quarantined slots remain quarantined. Queued after the higher-priority J516s rows.

Merge status

  • Merges cleanly onto current main (2eceb1f24262).
  • Note: overlaps #3340 (a134833c6f92) with a small conflict in drivers/gpu/drm/asahi/g16/slots.rs; if #3340 lands first, this branch will be forward-merged onto main before final verification.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J773g (Apple Mac mini M4, T8132, G16G B0, os-fw 27.2, 24 GB RAM) no-regression hardware row for head cc7c4893660fed0a015c8f5e09f5f216b754a798 (work/linux4185-cc7c4893-j773g-20261203, KIT.sha256 cb573347aa16f1d9effe336798f63df15b3ed72a9ea4e0c1eb43b433bf17daa1):

  • Kernel: 7.3.0-j773g-pr4185, local merge 8967201e3ddfa9ec1423c6c6d1cd3e9f2b7e2f49 (main 2eceb1f24262 + #4185 cc7c4893660f), vmlinux build ID f6161f7a87a84a512efa5730b17c96211b6b45eb, aurora.ko build ID 7158550f0e57f90c262b6d1e329d2591128d5711.
  • HEAD boot: 72ca7d00-9630-47be-ba83-ec916e8f2a49 (unchanged across run; watchdog + dead-man armed and disarmed).
  • Results (results/run1/out-head/summary.txt + pr-post.txt):
    • VULKANINFO rc=0
    • GPUBENCH ok=14 fail=0
    • CTS rc=0 passed=15/15 failed=0/15 not_supported=0/15
    • KLOG gpu=0 warn=0
    • render: count 283293, render_owners: ... quarantined 0 reusable 47, compute_owners: ... quarantined 0 reusable 16, jobs 518799 ... recoveries 0 hang_kills 0 clustered 0, health: failed 0 errno 0 degraded 0
    • TESTS-DONE head
  • Stock restore: verified 7.3.0-j773g-main3685+, boot e941c7e8-65aa-4381-b9ef-9b0f7be3953c, aurora.ko cc310d6ff44e0b19c68a005855cf4a0198858ea7.
  • Verdict: functional PASS (all hardware criteria green; kit judge.py returned INCOMPLETE: CTS line missing solely because its regex on line 94 matches passed=(\d+) without the /15 denominator printed in summary.txt: CTS rc=0 passed=15/15 failed=0/15 not_supported=0/15).

@DjDeveloperr
DjDeveloperr marked this pull request as ready for review December 3, 2026 19:24
@DjDeveloperr
DjDeveloperr requested review from a team as code owners December 3, 2026 19:24
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m3 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) labels Dec 3, 2026
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Merge readiness at cc7c4893: ready to merge

Check Detail
CI at head ok 11 checks passed
Review ok approved by RyanTheTide
Requested changes ok none
Hardware row at head ok comment at cc7c4893
Conflicts ok none
PR text ok Risk: two-way · M3, M3 Pro, M4 (the GPUs on the g16 runtime). Nothing changes while no render slot is quarantined.

Areas: area:gpu
Merge: gh pr merge 4185 --merge (Owners and Core through the bypass: add --admin).

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

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed ci-failing A check failed at the PR head (bot) labels Dec 3, 2026
@DjDeveloperr
DjDeveloperr merged commit 5bb2f1e into main Dec 3, 2026
15 of 16 checks passed
@DjDeveloperr
DjDeveloperr deleted the fix/g16-render-tier-quarantine-fallback branch December 3, 2026 19:25
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Merged as 5bb2f1eed073 (main ebfc4f60bdd1 + cc7c4893660f, tree 854b8bcafc56). I checked that exact tree on pc before the merge:

  • Its drivers/gpu/drm/asahi/g16/ is the same as in 8967201e3ddf, the merge the J773g row ran. Main's 12 commits since then change g14_v27_2.rs and gpu/v27_2.rs only.
  • arm64 make LLVM=1 W=1 drivers/gpu/drm/asahi/ (J773g kit config, G15 and G16 on, clang 23, rustc 1.100): builds. Main and the merge print the same 38 warnings.
  • Host tests in the hosted-CI image (localhost/aurora-linux-host-tests:ubuntu2404, no network): asahi-m4/run-host-tests.py 26 of 26 scripts (test-resources 100 passed), run-host-tests.py --only g16 2 of 2, --only g15 19 of 19, --only m3-recovery 2 of 2.
  • checkpatch.pl --strict: 0 errors, 0 checks, 1 warning (one commit-message line is 76 characters).
  • pr-text (the org script) passes on the updated body.

The body now lists both hardware rows. Still open: the fallback path on hardware (8 or more quarantined render slots on a J516s).

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:m3 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants