Skip to content

drm/asahi: g17: support staged and compute-prefixed renders in render_direct() - #3388

Merged
RyanTheTide merged 4 commits into
mainfrom
perf/g17-direct-render-stage-prefixes
Nov 29, 2026
Merged

RyanTheTide merged 4 commits into
mainfrom
perf/g17-direct-render-stage-prefixes

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

What: Admit staged (DRM_ASAHI_RENDER_STAGE_PREFIXES) and compute-prefixed (wait_through[1] / tiling_wait_through[1]) renders onto render_direct() instead of forcing them onto the device-mutex prepare_render() path.

  • Populate render_tiling (via tiling_wait_through[0]) and tiling (via wait_through[0]) in Pair::own_dependencies() (queue/render.rs), matching Registry::render_dependencies().
  • Resolve tiling_wait_through[1] and wait_through[1] across every compute queue owned by owner inside Firmware::lend_render() (runtime/render/direct.rs), which already holds the device mutex (returning Ok(None) on EAGAIN or non-zero recovery state to fall back cleanly to the mutex path, and handling multiple sibling compute queues per owner).
  • Remove the wait_through[1] and stage_prefixes rejections from render_direct() and copy the resolved compute dependencies from Loan into RenderDependencies.

In GTA V Enhanced on M5 Pro, 100.0% (77,005/77,005) of renders carry non-zero compute prefixes and 69.4% carry stage_prefixes, leaving render_direct() completely unused (0%) on main and serializing every render publication and mailbox doorbell under the global device mutex. Supersedes the staged/compute-prefixed portion of conflicting #2769 with full M5 DirectTarget::M5 and multi-compute-queue support.

Tested:

  • Host tests at 4d03fcdf4566d: python3 tools/asahi/run-host-tests.py --only g17 (237/237 pass, including new tools/asahi/g17-direct-stage-prefixes-tests.py with 5 mutation traps). scripts/checkpatch.pl --strict 0 errors, 0 checks. Local asahi.config build of drivers/gpu/drm/asahi/aurora.o succeeds cleanly.
  • J714s (Apple M5 Pro, G17S B1) same-slot, same-Mesa-kit (inst-A), same-DTB (origin/main DTB, MCC/SLC disabled) A/B (notsws2-rescan vs slot3-direct adding 4d03fcdf4566d + inline cross-engine pub + WQ_HIGHPRI drm_sched over origin/main + #3319 + #3330 + #3380):
    • VK CTS (1.4.7.1): 594/594 executed passed, 0 failures (occlusion_query.copy_*: 152/159 + 7 NS; multiview.queries.*: 16/16; concurrent_queries.*: 2/2; synchronization.smoke.*: 12/12; synchronization2.op.single_queue.barrier.*_read_image_compute*: 412/412).
    • GTA V Enhanced (3024x1964 native, Preset 2 Very High, TAA On, ResScalingType=0, no FSR/DLSS, 10 s 24 MHz asahi_hop trace):
      • P4: 54.27 (18.427 ms) -> 55.07 FPS (18.159 ms, +0.80 FPS / +1.5%); P0=59.54 P1=51.93 P2=52.61 P3=56.05 P4=55.07
      • GPU busy: 92.86% -> 94.72% (+1.86 pp); >1 ms blackouts: n=156 (345.6 ms) -> n=96 (231.6 ms)
      • LATE_PUB(FR->CO): 69.1 ms (n=57) -> 0.1 ms (n=6, -99.8%); LATE_PUB(FR->TA): 360.0 ms -> 282.0 ms; 0 GPU faults, 0 new kernel errors.
    • chainbench_diag: V0_ALL_BAR 960x540: 321.5 us (22.96 us/pass) -> 266.5 us (19.03 us/pass, -17.1%); V3_NO_BAR_INDEP 60x33: 289.0 us -> 269.9 us (-6.6%).
    • BeamNG wcusa (3024x1964): 0 >1 ms GPU-idle blackouts, 0 GPU faults, 0 new kernel errors.

Risk: Two-way door · G17 direct render lend path only. lend_render() runs under the device mutex and falls back to the mutex path (Ok(None)) whenever recovery_state != 0 or any compute queue reports EAGAIN; orthogonal to #3301's multi-pair sibling render guard.

Not yet: Isolated single-commit J714s A/B (measured combined in slot3-direct), G17P/G17C/G17D hardware rows, and CI.

…_direct()

Previously render_direct() rejected every render carrying either
DRM_ASAHI_RENDER_STAGE_PREFIXES or a non-zero compute prefix
(wait_through[1] / tiling_wait_through[1]), forcing them onto the
device-mutex prepare_render() path. In GTA V on M5 Pro, 100.0% of renders
(77,005/77,005) carry non-zero compute prefixes and 69.4% carry
stage_prefixes, leaving render_direct() completely unused (0%) and
serializing every render publication and mailbox doorbell under the global
device mutex.

Populate render_tiling (via tiling_wait_through[0]) and tiling (via
wait_through[0]) in Pair::own_dependencies() matching
Registry::render_dependencies(), resolve wait_through[1] and
tiling_wait_through[1] across all owner compute queues inside
Firmware::lend_render() (which already holds the device mutex, returning
Ok(None) on EAGAIN or non-zero recovery state to fall back cleanly), and
admit both staged and compute-prefixed renders in render_direct().

Add a compiled host test with 5 mutation traps verifying render_direct()
admission, lend_render() compute-prefix resolution and EAGAIN fallback,
and Pair::own_dependencies() parity for staged and plain renders.

Signed-off-by: DjDeveloperr <[email protected]>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 27, 2026 13:53
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:none Macs affected, from Merge risk (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 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Merge readiness at dab63909: not ready yet

Check Detail
CI at head running running: KUnit trusted-keys
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 dab63909
Conflicts ok none
PR text ok Risk: two-way · G17 direct render lend path only. lendrender() runs under the device mutex and falls back to the mutex path (Ok(None)) whenever recoverystate != 0 or any compute queue reports EAGAIN; orthogonal to #3301's multi-pair sibling render guard.

Areas: area:gpu

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

@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 newly admitted staged renders use Pair::own_dependencies() for both render prefix scopes. That only sees the lent pair, whereas the mutex path walks the registry, including borrowed siblings. Please coordinate with #3301 and show that fallback covers both wait_through[0] and tiling_wait_through[0] for staged renders, including a live sibling whose dependency belongs to the tiling prefix. Add an exact direct-vs-mutex comparison for that case. The combined J714s A/B also leaves isolated and peer rows open.

…refix work

Pair::own_dependencies() only inspects the lent pair, whereas
Registry::render_dependencies() walks every render pair of the owner
(including pairs lent out for preparation or heap growth via
borrowed_dependencies).

Coordinating with #3301, add Registry::has_other_pair_dependencies() and
call it in lend_render() ahead of Pair::host_growth_target() so any live
or borrowed sibling pair holding work covered by either wait_through[0]
or tiling_wait_through[0] (including a sibling whose dependency belongs
to the tiling prefix) falls back to the device-mutex path.

Extend g17-direct-stage-prefixes-tests.py with direct-vs-mutex parity
comparisons and live/borrowed/tiling-only sibling fallback tests plus 3
new mutation traps.

Signed-off-by: DjDeveloperr <[email protected]>

@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 new pre-lend guard examines both whole-render and tiling prefixes, including the borrowed snapshot for a sibling whose resident pair is unavailable. A matching sibling falls back before host-growth state is sampled. I ran the exact-head direct-stage-prefix host fixture and verified the resident, borrowed and tiling-only cases. Code approved. The combined benchmark does not isolate this patch. Keep held for exact isolated J714s A/B, affected peers and hosted CI.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J700 (MacBook Neo, Apple A18 Pro T8140 / G17P B1, second generation) batched kernel verification row at exact head 334dbc6c7e8bfa8d9739ccf8bca45c6baabe6480: PASS (no regression, 0 failures, 0 GPU faults/recoveries).

  • Combined trial tree (7.3.0-neo-g17perf2v2, commit 5fff9e2700cb):
    • Base: origin/main (ae011990411422923609ae4a41550af2ba25d1b6)
    • Combined PRs tested together in one one-shot boot:
      • #3388 (perf/g17-direct-render-stage-prefixes, head 334dbc6c7e8bfa8d9739ccf8bca45c6baabe6480)
      • #3390 (perf/g17-inline-cross-engine-pub, head 513edcf43d8f67ec51e30a6dcaa5cfe7f746b5a2)
    • All kernel/driver/Rust files merged cleanly onto origin/main with zero conflicts (only adjacent test registrations in tools/asahi/run-host-tests.py were combined).
    • Host tests on the combined tree: python3 tools/asahi/run-host-tests.py --only g17 passed 247/247.
  • Setup & identity:
    • Built with stock 7.3.0-41 config + LOCALVERSION=-neo-g17perf2v2 (0 build errors).
    • Booted via one-shot grub2-reboot only with a 16-minute fallback timer; default entry remained 7.3.0-41.fc44.aurora.aarch64. System Mesa, stock kernel command line.
    • Verified on boot (abb9483f): uname -r = 7.3.0-neo-g17perf2v2, kernel build ID 7c7992d87026bdcf84123ccad4f86d1e331f30ce (MATCH), aurora.ko build ID 36db614ebfd601ee5a14b2bfb798ee1a6656b47c (MATCH).
  • VK CTS (6 jobs, 37,886 cases in 185 s): 31,611 Pass, 6,275 NotSupported, 0 Fail, 0 recoveries (gate rc 0):
    • dEQP-VK.synchronization2.*_read_image_compute*: 5,100 Pass, 5,806 NotSupported, 0 Fail (10,906 total; NotSupported are exclusive-compute-queue / unsupported feature cases).
    • dEQP-VK.synchronization{,2}.* (basic, smoke, single-queue, timeline semaphore, implicit, none_set_reset, internally synchronized objects, plus all synchronization2.*_read_image_compute*): 31,242 Pass, 6,178 NotSupported, 0 Fail (37,420 total).
    • dEQP-VK.compute.pipeline.basic.*: 79 Pass, 2 NotSupported, 0 Fail.
    • dEQP-VK.api.command_buffers.*: 65 Pass, 66 NotSupported, 0 Fail.
    • dEQP-VK.renderpass{,2}.suballocation.subpass_dependencies.*: 73 Pass, 22 NotSupported, 0 Fail.
    • dEQP-VK.query_pool.occlusion_query.copy_*: 152 Pass, 7 NotSupported, 0 Fail.
  • gpubench-vk (fdf4dd6, system Mesa, 17/17 rows ok, CRCs matched stock 7.3.0-41 pre-boot baseline):
    • render.deferred (tile msaa=4 1080p d1/d2): 5e4130ce (match), GPU 10596.9 / 10525.5 µs (stock 10831.2 / 10653.7 µs).
    • render.postfx (msaa=4 1080p d1/d2): 668d6f0a (match), us/sub 773.2 / 572.5 µs (stock 781.2 / 625.0 µs).
    • render.pass_chain (all_bar d1/d4): 93411763 (match), us/sub 550.5 / 371.3 µs (stock 513.7 / 449.1 µs).
    • render.pass_chain (oq_bar d1/d4): 93411763 (match), us/sub 761.4 / 1200.0 µs (stock 785.3 / 857.1 µs).
    • render.light d1/d8: ok, us/sub 132.6 / 31.1 µs (stock 125.3 / 28.8 µs).
    • compute.heavy (alu d1/d4): ok, us/sub 1351.4 / 1181.1 µs (stock 1382.5 / 1181.1 µs).
    • compute.light d1/d8: ok, us/sub 107.4 / 17.0 µs (stock 102.9 / 15.9 µs).
    • compute.cull_mdi d1/d4: 57276de2 (match), us/sub 9677.4 / 1851.9 µs (stock 5357.1 / 1886.8 µs).
    • sync.signal (compute.light d1): ok, latency p5/med/p95 151.0 / 154.9 / 164.2 µs (stock 140.8 / 145.6 / 152.7 µs).
    • Note: stock 7.3.0-41 predates origin/main (ae01199041142), so this row serves as a combined correctness/CRC/stability verification rather than a merge-base perf A/B.
  • Kernel health & restore:
    • 0 GPU faults/recoveries, 0 MMU faults, 0 WARN/BUG/Oops/lockup/RCU-stall/timeout lines, 0 new kernel error lines, 0 AVC denials, 0 failed units, 0 core dumps.
    • Restored cleanly to stock 7.3.0-41.fc44.aurora.aarch64 (boot 278c2620, PMU f701/f702 = 30 00); trial /boot, /lib/modules, BLS entry, and fallback timer removed, stock.sh POST vs PRE diff = 0 bytes.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 27, 2026
@github-actions github-actions Bot added the needs-hw-row No hardware row at the PR head (bot) label Nov 27, 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: HOLD for hosted CI and final-stack hardware qualification.

Checked: All three PR runtime files and the direct-stage fixture have the same Git blobs as the previously approved head. The merged host-test runner retains the fixture and both sibling-prefix regression controls. The attached J700 combined row is for the older pair of heads. Preserve the isolated comparison and affected-peer gates for the landing stack.

Keep both the direct-stage-prefix and M5 governor-stop host test registrations.

Signed-off-by: DjDeveloperr <[email protected]>

@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 dab63909 (wait for queued CI at dab63909 and retain the isolated J714s / peer hardware gates from the prior review)

Blockers: none

Checked:

  • Clean forward-merge of origin/main into perf/g17-direct-render-stage-prefixes:
    • Verified all four PR runtime/test files (drivers/gpu/drm/asahi/g17/queue/render.rs, runtime/render/dependencies.rs, runtime/render/direct.rs, tools/asahi/g17-direct-stage-prefixes-tests.py) have identical Git blob SHAs to previously approved 6d28e86a.
    • Verified tools/asahi/run-host-tests.py cleanly retains both g17-direct-stage-prefixes-tests.py and g17-m5-governor-stop-tests.py.
  • Checked for Apple material, tool attribution, and private serials: clean; MERGEABLE on main; human Signed-off-by present; Tested: and Risk: Two-way door present.
Evidence
  • Head: dab63909 (base: main, mergeable: MERGEABLE, +623/-8 across 5 files).
  • Compared blob SHAs between 6d28e86a and dab63909 across all 4 code/test files: 4/4 identical.
  • Hosted CI at dab63909 is currently queued.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge train note (code-owner ping <@422957901716652033>): dab63909 is a forward merge of main, with code byte-identical to the approved and tested 334dbc6c. App approved at this head; rows J714s (G17S) + J700 (G17P). Merges under the 6-point rule in 1 h once hosted CI is green.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J700 exact-head smoke passed at dab639093cde4b5d4b8fdf6e72b04f4457ecff8d via one-shot GRUB boot. The running kernel and loaded aurora.ko build IDs matched, four-plane SLC was enabled, and MCC DT status was okay. Vulkan smoke passed 9/9 with seven exact CRC matches against stock and the benchmark references. Publication traces confirmed direct render in the render, concurrent, and compute-prefixed workloads. Zero WARN/BUG/Oops, GPU faults, or AVCs.

Stock 7.3.0-41 returned with four-plane SLC, identical persistent boot state, and all trial files removed. The Asahi Image modules dtbs build had zero errors and zero warnings in touched driver files. G17 host tests passed 260/260.

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

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

Verdict: CODE-CLEAR at dab639093cde4b5d4b8fdf6e72b04f4457ecff8d

Audited all 5 touched files, forward-merge resolution (dab639093cde), dependency parity between Pair::own_dependencies() + Firmware::lend_render() and Registry::render_dependencies(), build, host tests, and negative controls.

Verification Summary

  • Merge & hygiene: dab639093cde is a clean forward-merge onto origin/main (driver files drivers/gpu/drm/asahi/g17/{queue/render.rs,runtime/render/dependencies.rs,runtime/render/direct.rs} are byte-identical to 334dbc6c7e8b; tools/asahi/run-host-tests.py keeps both g17-direct-stage-prefixes-tests.py and g17-m5-governor-stop-tests.py). All PR commits carry valid Signed-off-by, git diff --check is clean, and scripts/checkpatch.pl --strict --no-tree reports 0 errors / 0 code warnings (1 standard new-file MAINTAINERS notice on the test script).
  • Build & host tests: LD [M] drivers/gpu/drm/asahi/aurora.o compiles cleanly with 0 errors and 0 warnings in touched files. g17-direct-stage-prefixes-tests.py passes (including all 8 mutation traps); an independent negative control substituting the whole-render prefix for tiling_wait_through[0] failed at the expected direct-vs-mutex parity assertion. (Observed Apple DCP host-test failures reproduce identically on unmodified origin/main baseline.)
  • Correctness audit:
    • Registry::has_other_pair_dependencies() executes ahead of Pair::host_growth_target(), checks both wait_through[0] and tiling_wait_through[0], and covers both resident pairs and borrowed_dependencies (render and tiling prefixes), guaranteeing Pair::own_dependencies() matches Registry::render_dependencies().
    • Firmware::lend_render() resolves compute (tiling_wait_through[1]) and fragment_compute (wait_through[1] != tiling_wait_through[1]) under the device mutex and falls back cleanly (Ok(None)) on EAGAIN or non-zero recovery_state.

Non-blocking Pre-existing Follow-up Found During Audit

  • In drivers/gpu/drm/asahi/g17/queue/render.rs:1094 (introduced earlier by ef6ed2728bfc1 on main, not this PR), let mut fragment_types = [0u8; 5 + crate::g17::hazard::PUBLICATION_BARRIERS]; (len = 12) omits + crate::g17::pairs::COMPUTE_CHANNELS_MAX, whereas barriers.fragment_types is sized 4 + COMPUTE_CHANNELS_MAX + PUBLICATION_BARRIERS (len = 14) and barriers.fragment_count can reach up to 13. On M5 (COMPUTE_CHANNELS_MAX = 3) with fragment_count >= 11 (reachable on both the existing device-mutex path and now render_direct()), lines 1095/1097 would panic out of bounds. Worth fixing in a 1-line follow-up (5 + crate::g17::pairs::COMPUTE_CHANNELS_MAX + crate::g17::hazard::PUBLICATION_BARRIERS).

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging under the 6-point rule (Ryan 09:29, permanent), at dab63909. (1) The review App approved at this head. (2) Full CI is green. (3/4) Rows: J714s+J700;fwd-merge-of-334dbc6c. (5) There's no blocking review. (6) Dj was pinged here 555 min ago with no objection. Revert: git revert -m 1 <merge>.

@RyanTheTide
RyanTheTide merged commit 3778e23 into main Nov 29, 2026
21 of 22 checks passed
@RyanTheTide
RyanTheTide deleted the perf/g17-direct-render-stage-prefixes branch November 29, 2026 02:31
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:none 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