Skip to content

drm/asahi: g17: step past owed render stamps and suppress drained timeout heads - #3229

Merged
RyanTheTide merged 1 commit into
aurora-silicon:mainfrom
AxxzyWasTaken:pr/g17-render-owed-stamps
Dec 1, 2026
Merged

RyanTheTide merged 1 commit into
aurora-silicon:mainfrom
AxxzyWasTaken:pr/g17-render-owed-stamps

Conversation

@AxxzyWasTaken

@AxxzyWasTaken AxxzyWasTaken commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What: Fixes two G17 render-pair parity gaps against compute queues when a render group retires on its pass record without completion stamps (Active::stamps_owed) or when a quarantined render pair has already finished executing:

  • Pair::timeout_head() suppression: Skip stamps_owed entries (which never receive a drained_result) and suppress quarantined pairs that satisfy executed_unstamped() or drain_failures >= DRAIN_RETRY_LIMIT, while keeping genuinely pending live or quarantined render groups visible.
  • Step past leading stamps_owed entries across retirement, stamp-wait, recovery, and timeout paths: Add Tracker::get_mut() and filter out stamps_owed entries in retire_front_command(), note_stamp_wait(), stamp_waiting(), expire_stamp_wait(), report_timeout(), oldest_packet(), oldest_spared(), visit_contexts(), classify(), pass_started(), front_untouched(), running_start(), quarantine(), note_interrupted(), and live_unparked(). Keep leading stamps_owed entries popping at index 0 once TA and fragment stamps cover them, keep groups retired behind held entries in FIFO order until predecessors pop, call note_retirement() only when an entry is actually popped or released in release_witnessed(), clear collateral_at and record executed_generation on both stampless and stamp-covered retirements, return Decision::Retire in Backend::defer_timeout() when retirement_queued() is set after scan_renders(), skip retired_held(packet) in render_timeout_decision() / fail_render_packet() / fail_after_observation(), and guard replay_abandoned() against a stamps_owed front.
  • Host tests: Add tools/asahi/g17-render-owed-stamp-tests.py (registered in tools/asahi/run-host-tests.py, with mock fields updated in tools/asahi/g17-quarantine-drain-tests.py) compiling the real driver code with 34 negative-control mutations.

Closes: #2736

Tested: tools/asahi/run-host-tests.py --only g17: 266/266 passed at 5e0770c9ceaa (including g17-render-owed-stamp-tests baseline + all 34 negative-control mutations killed, g17-quarantine-drain-tests 7/7, g17-admission-order-tests 25/25, g17-owner-release-order-tests 1/1, g17-render-return-observe-tests 14/14).

  • Cross-compiled ARCH=arm64 LLVM=1 drivers/gpu/drm/asahi/aurora.o at 5e0770c9ceaa with 0 warnings in touched files.

Not yet: Live G17 hardware stress run (M4 Pro / M4 Max / M5) triggering stampless render retirement behind lagging stamps and recovery classification.

Risk: two-way · G17 Macs (M4 Pro, M4 Max, M5 family)

@AxxzyWasTaken
AxxzyWasTaken requested review from a team and DjDeveloperr as code owners November 26, 2026 10:08
@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) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Merge readiness at 5e0770c9: not ready yet

Check Detail
CI at head ok 21 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 comment at 5e0770c9
Conflicts ok none
PR text ok Risk: two-way · G17 Macs (M4 Pro, M4 Max, M5 family)

Areas: area:gpu

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

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 26, 2026
…eout heads

G17 render pairs still had parity gaps against compute queues when a
group retires on its pass record without completion stamps
(`Active::stamps_owed`) or when a quarantined pair has already finished
executing:

1. `Pair::timeout_head()` only skipped entries with
   `drained_result.is_some()`. A group that retired stampless keeps
   `stamps_owed = true` and never gets a `drained_result`, so it stayed
   advertised as the pair's timeout head (both live and as `failed: true`
   once quarantined). Likewise, a quarantined render pair whose groups
   all executed unstamped (`executed_unstamped()`) or that was parked out
   of service (`drain_failures >= DRAIN_RETRY_LIMIT`) continued reporting
   `failed: true` as a `blocker_failed=1` head to other VMs' watchdogs.

   Skip `stamps_owed` entries in `Pair::timeout_head()` and suppress
   quarantined pairs that satisfy `executed_unstamped()` or
   `drain_failures >= DRAIN_RETRY_LIMIT`, while keeping genuinely pending
   in-flight live or quarantined render groups visible.

2. `Pair::retire_front_command()`, `Pair::note_stamp_wait()`,
   `Pair::stamp_waiting()`, and `Pair::expire_stamp_wait()` only
   inspected `self.active.front()`. Once the front group held
   `stamps_owed = true` waiting for lagging stamps, later groups queued
   behind it on the same pair could neither latch or expire a stamp wait
   nor retire past it. In addition, recovery, replay, binding-lifetime,
   and timeout paths still saw retired `stamps_owed` entries as unretired
   active work:
   - `Pair::oldest_spared()`, `Pair::quarantine()`, `Pair::visit_contexts()`,
     `Pair::classify()`, `Pair::pass_started()`, `Pair::note_interrupted()`,
     `Pair::oldest_packet()`, `Pair::front_untouched()`,
     `Pair::running_start()`, `Pair::report_timeout()`, and
     `Pair::live_unparked()` did not filter out `stamps_owed` entries
     (an all-`stamps_owed` pair reported via `visit_contexts()` caused
     `recovery::classify()` to hit `oldest_spared() == None` and abort
     classification, `pass_started()` could blame an already-completed
     pass, and an exact-stamp match on a `stamps_owed` entry in
     `note_interrupted()` must return `Interrupted::None` without falling
     through to mark a successor).
   - `Pair::retire_front_command()` called `note_retirement()` before
     fallible completion and even on stampless or behind-owed
     retirements, risking releasing `self.previous` before stamps or
     `firmware_drained` proved the first publication was done; it also
     omitted `executed_generation` on stampless retirement even though
     the group executed on the GPU.
   - `Backend::defer_timeout()`, `Registry::render_timeout_decision()`,
     `Firmware::fail_render_packet()`, and `Pair::fail_after_observation()`
     could treat a packet that had just retired stampless (and remained
     held in `Pair::active` as `stamps_owed`) as still unretired, causing
     spurious watchdog give-ups or quarantines of running successors.

   Add `Tracker::get_mut()`, step past leading `stamps_owed` entries in
   `retire_front_command()`, `note_stamp_wait()`, `stamp_waiting()`,
   `expire_stamp_wait()`, `report_timeout()`, `oldest_packet()`,
   `oldest_spared()`, `visit_contexts()`, `classify()`, `pass_started()`,
   `front_untouched()`, `running_start()`, `quarantine()`,
   `note_interrupted()`, and `live_unparked()`, keep leading
   `stamps_owed` entries popping at index 0 once both TA and fragment
   stamps cover them, keep groups retired behind held entries in FIFO
   order until their predecessors pop, call `note_retirement()` only
   after popping index 0 on stamps or releasing `stamps_owed` entries in
   `release_witnessed()`, record `executed_generation` unconditionally on
   stampless retirement too, return `Decision::Retire` in
   `Backend::defer_timeout()` when `retirement_queued()` is set after
   `scan_renders()`, skip `retired_held(packet)` in
   `render_timeout_decision()` / `fail_render_packet()` /
   `fail_after_observation()`, and guard `replay_abandoned()` against a
   `stamps_owed` front.

Add `tools/asahi/g17-render-owed-stamp-tests.py` (registered in
`tools/asahi/run-host-tests.py`, with mock fields updated in
`tools/asahi/g17-quarantine-drain-tests.py`) compiling the real render
retirement, observation, replay, pair, settle, registry, backend, and
timeout policy code with 34 negative-control mutations.

Signed-off-by: AxxzyWasTaken <[email protected]>
@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/g17-render-owed-stamps branch from 3ad6d99 to 5e0770c Compare November 27, 2026 07:11
@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Rebased onto main (fcb124279183) as 5e0770c9ceaa after #2504 merged: adapted running_owner() -> running()/running_start(), preserved self.collateral_at = None on both stampless and stamp-covered retirement paths in retire_front_command(), and updated the g17-render-owed-stamp-tests.py fixture. Re-verified tools/asahi/run-host-tests.py --only g17 (266/266 passed) and ARCH=arm64 LLVM=1 drivers/gpu/drm/asahi/aurora.o (0 warnings in touched files).

@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: FINISH, then merge at 5e0770c9

Blockers:

  1. Missing hardware row at head 5e0770c9: PR touches G17 render retirement, stamp-wait, recovery, and timeout paths (drivers/gpu/drm/asahi/g17/), and the PR body notes no live G17 hardware run has been posted yet. Add an exact-head hardware row on a G17 Mac (M4 Pro / M4 Max / M5) with regression checks (0 GPU faults/timeouts, 0 failed units, 0 new kernel errors).

Checked: no Apple material, no AI attribution, no new chip/board/firmware gates, no cmdline hacks, human Signed-off-by, full diff of all 8 files, retire_front_command() FIFO stepping and idempotent retirement::poll() when stamps_owed entries advance to index 0, timeout_head()/quarantine()/note_interrupted()/replay_abandoned() filtering of stamps_owed entries, all 20/20 CI checks green (apple-build, host-tests, all KUnit suites, pr-text, readiness).

Evidence
  • Code inspection found no correctness or safety blockers:
    • Tracker::get_mut() bounds-checks index >= self.len before modular indexing.
    • Pair::retire_front_command() properly confines observed validation/consumption to at == 0, sets stamps_owed = true and clears collateral_at and updates executed_generation on both stampless and behind-owed (at != 0) retirements, and calls memory.retire() + note_retirement() only when an entry actually pops at at == 0 (or in release_witnessed()). Because retirement::poll() is idempotent on monotonic stamps, a behind-owed entry that later advances to index 0 pops cleanly.
    • Pair::timeout_head() suppresses drained/parked quarantined pairs (drain_failures >= DRAIN_RETRY_LIMIT || executed_unstamped()) and skips stamps_owed entries; render_timeout_decision() and fail_after_observation() skip retired_held(packet); Backend::defer_timeout() returns Decision::Retire immediately when retirement_queued() is set after scan_renders().
  • CI at 5e0770c9: 20/20 checks PASS.
  • Only missing item is a live G17 hardware row at 5e0770c9.

@RyanTheTide

Copy link
Copy Markdown
Contributor

5e0770c J700 (MacBook Neo, T8140, G17P B1) PASS: combined guarded one-shot 7.3.0-aurora-peer1+ on main 498d53fd (clean merge of 5e0770c9ceaa, default cmdline, saved Stage 2 unchanged); gpubench-vk render.light d1 138.43 us / d2 54.36 us ok, dEQP-VK.api.smoke.* 8/8 pre/post s2idle 1/1 (rtc0), dEQP-VK.synchronization.smoke.* 12/12, 0 GPU faults, Enforcing, 0 AVC, 0 failed units; restored saved 7.3.0-aurora-edge. (Note: tools/asahi/g17-render-owed-stamp-tests.py stub on this branch still declares 0-arg note_retired() vs main's 1-arg note_retired(u64).)

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 29, 2026

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

The J700 combined-build row supplies render and suspend regressions. Its receipt identifies a remaining mismatch between the branch fixture and the current integrated note_retired signature. Keep landing held for a green host run on the intended integration tree with that fixture aligned.

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Nov 30, 2026

@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 5e0770c9ceaa

Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.

Checked: Code reviewed in the earlier App review at this head (6105701508).

Follow-ups (not blocking): align branch fixture with integrated note_retired signature, green host run on integration tree

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging at 5e0770c9ceaa (B2 merge train, 12-01 merge bar). Approval at this head: aurora-silicon-review[bot]. Row: the hardware row at 5e0770c that the readiness check found (PR body or comment). CI: linux train L3 = main 429e7e1 + 28 approved PRs (candidate 45c2fa4b): Apple driver compile pass, Apple DTBs W=1 pass, planned KUnit dcp-fabric/dcp-topology/dcp-display/macsmc/spi-hid-apple/mt7932/asahi/sep pass; ave failed to build only because of #3153 (unused static helper under -Werror; #3153 held out) and passes with #3153 reverted from the candidate; host tests apple-dcp and apple-scaler-recovery pass. The rest of the hosted run is queued behind the backlog. Revert: git revert -m 1 <merge commit>.

@RyanTheTide
RyanTheTide merged commit bcb1f91 into aurora-silicon:main Dec 1, 2026
23 of 25 checks passed
muness pushed a commit to muness/linux that referenced this pull request Dec 1, 2026
The two harnesses copy driver code next to stand-ins. Code that landed
on main 12-01 calls stand-ins they did not have, so both fail to compile:
- g17-output-fence-tests: fence.rs (aurora-silicon#3392) calls KickDependency::qid().
- g17-render-owed-stamp-tests (aurora-silicon#3229): backend.rs calls
  Packet::note_first_excuse()/first_excuse() and Queues::forfeit_blocker()
  (compute allowance forfeit), and recovery::note_retired() now takes the
  retired command number.
The render cases have no compute command, so the new stand-ins record no
excuse and forfeit nothing. All g17 host tests pass (329 jobs).
@axboe

axboe commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

One render timeout on a K116s (T6050, 16" M5 Pro OLED, firmware 27.2) with this merged, which froze the desktop. I'm posting it here because the timed-out pair looks executed but unstamped, which is the case this changed.

Kernel: main cafee21 (has this, #3415, #3392 and #3772) + #2355 + #3821, ATC0 left out (#3598) (7.3.0-m5pro-g59b031673838). Loader: aura main 7f5a1df5. Default command line. KDE Plasma (kwin_wayland), normal desktop use, about 38 minutes after boot:

aurora 2300000000.gpu: G17: watchdog gave up on a render command of owner 17: allowance 2000 ms, at the head of its queue for 10064 ms; not long work; sharing renewals 4/14, last command retired 5672 ms ago; deferred 0 polls behind older or pending work, excused 0 polls behind other clients' allowed work; failed as its own
aurora: G17: render timeout slot 3 ordinal 420390 qids [6, 7]: stamps [0x66a2600, 0x66a2600], recovery state 0, pass [0xcf2a2fe82, 0x0], stages [0xcf2a2fe82, 0xcf2a301be, 0x0, 0x0], tiler Cursors { done: 388, read: 388, write: 388 }, fragment Cursors { done: 388, read: 388, write: 388 }, job list not empty
aurora: GPU work of a client failed (ETIMEDOUT, reported at g17/runtime.rs:2367, client kwin_wayland[1365]); the client sees a lost device
aurora 2300000000.gpu: [File 19 Queue 2]: IOCTL: submit failed! (submission ID: 662606 err: EIO)
  • Both rings are drained (388/388/388), yet the pair was failed as its own after 10 s, and kwin's VM went sticky -110. kwin logged GL_CONTEXT_LOST, never recovered, and the screen and pointer froze until a power-button reset. The kernel itself stayed up.
  • The only other GPU line in that boot is aurora: asahi: M5 submission history skipped: EBUSY, 12 minutes earlier.
  • It's the first G17 render timeout in the last 40 boots on this machine. The previous kernels (main e6c7b03 and older) never logged one.

I don't have a reproducer. I'm staying on this kernel and will add any repeat here.

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.

drm/asahi: g17: concurrent timeline_semaphore.one_to_n clients lose their device behind another VM's failed render work (J616s)

3 participants