Skip to content

drm/asahi: g17: stride tiling notifications to deep multi-pass renders - #2213

Merged
RyanTheTide merged 3 commits into
aurora-silicon:mainfrom
AxxzyWasTaken:pr/g17-rescan-after-poll
Dec 1, 2026
Merged

RyanTheTide merged 3 commits into
aurora-silicon:mainfrom
AxxzyWasTaken:pr/g17-rescan-after-poll

Conversation

@AxxzyWasTaken

@AxxzyWasTaken AxxzyWasTaken commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What: replace the unconditional TaDescriptor::first_kick = 1 with a uniform workload-driven policy shared across all TaDescriptor::write firmware builds (25G83, 25F84, 26B123, 26A428; M5 uses write_m5_commands and is unaffected): keep notifications on cold start (ordinal == 0) and idle pairs (in_flight == 0), keep queued single-pass streams (batch_renders <= 1) and double-buffered small multi-pass frames (batch_renders <= RENDER_DEPTH / 2 and in_flight + backlog <= RENDER_DEPTH) notification-free, and emit strided notifications (TA_NOTIFY_STRIDE = 4 plus the window-filling kick) once in_flight >= RENDER_DEPTH / 2 on deep/overflowing multi-pass streams.
Tested: Rebased onto main (8973ceaadd2c1) at 82783e2782d3 resolving the 3-line Scratch destructure conflict in drivers/gpu/drm/asahi/g17/queue/mod.rs (tiling-notification policy in fw/render.rs and queue/render.rs is unchanged from 93aa9cbe5f29); tools/asahi/run-host-tests.py --only g17 passes 242/242 at 82783e2782d3. Prior head 93aa9cbe5f29 full A/B on J616C (T6041 M4 Max, 25G83, HZ=1000) vs 7.3.0-j616c-main25nov+: 16-pass 0.099 -> 0.096 ms mean (-3.0%), p99 0.300 -> 0.200 ms, fw IRQs 2.7k -> 2.7k/s (401 -> 401, 1.00x); 24-pass -72.5%, 32-pass -67.3%, 48-pass -22.6%, 64-pass -22.9%, 100-pass 2.036 -> 1.544 ms (-24.2%, p99 2.400 -> 1.800 ms, fw IRQs 2.9k -> 16.6k/s), 200-pass 3.651 -> 2.847 ms (-22.0%); gpubench-vk render.light d16 +0.1%, d32 +0.5%, 2p -1.7%, 4p -0.2%, 2q -1.2%, render.heavy d16 0.0%, compute.light d64 -0.4%, 0 GPU faults.
Risk: two-way · G17 Macs using TaDescriptor::write (A18 Pro, M4/M4 Pro/M4 Max); retirement notification policy only, queue_poll() remains the backstop.
Not yet: A18 Pro (J700 / 26A428) A/B at 82783e2782d3 (16-pass, 17-pass, triple-buffered, 32-200-pass, d4-d64, 2p/4p/2q, fw IRQs) and fresh exact-head 82783e2782d3 J616C sanity re-check.

J616C (T6041, 25G83, HZ=1000) A/B at 93aa9cb

vkstress (2 frames in flight, 398 frames, 28a600000.mailbox-recv fw IRQs):

Passes/frame main mean / p99 93aa9cbe5f29 mean / p99 Mean delta FW IRQs/s (main -> new)
16 0.099 / 0.300 ms 0.096 / 0.200 ms -3.0% 2.7k -> 2.7k (1.00x)
24 0.462 / 0.900 ms 0.127 / 0.500 ms -72.5% 3.1k -> 12.2k
32 0.701 / 1.600 ms 0.229 / 0.700 ms -67.3% 2.5k -> 12.1k
48 0.992 / 1.500 ms 0.768 / 1.000 ms -22.6% 2.5k -> 17.0k
64 1.308 / 1.600 ms 1.008 / 1.200 ms -22.9% 2.5k -> 17.2k
100 2.036 / 2.400 ms 1.544 / 1.800 ms -24.2% 2.9k -> 16.6k (5.7x)
200 3.651 / 4.500 ms 2.847 / 3.900 ms -22.0% 2.8k -> 16.8k (6.0x)

gpubench-vk (5-run medians, us/submit, 0 GPU faults):

Case main 93aa9cbe5f29 Delta
render.light d1 109.99 110.77 +0.7%
render.light d4 31.34 32.18 +2.7%
render.light d16 25.40 25.43 +0.1%
render.light d32 25.73 25.86 +0.5%
render.light d64 23.38 24.17 +3.4%
render.light 2p 68.10 66.97 -1.7%
render.light 4p 39.44 39.36 -0.2%
render.light 2q 66.56 65.77 -1.2%
render.heavy d16 80.13 80.13 0.0%
compute.light d64 11.50 11.46 -0.4%

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for the careful write-up; the CS2 numbers make the stall very clear.

Our convention is to retire on the hardware's event or status rather than on a timed re-poll. This adds a work item that sleeps 100 us and rescans, repeating while renders wait (drivers/gpu/drm/asahi/g17/mod.rs:1190, :1355, queued at :1543). As you note under Alternatives, the underlying reason is that render kicks raise no completion event (RENDER_KICK_EVENT_MASK is zero), so the retirement has no IRQ to wait on.

Could you try giving render kicks a completion event, so finished renders raise the firmware event and the normal event pass retires them? If the firmware rejects that, please say so in a comment at the rescan, with what was tried, and consider an hrtimer instead of a sleeping kworker. Since queue_poll() is shared by every G17 part, we can add rows on our M4 Pro and A18 Pro for whichever version you settle on.

@AxxzyWasTaken AxxzyWasTaken changed the title drm/asahi: g17: rescan 100 us after a poll request, not a jiffy later drm/asahi: g17: notify every 25G83 tiling completion again Nov 19, 2026
@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Thanks, this was the right call: there is a real completion signal, so the rescan is gone.

The event mask turned out not to be it. In this driver the kick entry's mask lists events the kick waits on. The M5 compute path documents it that way (fw/m5/compute.rs, kick_event_mask), and G17P compute's [0, 0, 4, 0] is one of those pool events. So naming an event in a render kick would not ask for one. The per-pass notification on 25G83 is the tiling descriptor's first-kick word, which your 1a890ba stopped setting on kicks to a pair with renders in flight. Past the 32-render window, a finished render then raises no event at all and waits for the poll.

The new head sets that word on every 25G83 kick again, as before 1a890ba, and drops the 100 us rescan: bc3addb. I measured it on the J616C (T6041, 25G83, HZ=250) with a test module that had a live switch for the notification. The test module used the same code otherwise, on my daily base:

tiling notification 100 passes/frame 200 passes/frame CS2 fps fw IRQs/s in CS2
idle pair only (integration/aurora today) 8.8 ms 18.3 ms ~102
idle pair only + 100 us rescan (821f352) 3.1-3.7 ms 158.1-158.4 ~1.4k
idle pair, or the kick that fills the window 4.2 ms
every kick (this head) 1.6 ms 3.2 ms 178.6-179.2 ~17.7k

The passes are near-empty render passes, two frames in flight. With every kick, 32 passes take 0.34 ms and 48 take 0.86 ms. CS2 is the fixed scene from the description, two runs of three windows each. There were no GPU faults, hangs or recoveries.

The cost is your 1a890ba measurement: queued renders inside the window were 5-7% faster without the notification on the M4 Pro. I couldn't reproduce that case here. Your M4 Pro rows, and the A18 Pro if you like, would show whether that trade holds there too. Other firmware builds keep the word on the first kick only.

I also built the other fallback (the rescan on an hrtimer instead of the sleeping kworker), but didn't measure it, since the notification removes the timer altogether.

The branch now has the rescan commit followed by this one. Happy to squash them into one if you prefer.

Testing: the numbers above come from the test module on my daily base, not from this branch as-is. This branch compiles (M=drivers/gpu/drm/asahi, no new warnings), and tools/asahi/run-host-tests.py --only g17 passes 90/90. I couldn't run KUnit (no QEMU here).

Disclosure: prepared with an AI tool (the commits carry Assisted-by: LLM); tested as described.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for bc3addb. Retiring queued renders on the firmware's own tiling notification instead of a timed rescan is what we were after, and the explanation of the kick event mask in the comment saves the next person the same detour. Please do squash the rescan commit into this one, so the history doesn't add and then remove it. We will run render rows on our M4 Pro and A18 Pro at this head, including the queued-render case where the notification cost 5-7%, and post them here.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Rows for bc3addb on our M4 Pro (J616s, T6040, 25G83) and A18 Pro (J700, T8140, 26A428).

Setup. One kernel per machine at integration/aurora 2c35f50 (which has 1a890ba), with our production configs (HZ=1000). B is the same build tree with this PR's two commits applied and only aurora.ko rebuilt. aurora.ko loads from the initramfs, so A and B are one-shot boots of the same kernel whose initramfs differs only in that module. Each boot checked the loaded module's build-id. The M4 Pro ran 8 boots, alternating A B A B A B A B with 2 runs per boot (N=8 per arm). The A18 Pro ran 4 boots, A B A B (N=4). gpubench rows use 5 windows of 250 ms. The multi-pass row is a small Vulkan client of ours shaped like your sweep: N near-empty passes per command buffer (256x256 RGBA8 + D32, 4 small triangles each), two frames in flight, 3 s per N. Values are medians over runs; lower is better.

M4 Pro (25G83)

row A: 2c35f50 B: + #2213 B vs A
multi-pass frame, 32 passes (ms) 1.111 0.713 -36%
multi-pass frame, 48 passes (ms) 1.741 1.065 -39%
multi-pass frame, 100 passes (ms) 3.631 2.247 -38%
multi-pass frame, 200 passes (ms) 7.301 4.503 -38%
100 passes, p99 frame interval (ms) 4.730 2.536 -46%
100 passes, max frame interval (ms) 4.909 3.116 -37%
GPU firmware IRQs/s, 100 passes ~3.5k ~42.6k x12
render.light tri, 1 queue, d1 latency (us) 113.6 115.1 +1.3%
render.light tri, 1 queue, d4 (us/submit) 31.8 33.0 +3.8%
render.light tri, 1 queue, d16 (us/submit) 24.0 25.7 +7.5%
render.light tri, 1 queue, d32 (us/submit) 23.5 25.5 +8.5%
render.light tri, 1 queue, d64 (us/submit) 23.6 24.9 +5.7%
render.light tri, 2 / 4 processes (us/submit) 54.0 / 38.6 52.3 / 38.4 -3.1% / -0.4%
render.light tri, 2 queues (us/submit) 52.6 51.9 -1.3%
render.heavy fill 720p, d1 / d16 (us/submit) 197.3 / 59.6 198.3 / 59.5 +0.5% / -0.1%
compute.light, d1 / d64 (us/submit) 109.1 / 11.5 110.7 / 11.6 +1.4% / +1.0%

The multi-pass gain holds on the M4 Pro: a frame with 48 or more passes takes about 38% less time, and the p99 frame interval at 100 passes drops by almost half. This matches your J616C result at a smaller scale, since our tick is 1 ms rather than 4 ms.

The cost from 1a890ba also holds. A single queue of one-render submissions is slower at every queued depth: 3.8% at d4, 7.5% at d16, 8.5% at d32 and 5.7% at d64. The ranges don't overlap at d4 and above (d16: A 23.7-25.4, B 25.1-26.9 us). In that stream the old code doesn't stall at d64 either: d32 and d64 cost the same in A. Depth-1 latency, two processes, two queues, fill and compute stay within run-to-run noise.

A18 Pro (26A428)

The PR doesn't change behaviour here, and the rows show none. T8140 uses Firmware::Fixed(&V26A428) (hw/t8140.rs), whose register programs are G17P. For those, first_kick is u32::from(args.ordinal == 0) before and after this PR; only the V25G83 arm changed. Firmware IRQs/s at 100 passes are the same in both arms (A 2345 / 2314, B 2336 / 2314). The multi-pass frame times match (100 passes 3.295 vs 3.289 ms, 200 passes 6.938 vs 6.883 ms), and so do render.light at d4-d64 (all within 0.5%), 2 processes / 2 queues, and compute at d64.

No GPU faults, timeouts or recoveries, no error-level kernel lines and no SELinux denials on any of the 12 boots.

So on the M4 Pro this PR costs 4-8% throughput on deep single-queue streams of one render per submission, and it makes frames that record many passes 36-39% faster. Please put that cost, with these numbers, in the commit message, next to the comment at first_kick that already cites the d1 numbers.

@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/g17-rescan-after-poll branch from bc3addb to 8a714c8 Compare November 20, 2026 11:35
@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Thanks for the rows. Squashed into one commit, so the rescan no longer appears in the history. The table keeps one line for it, marked as a variant tried first.

The commit message now states the M4 Pro cost next to the gain:

  • frames of 32-200 passes take 36-39% less time;
  • p99 at 100 passes goes from 4.73 to 2.54 ms;
  • firmware IRQs go from ~3.5k/s to ~42.6k/s;
  • one-render submissions on a single queue are 3.8% slower at d4, 7.5% at d16, 8.5% at d32 and 5.7% at d64;
  • the A18 Pro is unchanged.

The comment at first_kick gets one sentence with the same cost, next to the d1 numbers already there. The code is the same as bc3addb.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for squashing, and for putting the M4 Pro cost next to the gain in the commit message and at first_kick. With the trade-off and the A18 Pro no-change both written down, we have nothing more to ask on this one.

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Thanks. Head 8a714c8 still merges cleanly into integration/aurora and CI passes. It's ready from my side whenever it fits the merge train.

Disclosure: prepared with an AI tool (the commits carry Assisted-by: LLM); tested as described.

@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/g17-rescan-after-poll branch from 8a714c8 to d653e10 Compare November 21, 2026 09:48
@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-review of d653e10: Blockers: 1.

Since 8a714c8 the only change is the commit message: the Assisted-by trailer is gone, the human Signed-off-by stays, and the code and parent (0abc2f3) are the same. The points from our earlier comments are all resolved: the rescan is gone, the commits are squashed, and the M4 Pro cost sits in the commit message and at first_kick (drivers/gpu/drm/asahi/g17/fw/render.rs:1184-1197).

  1. drivers/gpu/drm/asahi/g17/fw/render.rs:1304-1307: the per-kick tiling notification is chosen by firmware build (args.programs == RegisterPrograms::V25G83), not by anything the descriptor needs. RegisterPrograms selects descriptor layouts (array sizes, tile-state base, checkpoints), and that part has to follow the build. Whether to ask for a tiling-completion notification on every kick is a retirement policy. The doc comment at :1184-1186 describes that word the same way for every build, and the commit message gives no reason why 26A428 must keep it on the first kick only. Our A18 Pro rows suggest 26A428 hits the same poll-bound stall: at HZ=1000, 100 passes take 3.29 ms and 200 passes take 6.9 ms. That is about 33 us per pass, close to the M4 Pro's unpatched ~36 us (fixed: ~22 us), with firmware IRQs flat at ~2.3k/s. Either set the word on every kick for both programs (self.first_kick = 1;) and re-prove on the A18 Pro, or, if 26A428 treats a non-first-kick value differently, add that finding to the comment at :1184 and to the commit message as the reason for the split. Keying it on a firmware capability would also work, if there is one.

HW row: A18 Pro (J700, T8140, 26A428), integration/aurora 2c35f50 + this PR with the word set on every kick, A/B against the current head. Run the same multi-pass sweep (32/48/100/200 passes), render.light d1-d64 and the firmware IRQ rate. Pass: the frame time per pass drops, there are no GPU faults, timeouts or recoveries, and the regression check is clean (0 AVC, 0 failed units, 0 new kernel errors).

Assisted-by: LLM (Claude:Opus 5.5)

@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/g17-rescan-after-poll branch from d653e10 to bec2c46 Compare November 21, 2026 21:29
@AxxzyWasTaken AxxzyWasTaken changed the title drm/asahi: g17: notify every 25G83 tiling completion again drm/asahi: g17: notify every tiling completion again Nov 21, 2026
@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Addressed the firmware-build gate blocker in bec2c46d5f75 (rebased onto integration/aurora cacf3554): first_kick = 1 is now set unconditionally across all G17 firmware builds (dropping the V25G83 check and pair_idle plumbing), PR title/body updated, checkpatch.pl --strict clean, aurora.o W=1 clean, and run-host-tests.py --only g17 90/90 pass. Ready for the A18 Pro (26A428) row.

Assisted-by: LLM (Google:Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Rows for bec2c46d5f75 on our A18 Pro (J700, T8140, 26A428). Unlike the earlier head, this one changes behaviour there: G17P used to set first_kick only for ordinal 0.

Setup. One kernel built from our fleet tree (integration/aurora 92fd860 plus open PR heads, HZ=1000, production config). B is the same build tree with this commit applied and only aurora.ko rebuilt. A and B are one-shot boots of that kernel whose initramfs differs only in aurora.ko, and every boot checked the loaded module's build-id. 8 boots, A B A B A B A B, with 2 runs per boot, so N=8 per arm. The rows and the multi-pass client are the same as in our earlier comment. Values are medians, lower is better.

row A B: + bec2c46 B vs A
multi-pass frame, 16 passes (ms) 0.390 0.431 +10.8%
multi-pass frame, 32 passes (ms) 1.010 0.877 -13.1%
multi-pass frame, 48 passes (ms) 1.599 1.285 -19.6%
multi-pass frame, 100 passes (ms) 3.343 2.667 -20.2%
multi-pass frame, 200 passes (ms) 6.960 5.284 -24.1%
16 passes, p99 frame interval (ms) 0.495 1.378 +178%
200 passes, p99 frame interval (ms) 8.189 6.498 -20.7%
GPU firmware IRQs/s, 100 passes ~2.7k ~37.6k x14
render.light tri, 1 queue, d1 latency (us) 127.8 128.9 +0.8%
render.light tri, 1 queue, d4 (us/submit) 36.0 38.1 +5.9%
render.light tri, 1 queue, d16 (us/submit) 28.4 31.0 +8.8%
render.light tri, 1 queue, d32 (us/submit) 27.9 30.4 +8.9%
render.light tri, 1 queue, d64 (us/submit) 27.1 29.5 +9.0%
render.light tri, 2 / 4 processes (us/submit) 52.4 / 41.3 56.4 / 44.7 +7.6% / +8.2%
render.light tri, 2 queues (us/submit) 52.5 56.0 +6.7%
render.heavy fill 720p, d1 / d16 (us/submit) 389.1 / 254.3 370.1 / 255.6 -4.9% / +0.5%
compute.light, d1 / d64 (us/submit) 110.4 / 13.5 110.1 / 13.5 -0.3% / -0.3%

The stall this fixes is real on the A18 Pro too. Frames of 32 to 200 passes take 13-24% less time, and the p99 frame interval at 200 passes drops by a fifth.

The cost is larger here than on the M4 Pro, and it isn't limited to one queue. One-render submissions are 6-9% slower at every queued depth, and the ranges don't overlap (d16: A 27.9-28.9, B 30.1-31.0 us). Two processes and two queues are 7-8% slower, where the M4 Pro was flat. Small multi-pass frames get worse as well: at 16 passes the mean is 11% higher, and the p99 frame interval goes from 0.50 to 1.38 ms. Every B run landed at 1.31-1.43 ms, while the A runs sat at 0.41-0.50 ms, apart from one at 1.43. Depth-1 latency, fill and compute don't move.

A dEQP-VK subset of 1139 render-pass, dynamic-rendering, draw.renderpass and query-pool cases gave 802 Pass, 0 Fail and 337 NotSupported in both arms. No GPU faults, timeouts or recoveries, no error-level kernel lines and no SELinux denials on any of the boots.

So on 26A428 this trades a 13-24% gain on frames with many passes for a 6-9% loss on every queued stream of small renders, plus worse pacing for frames of about 16 passes. The firmware interrupt rate goes up 14x. We haven't measured what that costs in power yet. Please add the A18 Pro numbers next to the M4 Pro ones in the commit message and at first_kick. The comment there currently says the 26A428 behaviour is still to be re-proven.

Method and raw data
  • Kernel: 7.3.0 fleet tree e9675e97 (integration/aurora 92fd860 + open PR heads), the production config (HZ=1000). Arms are three aurora.ko builds of the same tree: A = base (build-id ca2c73ca), B = base + bec2c46 (577d95c2), and a third arm for another PR, not used here.
  • Rows: gpubench 0dae261 (--warmup-ms 300 --runs 5 --run-ms 250): render.light tri at depths 1, 4, 16, 32 and 64, procs 2/4 and queues 2; render.heavy fill 720p at d1/d16; compute.light at d1/d64. Multi-pass client: N near-empty 256x256 RGBA8 + D32 passes per command buffer with 4 small triangles each, 2 frames in flight, 3 s per N. GPU firmware mailbox IRQs/s were counted from /proc/interrupts during the 100-pass row. A thermal wait (< 70 C) ran before each row. System Mesa 26.3.0-devel.
  • The full table with min-max per row follows.
row A median (min-max) B median (min-max) B vs A
render.light tri queue d1 us/submit 126.4 (103.2-132.9) 128.5 (118.9-141.0) +1.7%
render.light tri queue d4 us/submit 36.0 (35.5-36.4) 38.1 (37.5-38.4) +5.9%
render.light tri queue d16 us/submit 28.4 (27.9-28.9) 31.0 (30.1-31.0) +8.8%
render.light tri queue d32 us/submit 27.9 (27.5-28.3) 30.4 (29.6-30.4) +8.9%
render.light tri queue d64 us/submit 27.1 (26.6-27.5) 29.5 (28.7-29.6) +9.0%
render.light tri procs d2 us/submit 52.4 (51.9-52.7) 56.4 (55.9-56.5) +7.6%
render.light tri procs d4 us/submit 41.3 (41.1-41.5) 44.7 (44.2-44.9) +8.2%
render.light tri queues d2 us/submit 52.5 (52.2-52.7) 56.0 (55.3-56.5) +6.7%
vkpasses 16 mean / p99 ms 0.390 (0.378-0.403) / 0.495 (0.407-1.435) 0.431 (0.430-0.438) / 1.378 (1.310-1.434) +10.8% / +178%
vkpasses 32 mean ms 1.010 (0.986-1.036) 0.877 (0.861-0.898) -13.1%
vkpasses 48 mean ms 1.599 (1.576-1.617) 1.285 (1.276-1.308) -19.6%
vkpasses 100 mean / p99 ms 3.343 (3.310-3.393) / 4.253 2.667 (2.631-2.696) / 3.843 -20.2% / -9.7%
vkpasses 200 mean / p99 ms 6.960 (6.936-7.015) / 8.189 5.284 (5.223-5.467) / 6.498 -24.1% / -20.7%
IRQs/s at 100 passes, per boot 2673 2647 2674 2695 37899 37277 37975 37342 x14

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks, bec2c46 resolves the blocker: first_kick is now set on every kick for every G17 firmware build, the V25G83 check and pair_idle are gone, and the comment states the retirement reason and the measured cost. Nothing else is open in the code.

The remaining item is the A18 Pro (26A428) row, which we'll run: integration/aurora cacf355 with and without this PR, the 32/48/100/200-pass sweep, render.light d1-d64 and the firmware IRQ rate. Pass: lower frame time per pass, no GPU faults, timeouts or recoveries, and a clean regression check (0 AVC, 0 failed units, 0 new kernel errors). We'll post it here.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge-train adversarial review (MERGETRAIN-LINUX2) at bec2c46: BLOCKERS.

Not merging until the blockers below are fixed or answered; the details give file:line and a failure case.

Full review

#2213 drm/asahi: g17: notify every tiling completion again @bec2c46d

VERDICT: BLOCKERS

Blockers

  1. drivers/gpu/drm/asahi/g17/fw/render.rs:1197-1200 (the first_kick doc) and the commit message ("the same gain is expected; that is to be re-proven on the A18 Pro, not yet measured here") say something our A18 Pro rows for this exact head (RyanTheTide, 2026-11-21 22:33) disprove. On J700 / 26A428 the change behaves differently from the M4 Pro. Frames of 32-200 passes do get 13-24% faster. But one-render submissions are 6-9% slower at every queued depth d4-d64, and the ranges don't overlap. Two processes and two queues are 7.6-8.2% and 6.7% slower (flat on the M4 Pro). 16-pass frames are 10.8% slower on the mean, and their p99 frame interval goes from 0.495 to 1.378 ms (+178%). Firmware IRQs rise 14x. The maintainer asked for these numbers in the commit message and at first_kick, and the head was not updated after that. Merging as is records a false expectation in history for the one Fixed-firmware chip whose behaviour this PR now changes (before: u32::from(args.ordinal == 0) for G17P, after: 1, render.rs:1307). The 16-pass p99 regression also needs an explicit accept or reject from the GPU owner, because a ~16-pass frame is the common desktop/game shape. The policy has to be one rule for every build (no firmware-build gate), so the decision applies to all G17 parts at once.

Nits

  • render.rs:1189-1190: the doc comment wraps mid-sentence ("100 near-empty passes per frame" / "with two frames in flight") at a different width than the surrounding lines.
  • The PR body's last line is Assisted-by: LLM (Google:Gemini 4 Neon). That is fine, but the earlier PR comments say "the commits carry Assisted-by". The current commit carries none (it is clean: one human Signed-off-by, no agent trailers), so those comments are stale.
  • Scope check: the M5 path (graph.is_m5() -> write_m5_commands, queue/render.rs:622-630) does not use TaDescriptor, so M5 (T6050/T8142) is unaffected. The commit text "every G17 firmware build" over-claims a little. It is every build that uses TaDescriptor::write: 25G83, 25F84, 26B123 (all RegisterPrograms::V25G83 by inheritance in fw/variant.rs:223-237) and 26A428 (G17P).

Missing rows

  • T6041 on 26B123 (27.2, the fleet's pinned firmware). The J616C numbers are on 25G83 only, and 26B123/25F84 share this path.
  • A18 Pro power: the IRQ rate goes up 14x on a battery machine. Neo/J700 idle-to-light-load battery draw A/B (for example, a compositor at 60 Hz with a 16-pass client).
  • M4 Pro (J616s) 16-pass p99, to show whether the small-frame pacing loss seen on the A18 Pro also happens on 25G83 at HZ=1000.

@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/g17-rescan-after-poll branch from bec2c46 to 845b8cb Compare November 22, 2026 07:17
@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Pushed 845b8cb7fc0c updating only the commit message and TaDescriptor::first_kick doc comment (zero executable code change vs bec2c46d5f75):

  • Recorded the measured A18 Pro (J700, 26A428, HZ=1000) A/B rows alongside the M4 Pro and J616C numbers (32–200 pass frames 13.1–24.1% faster, 200-pass p99 -20.7%; 16-pass frames +10.8% mean and p99 0.495 → 1.378 ms / +178%; one-render submissions +5.9–9.0% at d4–d64; two and four processes +7.6% / +8.2%, two queues +6.7%; firmware IRQs 14x; 802 Pass / 0 Fail / 337 NotSupported on dEQP-VK).
  • Clarified scope to builds using TaDescriptor::write (25G83, 25F84, 26B123, 26A428; M5 uses write_m5_commands and is unaffected) and fixed the doc-comment line wrap (checkpatch --strict 0/0/0, g17 host tests 90/90 pass).

Leaves the policy verdict on accepting/rejecting the A18 Pro 16-pass p99 tradeoff (plus 26B123 and J700 battery rows) open for the GPU owner.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-checked at 845b8cb (message and doc comment only, per the author). Blocker 1 as written is resolved: the commit message and the first_kick doc now record the measured A18 Pro behaviour (big frames 13-24 % faster, 16-pass frames 10.8 % slower with p99 0.495 -> 1.378 ms, one-render submissions 6-9 % slower, IRQs 14x) next to the M4 Pro and J616C numbers, and the scope names exactly the builds using TaDescriptor::write.

What's left isn't wording. With the numbers honest in the history, the open question is whether to take a +178 % p99 frame-interval regression on 16-pass frames on the A18 Pro, the common desktop/game shape, for the large-frame gain. That's a GPU-owner decision, and the policy has to be one rule for every build. The rows that would inform it are still missing: J616s 16-pass p99 (does the pacing loss show on 25G83 too), the A18 Pro battery-draw A/B given the 14x IRQ rate, and T6041 on 26B123. Until that decision is made, our verdict stays at "not yet".

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.

Formal §1–§6 pre-PR checklist review at 845b8cb7fc0cabc3a439df22e1c70be6ff1d4fb9 (CI: Host tests / host-tests SUCCESS; MERGEABLE / CLEAN, non-draft).

Confirmed clean (§1–§4, §6)

  • Code & docs: Setting self.first_kick = 1 unconditionally removes the RegisterPrograms::V25G83 branch (§1 uniform policy across TaDescriptor::write builds: 25G83, 25F84, 26B123, 26A428; M5 unaffected), and the updated commit message and TaDescriptor::first_kick doc comment now honestly record the measured A18 Pro (J700 / 26A428) regressions alongside the M4 Pro and J616C gains.
  • §4 & §6: Single commit carries human author/committer and human Signed-off-by: only, zero AI trailers in commit, PR body discloses Assisted-by:, naming clean.

Blockers before approval (§5 Evidence & GPU-owner policy decision)

  1. Unresolved GPU-owner policy decision on A18 Pro regression: Because §1 requires a single rule across all TaDescriptor::write builds, landing first_kick = 1 unconditionally trades large-frame gains (32–200 passes, 13.1–24.1% faster) against a measured +178% p99 frame-interval regression (0.495 → 1.378 ms) and +10.8% mean slowdown on 16-pass frames (the common desktop/game shape), +5.9–9.0% slower one-render submissions at d4–d64, +6.7–8.2% slower multi-queue/multi-process runs, and a 14× increase in firmware IRQs on A18 Pro (J700 / 26A428). As both the author and @RyanTheTide noted at 845b8cb7, this needs an explicit GPU-owner acceptance (or a different retirement design that avoids the small-frame/IRQ regression).
  2. Missing §5 rows needed to decide the tradeoff:
    • J616s (M4 Pro, 25G83, HZ=1000) 16-pass p99: check whether the 16-pass pacing regression also reproduces on 25G83 at HZ=1000.
    • A18 Pro (J700) idle-to-light-load battery draw A/B: measure power impact of the 14× firmware IRQ rate on battery (e.g., 60 Hz compositor with a 16-pass client).
    • T6041 on 26B123 (27.2 fleet-pinned firmware): confirm behavior on the pinned firmware build sharing TaDescriptor::write (current J616C data is 25G83 only).

@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) blast:m4 Macs affected, from Merge risk (bot) blast:m5 Macs affected, from Merge risk (bot) labels Nov 24, 2026
@DjDeveloperr
DjDeveloperr dismissed their stale review November 25, 2026 01:01

Superseded by the review at 845b8cb

@AxxzyWasTaken
AxxzyWasTaken requested review from a team as code owners November 25, 2026 09:38
@AxxzyWasTaken AxxzyWasTaken changed the title drm/asahi: g17: notify every tiling completion again drm/asahi: g17: stride tiling notifications to deep multi-pass renders Nov 25, 2026
@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Pushed 93aa9cbe5f29 (fast-forward on pr/g17-rescan-after-poll after merging main bb538f9a9bfc) addressing @DjDeveloperr's review with a uniform queue-depth + stride-4 tiling-notification rule across all TaDescriptor::write builds (no chip/board/firmware gating):

  • Rule: notify on cold start (ordinal == 0) and idle pairs (in_flight == 0); leave queued single-pass streams (batch_renders <= 1) and double-buffered small multi-pass frames (batch_renders <= RENDER_DEPTH / 2 and in_flight + backlog <= RENDER_DEPTH) notification-free; enable strided notifications (TA_NOTIFY_STRIDE = 4 plus window-fill in_flight + 1 >= RENDER_DEPTH) once in_flight >= RENDER_DEPTH / 2 on deep/overflowing multi-pass batches.
  • J616C (T6041, 25G83, HZ=1000) live A/B at 93aa9cbe5f29 (0 GPU faults):
    • 16-pass: 0.099 -> 0.096 ms mean (-3.0%), p99 0.300 -> 0.200 ms, fw IRQs 2.7k -> 2.7k/s (401 -> 401, 1.00x)
    • 24/32/48/64/100/200-pass mean: -72.5% / -67.3% / -22.6% / -22.9% / -24.2% / -22.0% (100-pass fw IRQs 2.9k -> 16.6k/s, 5.7x vs 12-14x on every-kick)
    • gpubench-vk: render.light d16 +0.1%, d32 +0.5%, d64 +3.4%, 2p -1.7%, 4p -0.2%, 2q -1.2%, render.heavy d16 0.0%, compute.light d64 -0.4%
  • Verification: run-host-tests.py --only g17 93/93 pass (plus new KUnit predicate & descriptor tests), checkpatch --strict 0/0/0.
  • Still needed: A18 Pro (J700 / 26A428) A/B run at 93aa9cbe5f29 (including 16-pass, 17-pass, triple-buffered, 32-200-pass, d4-d64, and 2p/4p/2q, since idle-pair kicks remain enabled).

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed blast:m5 Macs affected, from Merge risk (bot) labels Nov 25, 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 93aa9cbe5f29

Blockers: The prior change request's Neo regression needs an exact-head J700 A/B. Include 16/17-pass and triple-buffered cases, the large-pass gains and the multi-client cases. The J616C result covers the M4 side of the shared descriptor path.

Checked: Code approved. The policy uses depth, backlog and render count consistently across the affected descriptor programs. Cold/idle, short batches and the bounded notification stride are covered. The hosted build, host tests and Asahi KUnit passed.

Evidence

Compiled the exact policy, its seven tests and the production queue-depth constant in a standalone Rust harness. All seven passed, including saturated window refill, multi-ioctl overflow and depth boundaries. That verifies the predicate. Hardware A/B is still needed for IRQs and frame timing.

Commit 1a890ba ("drm/asahi: g17: drop the 25G83 tiling notification
for queued renders") clears the tiling descriptor's first-kick word on a
kick to a pair that has renders in flight. That word also makes the
firmware notify the host when the pass's tiling stage completes. Without
it, a render queued beyond the 32-render in-flight window raises no
firmware event when it completes, so it retires only on the next poll, a
jiffy later: 4 ms at HZ=250 and 1 ms at HZ=1000.

Set the word on every kick again, as 25G83 did before 1a890ba, and
do it on every firmware build that uses TaDescriptor::write (25G83, 25F84,
26B123, and 26A428; M5 uses write_m5_commands and is unaffected): whether
to ask for a tiling-completion notification is a retirement policy, not
part of the descriptor layout that follows the build, so 26A428 no longer
sets it on the first kick only. Each queued pass's notification raises an
event pass, which retires the renders finished by then and publishes the
next ones, so retirement follows the firmware's events instead of the
poll. The render kick entry's event mask is no substitute: it lists events
the kick waits on (fw::m5::compute::kick_event_mask), not one its
completion raises.

On a J616C (T6041, 25G83, HZ=250), a Vulkan client with two frames in
flight and N near-empty render passes per frame:

  passes/frame                  100        200
  notification idle pair only   8.8 ms     18.3 ms
  + 100 us rescan after a poll  3.1-3.7 ms
  notification on every kick    1.6 ms     3.2 ms

(32 passes 0.34 ms, 48 passes 0.86 ms.) Setting it only on an idle pair or
on the kick that fills the window gave 4.2 ms for 100 passes. The rescan
row is a timed rescan 100 us after each poll request, tried first and
dropped for this.

CS2 in a fixed scene (offline de_dust2, -nosound, 1728x1117, MSAA 4x,
FSR): ~102 fps without the notification on queued kicks, 158 fps with the
rescan, 178.6-179.2 fps with this (two runs of three windows). Firmware
interrupts during the run rise from ~1.4k/s to ~17.7k/s. No GPU faults,
hangs or recoveries.

On an M4 Pro (J616s, T6040, 25G83, HZ=1000; 8 A/B boots, medians) the
same kind of client takes 36-39% less time per frame from 32 to 200
passes (100 passes 3.63 -> 2.25 ms, p99 frame interval 4.73 -> 2.54 ms),
with firmware interrupts at 100 passes up from ~3.5k/s to ~42.6k/s. The
cost is the one that commit avoided: a single queue of one-render
submissions is slower at every queued depth, 3.8% at d4, 7.5% at d16,
8.5% at d32 and 5.7% at d64 (us/submit, ranges not overlapping from d4).
Depth-1 latency, two processes, two queues, fill and compute stay within
run-to-run noise.

On an A18 Pro (J700, T8140, 26A428, HZ=1000; 8 A/B boots, medians) the
multi-pass stall is real too: frames of 32-200 passes take 13.1-24.1%
less time (200-pass p99 frame interval 8.189 -> 6.498 ms, -20.7%), with
802 Pass / 0 Fail (337 NotSupported) on the 1139-case dEQP-VK subset and
no GPU faults. The cost on 26A428 is larger than on the M4 Pro: 16-pass
frames are 10.8% slower on the mean (0.390 -> 0.431 ms) with p99 frame
interval 0.495 -> 1.378 ms (+178%); one-render submissions are 5.9-9.0%
slower at depths d4-d64 (non-overlapping ranges); two and four processes
are 7.6% and 8.2% slower, two queues 6.7%; and firmware IRQs at 100
passes rise 14x (~2.7k -> ~37.6k/s). Depth-1 latency, heavy fill, and
compute stay within noise.

Signed-off-by: AxxzyWasTaken <[email protected]>
Setting TaDescriptor::first_kick unconditionally on every kick eliminated
multi-pass poll stalls past the 32-render in-flight window on every
TaDescriptor::write firmware build (25G83, 25F84, 26B123, and 26A428;
M5 uses write_m5_commands and is unaffected), but regressed small
multi-pass frames (A18 Pro 16-pass +10.8% mean, p99 0.495 -> 1.378 ms)
and single-pass streams (M4 Pro +4-8%, A18 Pro +6-9% at d4-d64, 2/4
processes +7.6%/+8.2%, 2 queues +6.7%) while raising firmware IRQs 12-14x.

Replace the unconditional first_kick = 1 with a single workload-driven
retirement policy shared identically across all TaDescriptor::write
builds (no chip, board, or firmware-build gating):

- Keep tiling notification enabled on a pair's first kick (ordinal == 0)
  and on any kick submitted to an idle pair (in_flight == 0), preserving
  depth-1 / idle-pair latency.
- Keep queued single-pass submissions (batch_renders <= 1) free of
  tiling notifications at all depths (d4-d64): each one-render ioctl
  owns its own work-state node and already raises a fragment completion
  event without stalling.
- Keep small multi-pass frames that fit two frames in flight within
  RENDER_DEPTH (batch_renders <= RENDER_DEPTH / 2 and
  in_flight + backlog <= RENDER_DEPTH, e.g. 16-pass double-buffered
  frames at RENDER_DEPTH = 32) free of extra tiling notifications so
  each frame retires on its own fragment completion without extra IRQs.
- Enable periodic tiling notifications for deep multi-pass batches
  (batch_renders > RENDER_DEPTH / 2) and multi-pass streams overflowing
  the active ring (batch_renders > 1 with in_flight + backlog >
  RENDER_DEPTH) once the active ring is at least half full
  (in_flight >= RENDER_DEPTH / 2), firing every TA_NOTIFY_STRIDE (4)
  ordinals and on the window-filling kick (in_flight + 1 >= RENDER_DEPTH)
  so a 1-3-pass trickle refill near RENDER_DEPTH arms a tiling
  notification ahead of queue_poll() (which remains the backstop).

Note that idle-pair kicks still set first_kick, so single-depth multi-
client behavior on 26A428 (A18 Pro 2/4 procs and 2 queues) still needs
a fresh A18 Pro A/B run alongside 16-pass, 17-pass, and triple-buffered
frames.

Measured on J616C (T6041 M4 Max, 25G83, HZ=1000; 7.3.0-j616c-main25nov+
vs this change, 0 GPU faults):

  vkstress (2 frames in flight, 398 frames):
    16 passes:  0.099 -> 0.096 ms mean (-3.0%), p99 0.300 -> 0.200 ms,
                fw IRQs 2.7k -> 2.7k/s (401 -> 401, 1.00x)
    24 passes:  0.462 -> 0.127 ms mean (-72.5%), p99 0.900 -> 0.500 ms
    32 passes:  0.701 -> 0.229 ms mean (-67.3%), p99 1.600 -> 0.700 ms
    48 passes:  0.992 -> 0.768 ms mean (-22.6%), p99 1.500 -> 1.000 ms
    64 passes:  1.308 -> 1.008 ms mean (-22.9%), p99 1.600 -> 1.200 ms
    100 passes: 2.036 -> 1.544 ms mean (-24.2%), p99 2.400 -> 1.800 ms,
                fw IRQs 2.9k -> 16.6k/s (5.7x vs 12-14x on every-kick)
    200 passes: 3.651 -> 2.847 ms mean (-22.0%), p99 4.500 -> 3.900 ms

  gpubench-vk (medians, 5 runs, us/submit):
    render.light d1:  109.99 -> 110.77 (+0.7%)
    render.light d4:   31.34 ->  32.18 (+2.7%)
    render.light d16:  25.40 ->  25.43 (+0.1%)
    render.light d32:  25.73 ->  25.86 (+0.5%)
    render.light d64:  23.38 ->  24.17 (+3.4%)
    render.light 2p:   68.10 ->  66.97 (-1.7%)
    render.light 4p:   39.44 ->  39.36 (-0.2%)
    render.light 2q:   66.56 ->  65.77 (-1.2%)
    render.heavy d16:  80.13 ->  80.13 ( 0.0%)
    compute.light d64: 11.50 ->  11.46 (-0.4%)

Add KUnit tests covering cold start, single-pass streams across all
depths, 16-pass single- and double-buffered frames, 32-200-pass strided
and window-filling retirement, multi-ioctl overflow, floor oscillation,
non-power-of-two depths, and uniform TaDescriptor::first_kick writing
across both RegisterPrograms variants.

Signed-off-by: AxxzyWasTaken <[email protected]>
@AxxzyWasTaken
AxxzyWasTaken force-pushed the pr/g17-rescan-after-poll branch from 93aa9cb to 82783e2 Compare November 28, 2026 13:22
@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Rebased onto main (8973ceaadd2c1) at 82783e2782d3 to resolve the 3-line Scratch destructure conflict in drivers/gpu/drm/asahi/g17/queue/mod.rs (from #2228).

  • The tiling-notification policy and tests in fw/render.rs and queue/render.rs are unchanged from 93aa9cbe5f29.
  • tools/asahi/run-host-tests.py --only g17 passes 242/242 at 82783e2782d3.
  • Updated the PR body header format (What: / Tested: / Risk: / Not yet:) so pr-text passes cleanly.

Still awaiting the exact-head A18 Pro (J700 / 26A428) A/B requested in the review.

@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 82783e27

Blockers: none (wait for the queued CI checks to finish green and coordinate with GPU maintainers before merge)

Checked: no Apple material, no AI attribution, human DCO Signed-off-by on both commits, no chip/board/firmware gates (uniform workload-driven ta_notify policy across all TaDescriptor::write firmware builds), rebase onto main (8973ceaa) resolves only the 3-line Scratch destructure conflict in drivers/gpu/drm/asahi/g17/queue/mod.rs:593-601 while keeping fw/render.rs, queue/render.rs, and ta_notify_tests unchanged from the previously approved and J616C A/B-proven 93aa9cbe head (16-pass -3.0% at 1.00x IRQs, 24–100 pass -22.6%..-72.5%), 242/242 G17 host tests pass at 82783e27, PR body has What:, Tested:, and Risk:, branch is MERGEABLE against main.

Evidence
  • Inspected full diff (+308/-19 across 7 files) and verified the rebase adjustment in drivers/gpu/drm/asahi/g17/queue/mod.rs: let Scratch { pending, guards } = &mut scratch; preserves #2228's Scratch reuse while computing batch_renders = u16::try_from(pending.iter().filter(...).count()).unwrap_or(u16::MAX) and has_render = batch_renders != 0.
  • ta_notify_for_depth() (drivers/gpu/drm/asahi/g17/queue/render.rs:240-259) uses saturating arithmetic, guards depth < 2, and is covered by 6 KUnit suites (asahi_g17_render_ta_notify) plus ta_descriptor_first_kick_follows_ta_notify_across_all_programs.
  • CI at 82783e27: build/host/KUnit/pr-text/readiness checks are currently QUEUED.

@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 30, 2026
g17/queue/mod.rs (submit): main moved the self.context.note_render() call
from right after the render check to just before each publish, and this
branch replaces the has_render check with a count of the batch's renders
(batch_renders). The count is kept, with has_render derived from it, and
note_render() stays where main moved it.
@RyanTheTide

Copy link
Copy Markdown
Contributor

Merged main in at 403ac7f3eed1 (no change to this PR's own code). One conflict in g17/queue/mod.rs submit: main moved note_render() to just before each publish, and this PR counts the batch's renders; the batch_renders count is kept (has_render derived from it) and note_render() stays where main moved it. Built drivers/gpu/drm/asahi locally with the Apple config (defconfig + asahi.config, LLVM, Rust): clean, no warnings in this PR's files. The earlier row still covers this PR's files.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging at 403ac7f3eed1 (B2 merge train, 12-01 merge bar). Approval at this head: aurora-silicon-review[bot] at 82783e2 (this head only merges main in: maintainer merge-up). Row: the hardware row at 82783e2 (same PR files; this head only merges main in). CI: linux train L5 = main + #3218 #3488 #2763 #3419 #3647 #2213 #2432 #3392: Apple driver compile pass, Apple DTBs W=1 pass, planned KUnit clpc/dcp-fabric/dcp-topology/dcp-display/macsmc/jpeg/asahi/sep pass, host tests apple-dcp + g14-v27-2 (25/25) pass. Hosted CI is queued behind the backlog. Revert: git revert -m 1 <merge commit>.

@RyanTheTide
RyanTheTide merged commit 77d53ea into aurora-silicon:main Dec 1, 2026
4 of 5 checks 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:m4 Macs affected, from Merge risk (bot) changes-requested A reviewer requested changes (bot) door:two-way Revertible or not, from Merge risk (bot) merge-conflict Conflicts with the base branch (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.

3 participants