Repository navigation
drm/asahi: g16: drop the M4 TA wave window - #3185
Conversation
The TA wave window held a ready render pass behind the in-flight work whenever four (multi-layer or large tilemap) or eight passes had not finished TA. It assumed the M4 firmware lets TA run that far ahead of FS. It does not. Per-pass firmware stage timestamps on J773g show that the TA of a pipelined pass starts only once the fragment stage of the pass before it has started: in render.postfx 1080p MSAA4, 312 of the 601 TA starts that waited began within 10 us of FS(N-1) starting, and the TA-to-FS lead never exceeds about one pass. So ta_pending_passes() counted passes queued behind the fragment front, not passes loading the tiler, and the window only held work the GPU could have started. The hold split every render.postfx frame into about six publications of 1.75 passes and every compress.bw job into about four. Each publication starts a new submit record, and at about a third of those boundaries the GPU sits idle for about 190 us before the firmware starts the next record. With the window at the render flight bound, render.postfx publishes one record per frame, its ta_wave holds drop from 19,041 to 0 per run, and the GPU time of one submit drops from 643 to 420 us. Remove the window, its heavy/light pass classification, the hysteresis that woke paused renders on TA progress, the per-wave doorbell flush and the compute bypass of TA-paused renders. Render publication stays bounded by render_flights(), the retained pass slots and TA/FS ring headroom. The hold_causes line loses its ta_wave key. On J773g against origin/main (medians of 6 passes, averaged over two sessions run in opposite order where both have the row): render.postfx 1080p MSAA4 d=2 735 -> 681 us, 1440p MSAA1 d=2 766 -> 703 us, 1440p MSAA4 d=2 775 -> 728 us, compress.bw array d=4 457 -> 422 us, render.light d=32 59.1 -> 54.5 us and d=64 60.4 -> 51.5 us. render.mdi, compute.light and sync.signal do not change. A lone render.postfx 1080p MSAA4 frame (d=1) gets 9 % slower, 799 -> 877 us: its GPU time drops from 547 to 388 us, but the firmware takes longer to start and to complete one 11-pass record on an idle GPU than the 8-pass record that the window used to publish. Signed-off-by: Diljit Singh <[email protected]>
The publication, poll and command stream harnesses stubbed or extracted the TA wave window, its heavy/light classification and the TA-progress wakeup that the engine no longer has. Drop the tests that only exercised that pacing (the per-wave doorbell flush, the hoisted pending-TA read, the compute bypass of TA-paused renders and the TA-only interrupt hysteresis) and the ta_wave hold cause case. Replace the pending-TA test with one that checks that a render keeps queueing behind 4, 8, 16 and 46 unfinished TA passes without reading the TA stamp, and stops at the render flight bound. Signed-off-by: Diljit Singh <[email protected]>
On an idle GPU the M4 firmware takes longer to start a render record the more passes it holds: a lone render.postfx frame published as one 11-pass record starts its first TA about 216 us after the doorbell, against about 170 us for the 8-pass record that the TA wave window used to publish. Since that window is gone, a lone multi-pass frame pays this on every submit, and render.postfx 1080p MSAA4 at d=1 went from 799 to 877 us although its GPU time dropped. When the engine is idle, publish the first pass of the job as a record of its own. The rest of the job follows right behind it in the next record, which the firmware takes up while the first pass runs. Render jobs published behind in-flight work are batched as before. On J773g against the previous commit (medians of 6 passes, arms in mirrored order in one boot): render.postfx 1080p MSAA4 d=1 885 -> 761 us and 1440p MSAA4 d=1 955 -> 819 us. render.postfx 1080p MSAA4 d=2 (686 -> 687 us), render.light d=64 (51.5 -> 51.4 us) and render.deferred tile d=1 (485 -> 486 us) do not change. Signed-off-by: Diljit Singh <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
|
|
Verdict at Blockers: none. Checked:
Evidence
|
|
J516s (MacBook Pro 16" M3 Pro, G15S) row at
|
Signed-off-by: DjDeveloperr <[email protected]>
|
J773g (Mac mini M4, G16G, firmware 26B123) row at the current head
The one fail is not from this PR. I ran that case 30 times per kernel and Mesa build: 20 times on its own and 10 times among its neighbours from the CTS run. The builds were interleaved run by run, two boots in one session, with no GPU faults in either:
|
|
J516s (MacBook Pro 16" M3 Pro, G15S) row at
|
There was a problem hiding this comment.
Verdict: MERGE at 068d90ee2055f335119eb3d23ba4d15a8e4702c9 once the remaining shared-path hardware evidence is complete.
Blockers: No code blocker found. Keep the PR unarmed pending a T8122 run on the shared backend or a documented stand-in with an owner regression request.
Checked: Followed the removal through render admission, same-submit and cross-job folding, doorbell handling, and shorter repolls. Dependency and same-queue ordering checks remain. Render-flight, slot, and ring capacity limits still bound publication. The idle first pass prevents cross-job folding for that initial record. Independently ran the exact-head command-stream, poll-retire, and publication suites (28, 43, and 86 cases passed). Reviewed the exact-head J773g and J516s reports, including the reported CTS failures and controls. No DT, board gating, private material, or attribution change.
|
code-owner ping @DjDeveloperr: closeout merge of your PR at |
|
Merging under the 6-point rule (Ryan 09:29, permanent), at |
Forward-merge main. Main (#3185) dropped the M4 TA wave window, which removed Flight::heavy_render, Engine::ta_wave_wait and turned can_queue_behind_with_ta() into can_queue_behind(). engine.rs keeps this branch's compute_uma_mask and takes main's removal of heavy_render. The test-publication.py stand-ins take main's Flight and QueueBehindFlight shapes plus compute_uma_mask/quarantined_uma_mask; the TA wave tests main deleted stay deleted, and the shared compute UMA tests call can_queue_behind() without the TA cursor. Signed-off-by: Ryan Murray <[email protected]>
What: On M4 the g16 TA wave window held ready render passes until earlier passes finished TA. The firmware never lets TA run more than one pass ahead of FS, so the window only split frames into many small submit records. Several M4 render rows lost GPU time at those record boundaries. This removes the window. It also publishes the first pass of a job by itself when the GPU is idle, because the firmware starts long records late on an idle GPU.
Tested: J773g M4 mini at
c7cf6c26: render.postfx d=2 +6 to 9 %, d=1 +3 to 20 %, compress.bw +8 to 17 %, render.light d=64 +17 %; full gpubench-vk 202/202 ok with 84/84 CRCs, geomean against Metal 4 1.198x to 1.202x; Vulkan CTS subset of 13,810 cases with one failure, an intermittent implicit-sync case that origin/main fails too; s2idle and post-wake rows pass; 0 GPU faults or recoveries.Risk: two-way · M3 and M4 Macs that run the g16 backend (T8122, T6030, T8132, T6040, T6041)
Not yet: rows on M4 Pro/Max (T6040, T6041) and on the M3 chips that share this backend (T8122, T6030). Two firmware stalls remain for follow-ups: some record switches still idle the GPU about 190 us, and an idle GPU starts freshly kicked work 90 to 180 us late.
Details
What the firmware does. I measured this with a tracing build, not part of this PR, that records the firmware's per-pass TA and FS start and end stamps alongside the host's publications, holds and retirements. On J773g, the TA of a pipelined pass starts only after the FS of the pass before it has started. In render.postfx 1080p MSAA4, 312 of the 601 TA starts that waited began within 10 us of FS(N-1) starting. At 85 % of TA starts, at most one earlier pass had a started TA and an unfinished FS.
Why the window hurt.
ta_pending_passes()counted passes whose TA had not finished, and the window held further renders at 4 (multi-layer or large tilemap) or 8. Those passes were waiting behind FS, not loading the tiler. Holding them only split each frame into separate publications: about six per render.postfx frame (1.75 passes each), about four per compress.bw job. Every publication starts a new submit record, and at about a third of record boundaries the GPU sat idle for about 190 us. With the window gone, render.postfx publishes one record per frame. Its ta_wave holds drop from 19,041 to 0 per run, and the GPU time of one submit drops from 643 to 420 us (Metal 4: 395 us).Commit 1 removes the window and everything built on it: the heavy/light pass classification, the hysteresis that woke paused renders on TA progress, the per-wave doorbell flush, and the compute bypass of TA-paused renders. Render publication stays bounded by
render_flights(), the retained pass slots and the TA/FS ring headroom. Thehold_causesline in debugfs loses itsta_wavekey. Net -250 lines.Commit 2 updates the asahi-m4 host selftests that stubbed or extracted the removed code. One new test checks that a render keeps queueing behind 4, 8, 16 and 46 unfinished TA passes without reading the TA stamp, and stops at the render flight bound.
Commit 3. On an idle GPU the firmware starts a record later the more passes it holds: about 216 us from doorbell to first TA for an 11-pass render.postfx frame, against about 170 us for an 8-pass record. After commit 1 a lone multi-pass frame paid that on every submit (render.postfx 1080p MSAA4 d=1: 799 to 877 us). When the engine is idle, the first pass of a job now goes out as a record of its own, and the rest follows right behind it. Work published behind in-flight jobs is batched as before. A one-pass first record measured the same as two or four passes, so the code has no tuning constant.
What this does not fix. The record-switch stall still happens on some boundaries. Extra doorbells made it worse, and none of the barrier variants I tried (hold-type barriers, an always-on FS-to-FS barrier, no TA-to-TA barrier) changed it, so it is firmware-side. An idle GPU also starts a freshly kicked burst 90 to 180 us after the doorbell (render.mdi). The compute-to-render handoff inside that burst takes 13 to 27 us.
Evidence
Kits were built natively on J773g:
89542c560bf22: release 7.3.0-ARCH-m4kpmain-89542c56, aurora.ko build id 1c6c6b73…c7cf6c261bfd1: release 7.3.0-ARCH-m4kpfix3-c7cf6c26, aurora.ko build id 8a014071…Both used Mesa main at 15c5bb524162 and gpubench-vk 13. Each value is the median of 6 passes, in us per submit. origin/main was measured in two sessions run in opposite order; same-kernel drift between sessions was 0.5 to 4.6 %.
compute.light and sync.signal read 1 to 2 % slower in this session. An unchanged kernel varied 0.5 to 4.6 % between sessions on the same rows: commit 1 measured 31.47 us on sync.signal in one session and 30.17 us in the other. No commit here changes the compute path.
Full gpubench-vk suite, one pass per row: 202/202 ok and 84/84 CRCs valid on both kernels. The geomean against Metal 4 goes from 1.1977x (127 of 202 rows ahead) to 1.2023x (133 ahead). This branch over origin/main is 1.0083x. Rows that moved more than 5 % in that single pass:
Lone-frame breakdown, from traces with the window as on origin/main versus with no window: the frame's GPU time drops from 547 to 388 us. The idle gap between frames rises because an 11-pass record starts about 46 us later on an idle GPU and its completion becomes visible about 85 us later. Commit 3 removes most of the start delay. Measured against commit 2 in one boot, with arms in mirrored order and 6 passes each:
Safety on J773g at this head:
--jobs 1, 13,810 cases): Pass 9,638, NotSupported 4,171, Fail 1. The list covered memory.pipeline_barrier, the synchronization and synchronization2 basic/smoke/implicit/none_stage/layout_transition groups, compute.pipeline.indirect_dispatch and draw.renderpass.indirect_draw in full, plus samples of timeline_semaphore, op.single_queue, multisample, renderpasses, draw and compute.synchronization.implicit.timeline_semaphore.write_ssbo_vertex_read_ssbo_vertex.buffer_16384.3303("Memory contents don't match"). It is pre-existing. Running all 1,024 implicit-sync cases ten times on each kernel gave one failure each on origin/main, on commits 1-2 and on this head, all in the same case of that family:synchronization2.implicit.binary_semaphore.write_ssbo_vertex_read_ssbo_vertex.buffer_16384.3122.rtcwake -d /dev/rtc1 -m freeze -s 10): woke, suspend_stats success 1 / fail 0, no error lines in the kernel log delta. Post-wake render.light, compute.light, render.postfx, compress.bw and render.mdi rows: 7/7 ok with valid CRCs.Static checks:
Stand-in note: There is no T8122 in this lab. The exact-head J516s (M3 Pro, T6030/G15S) row at 068d90e (#3185 (comment)) exercises the same M3/G15 g16 shared backend and stands in for T8122 per policy/merge-policy.md §3 (co-Owner signed off; open to a T8122 owner regression check).
Aurora Agents T8122 owner regression request filed (ID
b32b2cf4-1160-4a54-b362-ae1f69776b56, keylinux3185-t8122-g16-068d90ee2055).