Repository navigation
drm/asahi: g17: stride tiling notifications to deep multi-pass renders - #2213
Conversation
|
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 ( 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 |
|
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 ( 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:
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 ( Disclosure: prepared with an AI tool (the commits carry Assisted-by: LLM); tested as described. |
|
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. |
|
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 M4 Pro (25G83)
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 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 |
bc3addb to
8a714c8
Compare
|
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:
The comment at |
|
Thanks for squashing, and for putting the M4 Pro cost next to the gain in the commit message and at |
|
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. |
8a714c8 to
d653e10
Compare
|
Re-review of d653e10: Blockers: 1. Since 8a714c8 the only change is the commit message: the
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) |
d653e10 to
bec2c46
Compare
|
Addressed the firmware-build gate blocker in Assisted-by: LLM (Google:Gemini 4 Neon) |
|
Rows for 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
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 Method and raw data
|
|
Thanks, bec2c46 resolves the blocker: 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) |
|
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 @bec2c46dVERDICT: BLOCKERS Blockers
Nits
Missing rows
|
bec2c46 to
845b8cb
Compare
|
Pushed
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. |
|
Re-checked at 845b8cb (message and doc comment only, per the author). Blocker 1 as written is resolved: the commit message and the 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) |
There was a problem hiding this comment.
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 = 1unconditionally removes theRegisterPrograms::V25G83branch (§1 uniform policy acrossTaDescriptor::writebuilds: 25G83, 25F84, 26B123, 26A428; M5 unaffected), and the updated commit message andTaDescriptor::first_kickdoc 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 disclosesAssisted-by:, naming clean.
Blockers before approval (§5 Evidence & GPU-owner policy decision)
- Unresolved GPU-owner policy decision on A18 Pro regression: Because §1 requires a single rule across all
TaDescriptor::writebuilds, landingfirst_kick = 1unconditionally 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@RyanTheTidenoted at845b8cb7, this needs an explicit GPU-owner acceptance (or a different retirement design that avoids the small-frame/IRQ regression). - 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 atHZ=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).
- J616s (M4 Pro, 25G83,
Superseded by the review at 845b8cb
|
Pushed
|
There was a problem hiding this comment.
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]>
93aa9cb to
82783e2
Compare
|
Rebased onto
Still awaiting the exact-head A18 Pro (J700 / 26A428) A/B requested in the review. |
There was a problem hiding this comment.
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/-19across 7 files) and verified the rebase adjustment indrivers/gpu/drm/asahi/g17/queue/mod.rs:let Scratch { pending, guards } = &mut scratch;preserves#2228'sScratchreuse while computingbatch_renders = u16::try_from(pending.iter().filter(...).count()).unwrap_or(u16::MAX)andhas_render = batch_renders != 0. ta_notify_for_depth()(drivers/gpu/drm/asahi/g17/queue/render.rs:240-259) uses saturating arithmetic, guardsdepth < 2, and is covered by 6 KUnit suites (asahi_g17_render_ta_notify) plusta_descriptor_first_kick_follows_ta_notify_across_all_programs.- CI at
82783e27: build/host/KUnit/pr-text/readiness checks are currentlyQUEUED.
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.
|
Merged main in at |
|
Merging at |
What: replace the unconditional
TaDescriptor::first_kick = 1with a uniform workload-driven policy shared across allTaDescriptor::writefirmware builds (25G83, 25F84, 26B123, 26A428; M5 useswrite_m5_commandsand 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 / 2andin_flight + backlog <= RENDER_DEPTH) notification-free, and emit strided notifications (TA_NOTIFY_STRIDE = 4plus the window-filling kick) oncein_flight >= RENDER_DEPTH / 2on deep/overflowing multi-pass streams.Tested: Rebased onto
main(8973ceaadd2c1) at82783e2782d3resolving the 3-lineScratchdestructure conflict indrivers/gpu/drm/asahi/g17/queue/mod.rs(tiling-notification policy infw/render.rsandqueue/render.rsis unchanged from93aa9cbe5f29);tools/asahi/run-host-tests.py --only g17passes242/242at82783e2782d3. Prior head93aa9cbe5f29full A/B on J616C (T6041 M4 Max, 25G83, HZ=1000) vs7.3.0-j616c-main25nov+: 16-pass0.099 -> 0.096 msmean (-3.0%), p990.300 -> 0.200 ms, fw IRQs2.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-pass2.036 -> 1.544 ms(-24.2%, p992.400 -> 1.800 ms, fw IRQs2.9k -> 16.6k/s), 200-pass3.651 -> 2.847 ms(-22.0%);gpubench-vkrender.light d16+0.1%,d32+0.5%,2p-1.7%,4p-0.2%,2q-1.2%,render.heavy d160.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-head82783e2782d3J616C sanity re-check.J616C (T6041, 25G83, HZ=1000) A/B at 93aa9cb
vkstress(2 frames in flight, 398 frames,28a600000.mailbox-recvfw IRQs):mainmean / p9993aa9cbe5f29mean / p99main-> new)gpubench-vk(5-run medians,us/submit, 0 GPU faults):main93aa9cbe5f29render.light d1render.light d4render.light d16render.light d32render.light d64render.light 2prender.light 4prender.light 2qrender.heavy d16compute.light d64