Skip to content

drm/asahi: g17: M5: renew a watchdog while later work overtakes it - #3583

Merged
RyanTheTide merged 1 commit into
aurora-silicon:mainfrom
m0d16l14n1:fix/g17-m5-overtake-renew
Nov 29, 2026
Merged

RyanTheTide merged 1 commit into
aurora-silicon:mainfrom
m0d16l14n1:fix/g17-m5-overtake-renew

Conversation

@m0d16l14n1

Copy link
Copy Markdown
Contributor

What: Renew an M5 job's watchdog while work published after it keeps retiring. On M5 a job that has not finished at its watchdog fails then (renews_shared() is false there since 79c6eb6), so a hung compute job is killed at 2 s instead of 6 s. That also fails work that is only waiting: with clients of mixed global priority, the firmware runs the higher-priority queues' later work ahead of a lower-priority client's oldest command for longer than one poll, and that client loses its device while the GPU retires work the whole time. Record each command's publication ordinal and the newest ordinal that retired; on M5 a job counts as sharing the GPU only while work published after it keeps retiring (timeout::overtaken), and is then renewed like a shared job elsewhere, at most SHARED_RENEWALS times (30 s). A hung job that nothing later overtakes still fails at its first expiry.
Tested: J815 MacBook Air 15" M5 (T8142, G17G), aurora.ko built from main 0701a920154e + this commit (head e861dd8534f6), Borealis aurora-wip. gpubench-stress-vk --test queue.depth (3 clients × 4 queues, mixed global priorities): 6/6 runs with 0 GPU errors (before: fails every run, VK_ERROR_DEVICE_LOST after a 2 s watchdog kill). Full gpubench-stress-vk suite: 16 pass, 0 fail, 1 skip (ray query), including compute.long and life.fault. Host tests tools/asahi/g17-ray-query-timeout-tests.sh: 34/34. dEQP-VK gate sample: same as main. Light submit rows: same as main. Regression line: 0 SELinux denials (N/A on this image), 0 failed units, 0 new watchdog or GPU kernel lines from the stress runs.
Risk: two-way door · M5 Macs (J815 tested; the rule is per chip generation, not per board); other chips unchanged (renews_shared() still true there and this path is not taken).
Not yet: M5 Pro/Max rows. Fairness is unchanged: the low-priority client still waits up to 3–12 s behind the higher-priority clients in queue.depth (now it waits instead of failing).

Details
  • g17/job.rs, queue/compute.rs, queue/render.rs: each command keeps the publication ordinal it was published with (the order both engines publish in); a retirement without error reports it to recovery::safety::note_retired(published).
  • recovery/safety.rs: besides the last retirement time, keep the newest retired ordinal and when it last rose (newest_retired()).
  • timeout.rs: overtaken(own, newest, since_newest) is true when the command was published, something published after it retired, and that happened within LIVENESS_NS. A unit test covers the cases and the SHARED_RENEWALS bound.
  • runtime/backend.rs: on M5 the shared renewal is taken only when the job is overtaken; the comment on renews_shared() says so. The rest of the watchdog (allowances, excuses, deferrals, attribution) is unchanged.
  • A hung job beside active traffic is renewed for up to 30 s, as on other G17. A per-engine variant (only same-engine work counts) failed queue.depth 3 of 5 runs, because render and compute share the cores, so it was not kept.
Evidence

Machine: J815 MacBook Air 15" M5 (T8142, G17G), GPU firmware 26B123, kernel 7.3.0-aurora-j815-dev, Borealis (aurora-wip based), gpubench-stress-vk suite c36cbbe.

Run Driver without this change This PR
queue.depth alone fails each run (11 of 11 on this Mac since the M5 watchdog change) 6/6, 0 GPU errors; low-priority max latency 3.2–12.0 s
full stress suite 15 pass, 1 fail (queue.depth), 1 skip 16 pass, 0 fail, 1 skip
dEQP-VK gate sample (15,958) 11,151 Pass with the task-stage fix 11,127 Pass + 24 task-stage Crash (this tree does not have the separate task mesh storage fix, #3582); no other diff

Before, the kernel log of the failing client:

aurora 582600000.gpu: G17: watchdog gave up on a compute command of owner 8194: allowance 2000 ms, at the head of its queue for 2000 ms; not long work; no sharing renewals on this GPU, last command retired 0 ms ago; deferred 0 polls behind older or pending work, excused 0 polls behind other clients' allowed work; failed as its own
aurora: GPU work of a client failed (ETIMEDOUT, reported at g17/runtime.rs:2367, client gpubench-stress[697630]); the client sees a lost device

One of the six runs also logged an unrelated boot-time line from a system service (not from the GPU) while it ran; its GPU checks were all clean.

On M5 a job that has not finished at its watchdog fails then (79c6eb6), so
that a hung compute job started just after other clients finished is killed at
2 s instead of 6 s. That also fails work that is only waiting: with clients of
mixed global priority, the firmware runs the higher-priority queues' later work
ahead of a lower-priority client's oldest command for longer than one poll.
gpubench-stress queue.depth (3 clients x 4 queues, low/medium/high priority)
lost the low-priority client's device in 11 of 11 runs on the J815, each after
"watchdog gave up on a compute command ... at the head of its queue for
2000 ms" while the GPU retired work continuously.

Record each command's publication ordinal (the order both engines publish in)
and the newest ordinal that retired. On M5, a job counts as sharing the GPU
only while work published after it keeps retiring (timeout::overtaken), and is
then renewed like a shared job elsewhere, at most SHARED_RENEWALS times (30 s).
A hung job that nothing later overtakes still fails at its first expiry.

Signed-off-by: Nick <[email protected]>
@m0d16l14n1
m0d16l14n1 requested review from a team and DjDeveloperr as code owners November 29, 2026 00:49

@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 e861dd85 once the fork PR's CI workflows are approved and pass.

Blockers: none in code (await fork CI workflow approval and green checks).

Checked: Full 7-file diff (drivers/gpu/drm/asahi/g17/{job.rs,queue/compute.rs,queue/render.rs,recovery.rs,recovery/safety.rs,runtime/backend.rs,timeout.rs}), shared cross-engine publication ordinal counter (port.rs:920, runtime.rs:2485,2583), replay ordinal refresh, atomic retirement tracking, GaveUp diagnostic formatting, unit tests, and exact-head J815 (T8142 / G17G) stress + CTS verification.

Evidence
  • Shared publication ordinal and replay handling:
    • Both render::Pair (host.next_publication()) and compute::Queue (host.next_compute_publication() -> port.next_publication()) draw from the same monotonic self.publications counter starting at 1, so cross-engine overtaking between render and compute shares a consistent total order.
    • packet.note_ordinal(published) runs on both initial publication and replay, and recovery::note_retired(front.published) records only error-free retirements.
  • M5 overtaken renewal (timeout.rs:198-200, job.rs:489-520):
    • overtaken(own, newest, since_newest) requires own != 0 && newest > own && retiring(since_newest), so a hung M5 job with nothing published after it still fails at its first 2 s expiry, while a lower-priority waiting job overtaken by newer retiring work is renewed up to SHARED_RENEWALS (30 s).
    • Non-M5 chips keep renews_shared() == true and stay on the existing path unchanged. Passing true to GaveUp::new() accurately logs M5 sharing renewal counts instead of no sharing renewals on this GPU.
    • Unit test overtaken_needs_later_work_retiring_recently covers positive, negative (newest <= own, expired LIVENESS_NS, None, unpublished 0), and SHARED_RENEWALS cap cases.
  • Verification at e861dd85 (J815 M5 / G17G): gpubench-stress-vk --test queue.depth 6/6 pass with 0 GPU errors (was 11/11 fail with VK_ERROR_DEVICE_LOST); full gpubench-stress-vk 16 pass, 0 fail, 1 skip; tools/asahi/g17-ray-query-timeout-tests.sh 34/34; 15,958-case dEQP-VK gate sample matches main; 0 failed units and 0 new GPU/watchdog kernel lines. Commit carries valid human Signed-off-by.

@RyanTheTide

Copy link
Copy Markdown
Contributor

code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at e861dd85. App approved (NEON-PR-REVIEW2); rows J815-exact-head, M5-only-non-M5-unchanged. Merges under the 6-point rule 1 h from now once hosted CI is green, unless you object.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (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 Nov 29, 2026
@github-actions

Copy link
Copy Markdown

Merge readiness at e861dd85: not ready yet

Check Detail
CI at head ok no CI for this change (the hardware row is the gate)
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 e861dd85
Conflicts ok none
PR text ok Risk: two-way · M5 Macs (J815 tested; the rule is per chip generation, not per board); other chips unchanged (renewsshared() still true there and this path is not taken).

Areas: area:gpu

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

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging under the 6-point rule (Ryan 09:29, permanent), at e861dd85. (1) The review App approved at this head. (2) Full CI is green. (3/4) Rows: J815-exact-head;M5-only-non-M5-unchanged. (5) There's no blocking review. (6) Dj was pinged here 89 min ago with no objection. Revert: git revert -m 1 <merge>.

@RyanTheTide
RyanTheTide merged commit 242fac0 into aurora-silicon:main Nov 29, 2026
1 check 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: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