Skip to content

drm/asahi: g16: map the render notifier records ASC-cached - #3298

Closed
DjDeveloperr wants to merge 3 commits into
mainfrom
perf/g16-m4-render-notifier-cached
Closed

DjDeveloperr wants to merge 3 commits into
mainfrom
perf/g16-m4-render-notifier-cached

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

What: on the M4 (G16G, 26B123 firmware), map the render notifier records ASC-cached, as macOS does. This is the render half of #3285 and is stacked on it (base: perf/g16-compute-notifier-cached); depends on #3285.

The firmware reads and updates the render notifier records (TA and FS, one page) around every finished TA and FS pass. G16 mapped that page uncached, so every finished pass paid for uncached firmware loads and stores on the path between passes.

Tested: J773g (M4 Mac mini) at d49f3e75952b (measured kit built from a94d58813752, same tree; only the commit message changed): render rows +4.6 to +9.2 % against #3285, render.shadow d16 depth-only d2 −3.2 %; CTS subset 9,639 pass / 0 fail; s2idle ok; 0 GPU faults, recoveries or hangs on 5 boots.

row (µs, lower is better) #3285 this PR change Metal 4 #3285 / Metal this / Metal
render.light tri d16 59.71 54.72 +9.1 % 48.29 0.809× 0.882×
render.light tri d64 60.91 56.06 +8.6 % 44.99 0.739× 0.802×
query occlusion d16 59.74 54.72 +9.2 % 47.84 0.801× 0.874×
render.bindless_ubo 512 ubo_vec4 d2 179.70 165.88 +8.3 % 125.19 0.697× 0.755×
render.bindless_ubo 512 ubo_vec4 d1 289.58 269.25 +7.6 % 340.60 1.176× 1.265×
render.postfx 1080p MSAA4 d2 741.85 688.86 +7.7 % 520.83 0.702× 0.756×
render.light tri procs d4 81.87 75.92 +7.8 % 104.47 1.276× 1.376×
render.light tri procs d16 68.39 63.68 +7.4 % 94.84 1.387× 1.489×
concurrent.cr interleave d4 64.81 61.53 +5.3 % 57.10 0.881× 0.928×
render.mdi 1024 draws d4 126.83 121.29 +4.6 % 86.27 0.680× 0.711×
render.deferred tile MSAA4 d2 332.97 325.73 +2.2 % 255.10 0.766× 0.783×
render.shadow d16 depth-only d1 789.47 775.20 +1.8 % 862.07 1.092× 1.112×
render.heavy fill 1080p d2 258.96 258.18 +0.3 % 252.53 0.975× 0.978×
compute.light d16 26.77 26.53 +0.9 % 23.89 0.892× 0.900×
query timestamp d16 26.89 26.50 +1.5 % 23.91 0.889× 0.902×
render.shadow d16 depth-only d2 452.49 467.29 −3.2 % 434.78 0.961× 0.930×
  • Stress on this PR:
    • concurrent.cr interleave ×10.
    • Multi-process render.light --mode procs d4,16 ×10: 20/20 ok.
    • render.postfx d1,2 ×3 and query occlusion d1,16 ×3.
    • All runs ok; driver health clean after each.
  • Vulkan CTS subset, single worker (memory.pipeline_barrier, synchronization basic/smoke/implicit/none_stage/layout_transition, timeline_semaphore 1/4, op.single_queue 1/40, compute.pipeline.indirect_dispatch, draw.renderpass.indirect_draw, multisample 1/8, renderpasses 1/80, draw 1/6, compute 1/25; 13,810 cases): 9,639 pass, 4,171 not supported, 0 fail, 0 recoveries. The 1,024 synchronization implicit cases were then run 3 more times: 1,024/1,024 pass each time.
  • One RTC s2idle cycle: woke after 13 s, suspend success +1, no new kernel errors; post-wake gpubench smoke 7/7 rows with correct CRCs.
  • Faults: 0 GPU faults, 0 recoveries, 0 hangs and 0 new kernel errors on all 5 boots with this PR or drm/asahi: g16: map the compute notifier records ASC-cached #3285. Every CRC correct. After each session the Mac was back on its default kernel with 0 failed units.
  • Host: the asahi-m4 host selftests pass, 26/26 files. test-stamp-wrap.py (render stamps in the user-stamp cells, the cached page is never read) and test-resources.py (the render page class) are updated. checkpatch --strict clean, no new rustfmt hunks.

Risk: two-way door (a plain revert undoes it) · Macs on the g16 backend (M4; the M3 Pro/G15S and M3/G15G layouts share this render path)

  • Scope: only the render notifier page's mapping and where the host reads the render completion stamps.
  • If the firmware didn't maintain the cached record the way 26B123 does, render completions would stall: missing stamps and a hang, not wrong results. The CTS, multi-process and stress runs above cover this on the J773g.
  • render.shadow d16 depth-only at depth 2 is 3.2 % slower (452 → 467 µs per submit; tight across boots: 450–454 vs 463–470 µs). Its GPU time is unchanged (445–450 µs), so the extra time is between frames. Depth 1 of the same row is 1.8 % faster. The cause is not known yet.

Not yet:

  • The cause of the render.shadow d16 depth-only d2 slowdown.
  • The full 202-row gpubench-vk suite on this PR (the rows above are targeted).
  • A row on a second G16 chip (T6040/T6041).
  • A J516s (M3 Pro, G15S) row: the g16 backend is shared, so the G15S layout also gets the cached render notifier page.
Details
  • Lab traces on the J773g (per-pass TA/FS stamps) with the cached page: the in-batch gaps between passes are unchanged, but the firmware takes more records per batch. render.light d16+64 showed 101 → 75 record-boundary stalls of 60 µs or more, and batches grew from about 6 to about 8 passes. So the uncached notifier work sits in the firmware's end-of-batch turnaround.
  • An earlier lab kernel that combined this change with an experiment retiring render flights before their notifier stamps crashed the GPU firmware in a multi-process run. That experiment is not part of this PR or of main. This PR alone ran the same multi-process workload ×10 cleanly (above).
Evidence

The firmware reads and updates the render notifier records (TA at +0,
FS at +0x200 of one page) around every finished TA and FS pass. G16
mapped that page uncached, so each finished pass paid for uncached
firmware loads and stores on the path between passes. macOS 26B123
maps its notifier records ASC-cached and keeps the service stamps in
separate uncached cells; the previous commit does the same for compute.

Map the render notifier page ASC-cached. The host writes it only
before the firmware first sees it and never reads it back. Move the TA
and FS service stamps from that page to the TA and FS queues' own
uncached user-stamp cells, which the render receipt now reads. Drop the
reads of the records' context words from the render receipt, as the
previous commit does for compute: the service stamps are device-wide
draw stamps, so a stamp equal to a flight's target names that flight.

On the J773g (M4 Mac mini), against the previous commit (A/B/B/A over
four boots): render.light tri d16 +9.1 %, d64 +8.6 %, render.postfx
1080p MSAA4 d2 +7.7 %, render.bindless_ubo d2 +8.3 %, query occlusion
d16 +9.2 %, concurrent.cr interleave +5.3 %, render.mdi d4 +4.6 %;
render.shadow d16 depth-only d2 is 3.2 % slower.

Signed-off-by: DjDeveloperr <hey@djdev.me>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 26, 2026 18:48
@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) 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 d77a6c6c: not ready yet

Check Detail
CI at head no failing: KUnit ane-boot, KUnit dcp-fabric, KUnit dcp-topology, KUnit asahi, KUnit asahi, KUnit spi-hid-apple
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 d77a6c6c
Conflicts ok none
PR text ok Risk: two-way · (a plain revert undoes it) · Macs on the g16 backend (M4; the M3 Pro/G15S and M3/G15G layouts share this render path) - Scope: only the render notifier page's mapping and where the host reads the render completion stamps. - If the firmware didn't maintain the cached record the way 26B123 does, render completions would stall: missing stamps and a hang, not wrong results. The CTS, multi-process and stress runs above cover this on the J773g. - render.shadow d16 depth-only at depth 2 is 3.2 % slower (452 → 467 µs per submit; tight across boots: 450–454 vs 463–470 µs). Its GPU time is unchanged (445–450 µs), so the extra time is between frames. Depth 1 of the same row is 1.8 % faster. The cause is not known yet.

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 removed the ci-failing A check failed 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 at d49f3e75

Blockers:

  1. Targets open non-main base branch perf/g16-compute-notifier-cached (#3285 is still OPEN); full main CI has not run.

Checked:

  • Verified #3285 is still OPEN and base ref is perf/g16-compute-notifier-cached.
  • Deferred final approval until #3285 lands and this PR is retargeted onto main with green CI.
Evidence
  • Base ref: perf/g16-compute-notifier-cached (#3285 state: OPEN).

Base automatically changed from perf/g16-compute-notifier-cached to main November 28, 2026 06:12
@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Nov 29, 2026
Signed-off-by: DjDeveloperr <hey@djdev.me>
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed merge-conflict Conflicts with the base branch (bot) labels 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: HOLD at caa89940 for hosted CI and shared G16 backend hardware evidence.

Checked: #3285 merged and this branch now targets main. The render completion path reads the separate uncached TA/FS service stamp cells, and the updated fixture asserts no reads of the cached notifier page. Four of the six PR-path blobs differ from the J773g-tested d49f3e75 after the forward merge. Keep that result attributed to its tested tree and provide current-head evidence or maintainer acceptance of equivalence. The second G16 chip and shared G15S backend rows listed in the PR remain open.

@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 at d77a6c6

Blockers: Current-head hosted checks and current or equivalent G16 hardware evidence remain.

Checked: The J516s G15S row at caa8994 passed 38 checks and all 18 pinned CRCs. The forward merge leaves all six reviewed render-notifier and test paths unchanged, so that peer result carries forward. The older J773g row predates changes to four of those paths and still needs separate equivalence or a refreshed run.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J516s second-generation row, 30 Nov: PASS. 38/38 rows passed and 18/18 pinned CRCs matched, including compute.uber uniform b022fbaf, postfx MSAA4 668d6f0a, bindless UBO 1af53d5c, and D16 shadow c0fb9993. Zero GPU faults, recoveries, hang kills, compute/render quarantines, or failed units.

M3 Pro J516s (T6030, G15S), 30 Nov 2026. Both arms used their own one-shot kernel and matching aurora.ko built from the same source commit, SLC on (all six planes), Borealis 69179743d9ae, and GPUBench cba9025d3fd9. Baseline kernel/driver source was main e6c7b032633cd0018a90bfc8fe6fb9f3bc3890f9. Tested at caa89940ab365c41a7d1dd794addf0926c70fbba. The current head d77a6c6c795e9752a61dd9197b2fc2034f3323c6 differs only by a merge from main that touches none of this PR's files.

Staged aurora.ko SHA-256: main 456f346552b20a12d28ab2b53bdf59027ba03769c3224cd010fd7747dbb21f6f, PR 25440e90be2575577718d1a25715c2e6090ac7eb500a38f5e8fdd68433806dd1.

Two-pass wall-time smoke measurements vs baseline: compute.light d16 +1.4%. Compute.uber uniform d4 was 139.82/124.50 µs vs 124.38/124.50 µs. Render.light tri d8/d16/d64 was −7.4%/−10.2%/−11.7%, postfx MSAA4 d2 −1.1%, D16 depth-only shadow d2 flat (723.60 → 723.59 µs), and mixed compute/render d4 −10.5%. The interleave row was rerun on both staged kernels after correcting its CLI arguments.

Evidence on the controller is in work/m3pro-bringup-20261124/rows-render3-e6c7b032/evidence-20261130T112653Z-qxQe5jS7/RESULTS.md, with raw rows and stages.tsv in the same directory.

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

Copy link
Copy Markdown
Contributor Author

J773g (M4 mini, T8132 G16G) target row at d77a6c6c795e9752a61dd9197b2fc2034f3323c6: render rows 6–9 % faster and outputs match, but one repeatable regression. render.shadow fmt=d16 depth_only res=2048 at depth 2 is +3.6 % on every PR boot against every main boot. An earlier single-boot screen showed +4 % on the same row.

Setup

  • Kernel: linux main dbfbced70b31 (release 7.3.0-ARCH-m4kmain-dbfbced7), with aurora.ko built from this head's drivers/gpu/drm/asahi. That tree is byte-identical to the pre-merge PR tree, and the main..head diff equals the PR patch.
  • Userspace: Borealis Mesa 285776c6af, gpubench-vk 868b0644 (VK rows check their output CRC in every run), 300 ms warmup, 5 × 250 ms windows, two passes per boot.
  • Boot order: main, this PR, this PR, main.
  • Values: µs per submission.
Row main this PR Δ every PR boot vs every main boot
render.light tri d16 / d64 59.52 / 53.16 54.86 / 48.21 −7.8 / −9.3 % faster
render.postfx msaa4 1080p d1 / d2 773.62 / 698.17 719.51 / 646.96 −7.0 / −7.3 % faster
render.bindless_ubo 512 ubo_vec4 d1 / d2 232.32 / 168.92 213.94 / 159.07 −7.9 / −5.8 % faster
render.deferred tile msaa4 1080p d2 289.60 289.10 −0.2 % faster
render.shadow d16 depth-only 2048 d2 451.69 468.17 +3.6 % slower
compute.uber uniform d4 171.35 171.35 0 equal

Not yet: held for a host-side trace. The row definition allows no repeatable regression over 1 %, and the D16 depth-only shadow loss below is repeatable. The cost is on the host side, so it gets traced on Linux next (the submit/command-record path on this head against main), fixed on the branch, and re-run as a matched ABBA, with D32F included.

Where it comes from. A bounding build from this head returned only the render notifier mapping to uncached and kept the two stamp cells and the polling code. One boot each (main / this PR / bound):

  • D16 depth-only shadow d2: 451.3 / 472.6 / 450.9 µs. The bound build recovers it.
  • Every gain above also disappears in the bound build (render.light, postfx, bindless_ubo). The same mapping change produces both the wins and this row's loss.
  • The extra time is host-side, not GPU-side:
    • Pass and prefix counts per job, PB epochs, growth (0) and kernel prep per job (about 11.5–11.9 µs) are the same in all three arms.
    • TA/FS service per job is the same too: 199/427, 197/428 and 196/426 µs.
    • With the cached mapping, the workload's command-record p95 goes from 11.3 to 167.2 µs and the GPU gap p95 from −2.6 to 122.7 µs. The first completion event arrives about 90–100 µs earlier.
    • This looks like a refill/notification tail in this workload's submit pattern. Current counters can't pin it to a specific poll or firmware step.
  • No mergeable fix from this evidence: the only lever found trades away all the gains.
  • D32F in the same trial: 434 µs on main vs 459 µs with this PR (two-pass means). The earlier matched ABBA didn't show it; worth watching.

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Dec 1, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Superseded by #3724, which caches only the FS record (plus the same-VM barrier change). Caching the TA record made render.shadow d16 3.8 % slower; it comes back as its own PR after the per-flight completion-event work.

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) ci-failing A check failed at the PR head (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.

1 participant