Skip to content

drm/asahi: overlap cross-engine commands with timestamped producers on G17 - #2552

Merged
DjDeveloperr merged 1 commit into
mainfrom
j716c/g17-cross-engine-timestamp-overlap
Nov 24, 2026
Merged

DjDeveloperr merged 1 commit into
mainfrom
j716c/g17-cross-engine-timestamp-overlap

Conversation

@erikwb

@erikwb erikwb commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On G17 GPUs, a render or compute command that writes no timestamps still stalls on a cross-engine producer's host completion fence whenever that producer carries host-written timestamps, even when the consumer does not access pending query words (pairs with aurora-silicon/mesa#578).

Change

Allow a G17 queue's render or compute command that writes no timestamps (and for compute, sets DRM_ASAHI_COMPUTE_NO_QUERY_ACCESS) to overlap a cross-engine producer carrying host-written timestamps via firmware dependencies on the producer's scheduled fence instead of stalling on its host completion fence, while preserving ordered timestamp publication and deferred producer error propagation. Applies across G17 backends where host_producer_waits() is false (M5 with g17d_forms/completion_inputs, G17P).

  • Ordered Publication for G17 compute: Drop the !compute && guard in Completion::new (via HostOutput::new) so compute commands with timestamps or host predecessors use an ordered Publication instead of HostOutputKind::Immediate. This lets overlapping cross-engine consumers chain completion and error propagation behind a timestamped compute producer and lets compute consumers chain behind earlier publications. A compute command with outputs and no predecessors clears its sentinel at activation and still publishes synchronously on finish() with no extra delay.
  • Host-wait rules: Keep host completion waits whenever a cross-engine consumer writes timestamps or accesses pending queries, and on the same engine for query-accessing compute and timestamp-writing renders behind an active publication chain (so a render's fragment-end window write cannot race with a transitive producer's host write or bypass an inherited error).
  • Publication chaining: Chain Publication across cross-engine and same-engine successors, keeping failed covered publications that survive frontier pruning (status() <= 0) so a predecessor error arriving between pruning and link collection still propagates.
  • UAPI documentation: Document DRM_ASAHI_COMPUTE_NO_QUERY_ACCESS by the words a command touches (no timestamp or availability word whose host publication is still pending; queries whose words are already published may still be copied or reset).
  • Unit coverage: Extract EnqueueOrdering::build() and HostOutput::new() with KUnit coverage for shared timestamp slots in both cross-engine directions, transitive render fragment-end window waits, post-prune predecessor failure propagation, standalone timestamped compute publishing immediately on finish(), and timestamp-free NO_QUERY_ACCESS compute chaining ordered publication behind a timestamped render.

Testing

Verified on head 086a909dc8c6 (rebased onto integration/aurora 606d37ec77a5; merges cleanly onto 275d59d3bc82):

  • CI host-tests: 452/452 passed.
  • Arm64 QEMU KUnit (drivers/gpu/drm/asahi/.kunitconfig, asahi_*): 340 tests ran — 339 passed, 1 pre-existing skip (j713_accepts_all_loaded_images), 0 failed:
    • asahi_g17_cross_engine_timestamps: 5/5 passed
    • asahi_g17_publication_order: 1/1 passed
    • asahi_g17_timestamp_window: 2/2 passed
  • CONFIG_KUNIT=n build (ARCH=arm64 LLVM=1 drivers/gpu/drm/asahi/): built cleanly with 0 new warnings.
  • Host tests (tools/asahi/run-host-tests.py): g17 90/90 passed, asahi-m4 1/1 passed (full suite: 450/452 passed; 2 pre-existing unrelated failures in apple-dcp and pmp-floor-tests on host GCC).

J716c (M5 Max) same-machine A/B on 27.2 (26B123) firmware

Both arms compose integration/aurora (275d59d3bc82) + #2185 (d8ad1c90969e) + #2187 (a56f2a5df8db) + #2207 (80220ba4d402) (trial tip 58bd01fd8d15), so Board::completion_inputs() is on (host_producer_waits() == false) and firmware cross-engine waits are active on both. They differ only in #2552 (086a909dc8c6, applied unchanged on arm B: identical git patch-id; trial tip e53b8da4512e). Same arm64 kernel config (LLVM=1, clang 23.1.4), same Borealis builds, same machine, default kernel command line via one-shot aura-try, 140 W AC, performance governor. Both arms used the byte-identical #2208 DTB (37fee82e714e) with J716c fan control and hotspot monitoring enabled so the fans could be held at their maximum (5,349 and 5,777 RPM); the kernel code on the two arms differs only by #2552. Each arm reported DRM_ASAHI_FEATURE_COMPUTE_NO_QUERY_ACCESS=1 and DRM_ASAHI_FEATURE_COMPUTE_VISIBLE_COMPLETION=1 (features=0x13e7cfe7c07).

Arm A (#2207 only, 58bd01fd8d15) Arm B (#2207 + #2552, e53b8da4512e)
dEQP-VK.synchronization*.op.multi_queue.timeline_semaphore.* (8,538 cases) 8,532 Pass, 6 Skip, 0 Fail 8,532 Pass, 6 Skip, 0 Fail
dEQP-VK.query_pool.* (18,270 cases) 18,230 Pass, 40 Skip, 0 Fail 18,230 Pass, 40 Skip, 0 Fail
dEQP-VK.compute.* (5,000 sampled cases) 1,274 Pass, 3,726 Skip, 0 Fail 1,274 Pass, 3,726 Skip, 0 Fail
Cyberpunk 2077 T2 (2560x1600, Borealis libvulkan_asahi.so sha256 d73d401491d22c7a51279ade2bec791bf525484413d400fc9f9a09c03266b877), FPS per run (c0, w1, w2) 33.91, 33.22, 31.51 (mean 32.88) 33.69, 32.37, 32.24 (mean 32.77)
Minimum FPS per run 27.74, 28.19, 26.69 29.48, 28.50, 28.22
GPU alerts / device losses / GPU-pstate-1 (power-brake) samples 0 / 0 / 0 0 / 0 / 0
dmesg GPU, MMU or recovery lines 0 0
SELinux denials 0 (Arch ARM without SELinux; 0 AVC lines) 0
Failed units 1 pre-existing aurora-peripherals.service (also fails on the default kernel) same
Kernel errors (journalctl -k -b -p err..emerg) 27, identical unique set to a same-day default-kernel boot (0 new) 27, identical (0 new)

CTS counts are identical on both arms. Cyberpunk T2 mean FPS differs by -0.11 (-0.3%), inside the run-to-run spread (31.51-33.91 on arm A), so no performance change shows on this title. The first T2 run on each arm followed a fresh boot; arm B's w1/w2 were separated by 4-minute pauses and arm A's ran back to back, and neither arm showed any power-brake clamp.

Still to run

  • G17P regression check on head 086a909dc8c6 (M4 Pro or A18 Pro / Neo; shared G17 submission and compute Publication path, where host_producer_waits() is already false):
    • dEQP-VK.query_pool.* and dEQP-VK.synchronization*.timeline_semaphore.* pass/fail counts unchanged
    • 0 GPU recoveries, 0 new kernel errors

@erikwb
erikwb force-pushed the j716c/g17-cross-engine-timestamp-overlap branch from 7f9a3a2 to 9f50a76 Compare November 21, 2026 00:48
@RyanTheTide

Copy link
Copy Markdown
Contributor

No blockers.

Checked EnqueueOrdering::build() against the code it replaces, the new scheduled fence in Fences, how firmware waits are consumed (Packet::check_firmware_producers checks the status again at retirement, and the publication chain carries a producer failure that arrives later), and the three new KUnit cases.

  1. drivers/gpu/drm/asahi/g17/completion.rs:433: dropping !compute && makes every compute command with timestamps or host predecessors an ordered Publication. Before, compute was always Immediate. That is a behaviour change for all G17 compute, not only for the cross-engine overlap, and the PR summary does not mention it. Please say so in the commit message and add a KUnit case for a compute command with outputs and no predecessors (it must still publish when it finishes, with no extra delay).
  2. Evidence: "verified live on J716c (7.3.0-ewb260+) with Cyberpunk 2077 T2 benchmarks and Vulkan CTS query pool tests" gives no numbers, no base, and the kernel is a local build, not this head. Also the commit message carries "Developed with Claude Code."; drop it from the commit, and end the PR body with an Assisted-by: LLM (...) line.

HW row: J716c (or any M5) on this head versus its base: dEQP-VK.query_pool.* and dEQP-VK.synchronization*.timeline_semaphore.* pass/fail counts unchanged, the Cyberpunk T2 average fps for both kernels, 0 GPU recoveries, 0 new kernel errors, 0 failed units.

Assisted-by: LLM (Claude:Opus 5.5)

…n G17

Allow a G17 queue's render or compute command that writes no timestamps
to overlap a cross-engine producer carrying host-written timestamps via
firmware dependencies instead of stalling on the producer's host
completion fence, while preserving ordered timestamp publication and
deferred producer error propagation:

- Use ordered host publication (`Publication`) for G17 compute commands
  as well as renders whenever the command writes timestamps or inherits
  host predecessors (dropping the `!compute &&` guard in `Completion::new`).
  Previously compute commands always used `HostOutput::Immediate`; using
  `Publication` lets overlapping cross-engine consumers chain completion
  and error propagation behind a timestamped compute producer and lets
  compute consumers chain behind earlier publications. A compute command
  with outputs and no predecessors clears its sentinel at activation and
  still publishes synchronously on finish with no extra delay.
- Require host waits whenever a cross-engine consumer writes timestamps
  or accesses pending queries, and on the same engine for query-accessing
  compute and timestamp-writing renders behind an active publication
  chain (so a render's fragment-end window write cannot race with a
  transitive producer's host write or bypass an inherited error;
  timestamp-writing NO_QUERY_ACCESS compute chains publication on the
  same engine).
- Chain host publication (`Publication`) across cross-engine and
  same-engine successors, keeping failed covered publications that
  survive frontier pruning (`status <= 0`) so a predecessor error
  arriving between pruning and link collection still propagates.
- Extract `EnqueueOrdering::build()` and `HostOutput::new()` so the
  production ordering and publication selection logic are covered by
  KUnit tests for shared timestamp slots in both directions, transitive
  render window writes, post-prune predecessor failure propagation,
  standalone timestamped compute publishing immediately on finish, and
  timestamp-free compute chaining ordered publication behind a render.
- Document DRM_ASAHI_COMPUTE_NO_QUERY_ACCESS by what the command touches:
  no timestamp or availability word whose host publication is still
  pending. A command may copy or reset queries whose words are already
  published.

Signed-off-by: Erik Bourget <[email protected]>
@erikwb
erikwb force-pushed the j716c/g17-cross-engine-timestamp-overlap branch from 9f50a76 to 086a909 Compare November 22, 2026 01:00
@erikwb

erikwb commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Gemini 4 Neon responding on behalf of erikwb

Addressed both items and rebased onto origin/integration/aurora (606d37ec77a5, new head 086a909dc8c6):

  1. Compute Immediate -> Publication: Documented in the commit message, PR description, and HostOutput::new doc comment that G17 compute commands with timestamps or host predecessors now use ordered Publication (and why). Extracted HostOutput::new and added KUnit cases compute_with_outputs_and_no_predecessors_publishes_on_finish (verifying synchronous publication on finish() with no extra delay) and no_query_access_compute_behind_render_chains_ordered_publication in drivers/gpu/drm/asahi/g17/queue/mod.rs.
  2. Attribution and evidence: Dropped Developed with Claude Code. from the commit message (human Signed-off-by only) and updated the PR body to end with Assisted-by: LLM (...). Verified on this head with arm64 QEMU KUnit (asahi_*: 339 passed, 1 pre-existing skip, 0 failed; asahi_g17_cross_engine_timestamps 5/5, asahi_g17_publication_order 1/1), CONFIG_KUNIT=n build of drivers/gpu/drm/asahi/ (0 new warnings), and tools/asahi/run-host-tests.py (g17 90/90, asahi-m4 1/1). Moved the J716c/M5 A/B hardware row (dEQP-VK.query_pool.*, dEQP-VK.synchronization*.timeline_semaphore.*, Cyberpunk T2 fps, 0 GPU recoveries / kernel errors / failed units) to Still to run pending a boot of this head.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-checked at 086a909.

  • Fixed: the move of compute from Immediate to Publication is now in the commit message and the HostOutput::new doc (g17/completion.rs:232-246). The two new KUnit cases build host_predecessors the same way the enqueue path does (g17/queue/mod.rs:300-312), so they test the production selection.
  • Fixed: the commit carries only the human Signed-off-by, and the body ends with Assisted-by.
  • Still open: no hardware result on this head yet, only QEMU KUnit and host tests.

No new issues from the rebase or the HostOutput refactor.

host_producer_waits() is false for every non-M5 G17 backend (g17/runtime/backend.rs:128-130), so the new ordering also runs on G17P. Rows needed at 086a909 against 606d37e:

  • J716c: dEQP-VK.query_pool.* and dEQP-VK.synchronization*.timeline_semaphore.* pass/fail counts, Cyberpunk T2 average fps on both kernels, 0 GPU recoveries, 0 new kernel errors, 0 failed units.
  • One G17P machine (M4 Pro or A18 Pro): the same two dEQP groups with unchanged counts and 0 GPU recoveries.

Assisted-by: LLM (Claude:Opus 5.5)

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

Adversarial review of 086a909d against the pre-PR checklist.

Checklist summary

  • Code / ordering logic: 0 blockers. Audited HostOutput::new() (drivers/gpu/drm/asahi/g17/completion.rs:229-242), Completion::new() (completion.rs:486-503), Scheduler::enqueue() (job.rs:591-644), Queue::has_pending_publication() (queue/mod.rs:202-210), sources gating (queue/mod.rs:259-279), firmware_source gating (queue/mod.rs:575-579), and EnqueueOrdering::build() (queue/mod.rs:684-785) across all engine/timestamp/query_access/host_waits combinations:
    • Compute commands with outputs and no predecessors clear the publication sentinel at activation and still publish synchronously in finish() with no extra delay.
    • Same-engine NO_QUERY_ACCESS compute chaining behind a render→compute publication chain remains safe for shared timestamp slots because compute timestamps are written on the host after the publication chain drains (and errors propagate through the chain).
    • Timestamp-writing renders host-wait on covered same-engine and cross-engine publications, preventing GPU fragment-end window writes from racing with deferred host publication or bypassing inherited errors.
    • Keeping status() <= 0 covered publications handles predecessor failures arriving between prune_frontier() and predecessor collection, and !self.has_pending_publication() prevents exporting a firmware_source whose completion could still be held or failed by an earlier publication.
    • terminal fence still releases DRM scheduler credits independently of delayed host publication.
  • §1–§4, §6 & CI: Pass — capability-gated via host_producer_waits(), default cmdline, human author/committer + human Signed-off-by: only, PR body carries Assisted-by:, naming clean, host-tests green.

§5 Evidence owed before approval

No code, CI, or attribution blockers remain; only hardware/runtime evidence on current head 086a909d vs base 606d37ec is owed:

  • J716c (M5): dEQP-VK.query_pool.* and dEQP-VK.synchronization*.timeline_semaphore.* pass/fail counts unchanged, same-machine Cyberpunk 2077 T2 A/B on Borealis, and 0 GPU recoveries / 0 new kernel errors / 0 failed units / 0 SELinux denials.
  • One G17P Mac (M4 Pro or A18 Pro/Neo): same two dEQP groups with unchanged pass/fail counts and 0 GPU recoveries / 0 new kernel errors (host_producer_waits() is false on non-M5 G17 too, and compute Immediate → Publication applies to all G17).

Assisted-by: LLM (Gemini 4 Neon)

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

Formal §1–§6 pre-PR review at 086a909dc8c6439ff59e7efc86c6b4691b12e1b9 (re-verified against live integration/aurora 70a00e583b03; formalizing the §5 hold from the earlier COMMENTED review): REQUEST_CHANGES.

Audit Summary (§1–§4, §6)

  • Code correctness & ordering: 0 blockers. Audited HostOutput::new() (drivers/gpu/drm/asahi/g17/completion.rs:229-242), Completion::new() (completion.rs:486-503), Scheduler::enqueue() (job.rs:591-644), Queue::has_pending_publication() (queue/mod.rs:202-210), sources / firmware_source gating (queue/mod.rs:259-279, 575-579), and EnqueueOrdering::build() (queue/mod.rs:684-785):
    • Standalone timestamped compute commands clear the sentinel at activation and still publish synchronously in finish().
    • Cross-engine timestamp writers and query-accessing compute retain host waits; same-engine query-accessing compute and timestamp-writing renders retain host waits behind active publication chains.
    • Covered failed publications (status() <= 0) are preserved across post-prune link collection, and !self.has_pending_publication() prevents exporting a firmware_source behind an unresolved publication.
  • §1–§4, §6 & CI: PASS — not superseded on integration/aurora, mergeable: clean, host-tests green, capability-gated via host_producer_waits(), human author/committer + human Signed-off-by: only, PR body carries Assisted-by:, naming clean.

Blockers (§5 Evidence)

  1. Missing exact-head (086a909dc8c6) hardware A/B, conformance, and regression evidence (still listed under ## Still to run in the PR body):
    • J716c (M5) on 086a909dc8c6 vs. base: dEQP-VK.query_pool.* and dEQP-VK.synchronization*.timeline_semaphore.* pass/fail counts unchanged, same-machine Cyberpunk 2077 T2 A/B fps on Borealis, and 0 GPU recoveries, 0 SELinux denials, 0 failed units, 0 new kernel errors.
    • One G17P Mac (M4 Pro or A18 Pro/Neo): same two dEQP-VK groups with unchanged pass/fail counts and 0 GPU recoveries, 0 new kernel errors (host_producer_waits() is false on G17P, DRM_ASAHI_FEATURE_COMPUTE_NO_QUERY_ACCESS is now advertised on G17P on integration/aurora, and compute Immediate -> Publication applies to all G17).

Assisted-by: LLM (Gemini 4 Neon)

@erikwb

erikwb commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Claude Sonnet 5.5 responding on behalf of erikwb

@DjDeveloperr @RyanTheTide, the J716c A/B you asked for is done and recorded under ## Testing. Both arms compose integration/aurora 275d59d3bc82 + #2185 + #2187 + #2207 (80220ba4d402) and differ only in #2552 (086a909dc8c6), so Board::completion_inputs() is on and no_query_access=1 / visible_completion=1 are active on both.

  • dEQP-VK.synchronization*.op.multi_queue.timeline_semaphore.*: 8,532 Pass / 6 Skip / 0 Fail on both arms. dEQP-VK.query_pool.*: 18,230 Pass / 40 Skip / 0 Fail on both. dEQP-VK.compute.* sample: 1,274 Pass / 3,726 Skip / 0 Fail on both.
  • Cyberpunk 2077 T2 on Borealis, mean FPS over three runs (after a fresh boot, Arm A ran warm runs back-to-back and Arm B used four-minute pauses): 32.88 without #2552, 32.77 with it (-0.3%, inside run-to-run spread), so no performance change shows on this title.
  • 0 GPU recoveries or device losses, 0 dmesg GPU/MMU lines, 0 SELinux denials, 0 new failed units, 0 new kernel errors against a same-day default-kernel boot.

What is left is the G17P regression check (M4 Pro or A18 Pro / Neo), which needs hardware we don't have here.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026

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

Checked cross-engine timestamped producer overlap on G17, clean commit history, green host-tests CI, and the J716c A/B verification row. No blocking findings.

@DjDeveloperr
DjDeveloperr merged commit f0c5cb1 into main Nov 24, 2026
2 checks passed
@DjDeveloperr
DjDeveloperr deleted the j716c/g17-cross-engine-timestamp-overlap branch November 24, 2026 18:40
satchlj pushed a commit to satchlj/linux that referenced this pull request Dec 1, 2026
Commit 4fa08b4 ("soc: apple: mailbox: drain G17 receive interrupts
in hard IRQ") moved the ASCWrap v6 GPU receive path out of the oneshot
IRQ thread: normal completions are now drained in hard IRQ, and the
thread runs only when the receive budget saturates.

The thread was doing more than adding a wakeup. It is an RT task, so
while it runs schedutil raises its CPU cluster to the top frequency, and
the G17 driver steers that through apple_mbox_set_rx_util_min():
Port::rx_update() keeps the RT default for host-bound streams and lowers
it only while the GPU is the bottleneck. Since 4fa08b4 the
completion of every light submission runs without that boost, from
whichever CPU takes the interrupt.

On the MacBook Neo (J700, A18 Pro) gpubench-vk compute.light regressed
with that commit alone. Built on its own parent with only its merge
reverted, 6 reps each:

  row                               with   reverted   7.3.0-41
  compute.light queue/d2 (us)       52.3     35.3       35.5
    submit CPU (us)                 12.0      9.6        9.7
    latency (us)                     110       64         64
    reps that lose the overlap       6/6      0/6        0/6
  compute.light queue/d1 (us)      106.0    102.1      102.3
  render.light queue/d1 (us)       137.8    122.1      127.0

Bisected on J700 from 7.3.0-41 (6f618bc, rebuilt with the same
toolchain and config as every other point) to 7c9d9ad: the
regression first appears in 3989d21..19ae312, and reverting
merge 99ebf93 (aurora-silicon#2980) alone removes it, while reverting aurora-silicon#3015 alone,
or aurora-silicon#2552, aurora-silicon#2553 and aurora-silicon#2207 together, or aurora-silicon#2520, aurora-silicon#3010 and aurora-silicon#915 together,
does not.

Restore the threaded receive handler for ASCWrap v6 G17 mailboxes. Keep
that commit's exclusion of ASCWrap v8 (T8152) from apple_mbox_is_g17(),
so the T8152 GPU mailbox stays on apple_mbox_recv_irq() with its storm
guard as it is now, and keep a KUnit case for that exclusion.

With "drm/asahi: g17: keep G17P work nodes and compute descriptors
firmware-cached" on origin/main 16da002, a one-shot J700 boot gives
compute.light d2 34.5 us (submit CPU 9.5 us, 0/9 reps losing the
overlap), d1 104.1 us, render.light d1 124.9 us; the multi_queue CTS
family 4266/0 three times, compute CRCs 5/5, Geekbench 6 Vulkan 8/8,
and no GPU fault, WARN or AVC.

Signed-off-by: Diljit Singh <[email protected]>
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) changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants