Repository navigation
drm/asahi: g17: cut G17P/V25G83 render submit CPU via template delta-patching - #3342
Conversation
…patching From one render of a pass to the next on G17P and V25G83, only per-render addresses, ordinals, lifecycle IDs, work keys, stamps, timestamps, sampler bindings, clear values, and USC program offsets change; the remaining ~175 register entries and descriptor fields stay identical. Add a self-verifying heap-backed TemplateSlot in fw/render_template.rs for non-M5 render pairs: - Key::matches() and Key::write_into() run out of line with exhaustive struct destructuring so masked temporaries pop off the submit stack and any new field forces a compile-time choice between keying and patching. - Register indices are discovered dynamically from the captured descriptors so the same patcher handles G17P and V25G83 with or without optional SCS scratch entries. - A new template enters Pending and is admitted only after the next matching render verifies byte-for-byte against a full encoding; any mismatch permanently rejects that key until the key changes. - Once admitted, each ring slot tracks its template generation and inline MCache count so subsequent wraps patch only the dynamic fields in place without re-copying all 11.6 KiB. - Expose g17_render_template full/patched/verified/mismatched/unmapped counters in capacity debugfs. - In NeoGeneration::prepare(), clear only the first 64-byte cache line of the uncached 16 KiB fragment status page (holding the single 64-bit status word at +0), matching M5 Generation::prepare(). Add KUnit tests verifying byte-for-byte identity across G17P and V25G83, SCS toggles, ring wraparound, MCache changes, and mismatch rejection. Signed-off-by: DjDeveloperr <hey@djdev.me>
Add tools/asahi/g17-render-template-tests.py and register it in tools/asahi/run-host-tests.py. The test compiles the production firmware encoders (fw/kick.rs, fw/compute.rs, fw/render.rs, fw/render_template.rs) with rustc --test and verifies byte-for-byte identity against the full reference encoders across G17P and V25G83, SCS toggles, ring wraparound, MCache growth/shrink/spill, key changes, and validation-error parity, along with four negative-control mutations and source guards. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
encode() keeps each descriptor slot's state, including how many inline MCache ranges it wrote, under ordinal % RING_SLOTS and expects that index to name the same descriptor storage every time, as the driver's RECORDS-deep render ring does. The wraparound KUnit test backed it with a four-entry ring indexed by ordinal % 4, so two template slots shared one ring entry. At ordinal 66 the template cleared the five ranges it had recorded for ordinal 34 while the ring entry still held ordinal 62's seven, and the fragment descriptor kept two stale ranges. Back the test with RING_SLOTS-deep rings indexed the same way; ordinals 0..4 and 32..68 still wrap the ring twice. Add a compile-time check that RING_SLOTS equals RECORDS so the two cannot drift apart. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
J714s (MacBook Pro 14" M5 Pro, G17S B1) second-generation boot-sanity row at exact head
1. Vulkan CTS (
2. gpubench smoke (depths 1 and 2,
3. Kernel log:
|
|
Fixed the The cause was the test, not the encoder or The test rings are now Tested locally: KUnit |
|
Non-author review at
|
There was a problem hiding this comment.
The regression fixture now uses the same ring depth as the runtime encoder, and the new constant assertion ties descriptor storage to template slot tracking. I ran the exact-head host render-template suite locally: 2 tests passed. I verified that the delta after the J700 and J714s builds consists of test code and the compile-time assertion. Code approved. Keep held for hosted KUnit and the still-missing V25G83 hardware row, which exercises the other register layout affected by this patch.
Main dropped the fragment MCache table writer (5910c92), so the template encoder no longer writes or tracks one: render_template::encode() takes no attachments or UAT context and returns only the path it took, slot_mcache and its inline-range clearing are gone, and write_descriptors() keeps main's signature. FragmentSlot::write() keeps main's comment and this branch's test-only cfg. The host test and the KUnit ring test drop their MCache cases and the skip_render_mcache_clear mutation. Signed-off-by: DjDeveloperr <hey@djdev.me>
There was a problem hiding this comment.
Verdict: HOLD at aa9ee1470cb2
Blockers:
- Hosted CI at
aa9ee1470cb2is still queued (21jobs queued:apple-build,host-tests,pr-text,readiness, and KUnit suites including the render-template ring test) — wait for all checks to complete green. - Post exact-head
aa9ee1470cb2G17P hardware verification (J700orJ616srender smoke) after themainmerge removed MCache table tracking fromrender_template::encode().
Checked:
- Audited merge commit
aa9ee1470cb2(MERGEABLEagainstmain, 9 files+1691/-124): cleanly reconciles against5910c926320e(removal of fragment MCache writer onmain), strippingslot_mcache, inline-range clearing, obsolete MCache tests, andskip_render_mcache_clearmutation with zero leftover MCache references across all 9 files while preservingmain'swrite_descriptors()signature and the previously approved2a18b26db1template delta-patching andRING_SLOTS == RECORDSassertion.
Evidence
- Head:
aa9ee1470cb2acdef8bef7704ea8d75d8080a1c0(basemain,MERGEABLE). - Status checks at review time: 21 queued, 3 skipped, 0 failed.
RyanTheTide
left a comment
There was a problem hiding this comment.
Reviewed the conflict-pass merge commit aa9ee14 only: render_template encode() adapted to main's Result return; tests and the run-host-tests mutation list follow. The resolution keeps what each side had and adds nothing outside the conflict. Approved for the merge-up; merging still waits on CI and the rows at this head.
There was a problem hiding this comment.
Verdict: MERGE at aa9ee1470cb2
Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.
Checked: - Audited merge commit aa9ee1470cb2 (MERGEABLE against main, 9 files +1691/-124): cleanly reconciles against 5910c926320e (removal of fragment MCache writer on main), stripping slot_mcache, inline-range clearing, obsolete MCache tests, and skip_render_mcache_clear mutation with zero leftover MCache references across all 9 files while preserving main's write_descriptors() signature and the previously approved 2a18b26db1 template delta-patching and RING_SLOTS == RECORDS assertion.
Follow-ups (not blocking): queued CI; G17P J700/J616s render smoke row
|
Row:
I didn't re-run the submit-CPU numbers. |
|
Local verification at The J700 CTS receipt covers G17P. The remaining hardware control is the J616s/J616C V25G83 render-template run, tracked under Aurora Agents request |
|
Second row at exact head
I didn't re-run the submit-CPU numbers. |
|
PASS J714s (M5 Pro, T6050/G17S B1) linux#3342 head aa9ee14 (7.3.0-m5-pr3342-aa9ee147, build-id vmlinux=8e6e1268 aurora.ko=9d6eb52a): paired headless VK-GL-CTS --procs 2 13538/13538 (10532 pass, 3006 NS, 0 bad, 0 diffs, 0 regressions vs stock 7.3.0-m5-pr67 across draw.renderpass 538, pipeline.monolithic 7766, timeline_semaphore 5153, compute.pipeline.basic 81); g17_render_template mismatched=0 unmapped=0 (M5 no-op path, fw_inputs 16073/16073, 0 refusals); 0 GPU faults/recoveries/Oops/WARN/BUG, WDT armed, SLC 16 planes, clean stock handback (3049d782). |
Commit 82783e2 ("drm/asahi: g17: stride tiling notifications to deep multi-pass renders") on main replaced RenderArgs::pair_idle with RenderArgs::ta_notify. TaDescriptor::write now sets first_kick to ta_notify on every firmware build that uses it. The render template still derived first_kick from the ordinal and pair_idle, and its key destructure named pair_idle, so the merge with main did not build. Patch first_kick from ta_notify the way TaDescriptor::write does. Keep ta_notify out of the template key, because it changes from one render to the next. The KUnit test and the host test fixture now vary ta_notify where they varied pair_idle, so a patched descriptor is still checked byte for byte against a full encode with both values. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Forward-merged What changed and why.
A patched descriptor now carries the same notification word as main's full encode. The existing byte-for-byte check before a key is admitted still covers it. Local checks on pc, at the new head:
What this changes on hardware. M5 render pairs have no template. On the J714s, this PR's code therefore behaves as it did at
Still needed: a fresh J714s exact-head row and an approval from someone other than the pusher. This push dismissed the earlier approval. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: MERGE at 4c1d616910005976fa5b2504546c4a9a9d03d3b3
Blockers: none
Checked: The main merge 855b8b2f is a real two-parent merge, and its tree is exactly the clean merge of aa9ee147 and main 4c6f0f70. The template now sets the tiling descriptor's first_kick from ta_notify on every kick, the same way main's full encode does, so patched descriptors stay byte-identical to a full encode. No Apple material, no gates or parameters, no attribution. Two things are still needed before merge. First, CI has to finish at this head: apple-build, host-tests and KUnit were still pending when I looked. Second, there has to be a hardware run at this head. The J700, J616s and J714s runs so far are at aa9ee147, and this push changes when the V25G83 and G17P template path sets first_kick.
Evidence
- Merge commit
855b8b2f. Its parents areaa9ee147and4c6f0f70, in that order, and the merge base is27284bfe(GitHub's compare agrees). Since that base, main changed 827 paths and this branch changed 9. Four paths overlap:fw/compute.rs,fw/render.rs,queue/render/memory.rsandtools/asahi/run-host-tests.py. Every path changed only on main matches main, every path changed only on the branch matchesaa9ee147, and nothing else differs. For the four overlapping files, a three-waygit merge-filemerges cleanly, and the result is byte-identical to the blob in855b8b2f. No hunks are lost or added. first_kickin the template.TemplateSlot::patch(render_template.rs:585) setsfirst_kick = ta_notify, matchingTaDescriptor::write(render.rs:1328).patchruns on every Admitted kick, whether or not the ring slot needs the golden copy. It also runs on the Pending kick, before the byte comparison. Empty, Rejected and changed-key kicks take the full encode. So the value captured into the golden template is always overwritten and never reaches the firmware. Keepingta_notifyout ofKey(:95,:121) is right: it changes from kick to kick, and keying on it would only churn the template. The fragment descriptor'sfirst_kickstill followsordinal == 0in both the full and the patched encode.- Other callers. The only place that builds
RenderArgsfor a real kick isPair::prepare(queue/render.rs:617), which computesta_notifyfrom main's policy. The direct, prepare and replay paths all go through it.write_m5copies the args with..*args, and M5 never uses this descriptor or the template (render_templateisNonethere).pair_idleappears nowhere at this head. Main's other changes since the base don't touch the render encoders: infw/render.rsthe only change ispair_idletota_notify, and inmemory.rsit is the command-storage mapping protection. Nothing new writes into a descriptor after encode.patchstill resets the fields thatset_completion_linkandbind_work_slotwrite. - Tests, mutation check. I ran
tools/asahi/g17-render-template-tests.pyon this head's sources. The control passes 2/2. Three mutants of thefirst_kickline are all caught: dropping the patch (2 tests fail), the oldordinal == 0rule (2 fail), and a constant1(1 fails, with a path mismatch at i=1). In both the KUnit test and the host fixture,ta_notify = ordinal % 4 == 0gives both values on patched kicks at non-zero ordinals. I did not rerun the whole host suite, the arm64 W=1 build or checkpatch; CI covers the first two. - Nits (no action needed). The commit message says #2213 replaced
pair_idle. On main,82783e27actually replaced an unconditionalfirst_kick = 1;pair_idlewas removed in an earlier commit. The net change against this branch's base is the same. Afirst_kickmutant could join the three inrun-host-tests.py, but the byte comparison already catches it.
J700 (MacBook Neo, A18 Pro, G17P B1): PASS at exact head
|
| Arm | Kernel | Boot |
|---|---|---|
| head | 4c1d61691000, release 7.3.0-pr3342-4c1d6169 |
183eb690-76ff-4b6b-839c-5cf69f340ccd |
| base | main 4c6f0f70989f, the main the head was merged with, release 7.3.0-main-4c6f0f70 |
057e0e94-68b3-428d-b478-4e19f8abd8ba |
Render cases (3 runs × 5 samples per arm, every sample output-checked, bar head/base ≤ 1.03 on each):
| Case | Head median (us/submit) | Base median | Ratio |
|---|---|---|---|
render.pass_chain indep, 64 passes, depth 1 |
2118.6 | 2118.6 | 1.0000 |
render.pass_chain frag_bar, 32 passes, depth 1 |
1050.4 | 1077.6 | 0.9748 |
render.deferred dram, 1080p, depth 1 |
827.8 | 819.7 | 1.0099 |
render.light tri, depth 1 |
135.8 | 135.3 | 1.0038 |
render.light tri, depth 16 |
30.22 | 30.23 | 0.9995 |
- Template: on the head,
mismatched=0,crashed=0andunmapped=0in every sample.patchedwent from 119 at start to 509,222 after the GPU runs and 527,501 after the sleep. The base has no template line, as expected. - Faults: 0 GPU faults, recoveries, firmware crashes or lost devices on both arms. 0 "render descriptor template differed" lines, 0 WARN, BUG, Oops or stalls.
- s2idle, identity, watchdog: PASS on both arms. After each arm the J700 returned to verified stock, with the configured Stage 2 byte-identical and the PMU boot-error count 00.
queue.exhaust, information only: 40 queues opened on both arms (5 devices × 8; device 6 refused its first work withVK_ERROR_OUT_OF_DEVICE_MEMORY). No GPU faults after it.
Submit CPU, the number the PR is about, is mixed and noisy here. Submit CPU medians per run, head vs base:
pass_chainindep: 387 / 428 / 448 vs 448 / 329 / 330 us. The head is lower in one run and higher in two.pass_chainfrag_bar: 266 / 222 / 225 vs 288 / 242 / 350 us. The head is lower in all three.render.deferred: 30.4 / 34.7 / 29.5 vs 30.1 / 29.9 / 29.9 us. Not lower on the head.render.lightdepth 1: 15.7 / 16.7 / 16.8 vs 16.1 / 18.0 / 18.4 us. The head is lower in all three.render.lightdepth 16: 14.1 / 14.0 / 13.8 vs 15.2 / 15.2 / 15.0 us. The head is about 7% lower in all three.
The run bar was the GPU time per submit, and it isn't a submit-CPU bar. I did not gate on CPU time, and one boot per arm is too few runs to claim a saving on the multi-pass cases.
Not covered
- The per-kick
first_kickvalue isn't visible from userspace. I chose cases that make it change (more than 16 passes per submit, a queued second kick, queued single-pass kicks), but I can't show which kicks used which value. - I didn't check that Mesa submits all 64 passes together.
- No deep sleep and no display checks in this row.
|
PASS on J714s (MacBook Pro 14" M5 Pro, T6050 G17S B1) at exact head |
RyanTheTide
left a comment
There was a problem hiding this comment.
Reviewed 4c1d616. The cached template now writes the same per-kick tiling notification as the full encoder, and the fixture covers both values on patched kicks. Build checks and hardware coverage for this updated notification path remain pending.
|
Local stand-in for the hosted
Rows at this head: J700 and J714s. Approved by RyanTheTide. Merging. |
What:
Port the self-verifying render descriptor template delta-patching and 64-byte status page clear design from M5 (
#3309) to non-M5 G17 render pairs (G17P / A18 Pro and V25G83 / M4 Pro/Max):TemplateSlotindrivers/gpu/drm/asahi/g17/fw/render_template.rsthat caches the static key (Key::matches()/Key::write_into()out of line with exhaustive destructuring), goldenTaDescriptorandFragmentDescriptor, and dynamically discovered register indices (handling both G17P and V25G83 with or without optional SCS entries).Pendingand are admitted only after the next matching render verifies byte-for-byte against a full encode; any mismatch permanently rejects that key until the key changes.NeoGeneration::prepare(), clear only the first 64-byte cache line of the uncached 16 KiB fragment status page (covering the single 64-bit status word at+0), matching M5Generation::prepare().g17_render_template full=... patched=... verified=... mismatched=... unmapped=...counters incapacitydebugfs.fw/render_template.rsand host unit tests intools/asahi/g17-render-template-tests.py(registered intools/asahi/run-host-tests.pywith 3 negative-control mutations).Tested:
4c1d61691000(mainat4c6f0f70989fmerged intoaa9ee1470cb2as855b8b2f0bae, then4c1d61691000adapts the template tota_notify, which replacedpair_idleonmainin82783e2782d3). Local checks on pc:run-host-tests.py --only g17 --jobs 8): 333/333 passed, includingg17-render-template-tests.pyand its 3 killed mutations. An extra mutation that writes a constantfirst_kickfails the fixture at TA byte 2242, so the fixture checks the new field.W=1 modules_prepare drivers/gpu/drm/asahi/(LLVM, warm build dir):aurora.obuilt and linked. It has 44 warnings, none in files this PR touches. A W=1 build of a tree based on main from earlier today shows the same ones.checkpatch.pl --stricton4c1d61691000: 0 errors, 0 warnings, 0 checks.T8140/G17P B1) ataa9ee1470cb2: 13,537 Vulkan CTS cases matched the stock kernel with 0 failures, 0 GPU faults or recoveries, and 0 template mismatches. Stock boot was restored. Exact-head result.G17S B1) ataa9ee1470cb2: 13,538 paired headless VK-GL-CTS cases with 0 regressions against stock, 0 GPU faults or recoveries. M5 does not use the template (mismatched=0 unmapped=0, no-op path). Row.aa9ee1470cb2: 13,537 VK-GL-CTS cases gave the same results as the saved kernel, withmismatched=0. Row.tools/asahi/run-host-tests.py --only g17 --jobs 4at exact head7a0225d1f478): 225/225 passed (includingg17-render-template-tests.pycompiling productionfw/kick.rs,fw/compute.rs,fw/render.rs,fw/render_template.rswithrustc --testand verifying byte-for-byte parity across G17P/V25G83, SCS on/off, 80-render ring wraparound, MCache growth/shrink/spill, key changes, validation errors, and 4 killed mutations).aurora.koat7a0225d1f478.T8140/G17P B1) exact-head 4-boot BAAB (7a0225d1f478vs8e2ee15f3ca30, one-shotgrub2-rebootwith rebuilt initramfs and verified/sys/module/aurora/notes/.note.gnu.build-idon all 4 boots):taskset -c 0,5) submit CPU:vk render.light queue/d32:20.89 -> 17.64 us(-15.6%,B1=18.39, B2=16.89vsA1=20.93, A2=20.85)vk render.light queues/d8:18.63 -> 16.33 us(-12.4%,B1=15.71, B2=16.95vsA1=18.63, A2=18.63)vk render.light queue/d8:18.20 -> 16.21 us(-11.0%,B1=16.34, B2=16.08vsA1=18.61, A2=17.80)vk render.light queue/d1:15.62 -> 14.34 us(-8.2%,B1=14.39, B2=14.29vsA1=15.80, A2=15.44)vk render.light queues/d4:15.60 -> 14.34 us(-8.1%,B1=14.36, B2=14.32vsA1=15.60, A2=15.60)gl render.light queue/d1:25.58 -> 24.60 us(-3.8%,B1=24.63, B2=24.57vsA1=25.68, A2=25.48)vk compute.light(untouched): flat within0.5%vk render.light queues/d8:-10.0%submit CPU (18.25 -> 16.42 us),-8.4%wall (48.28 -> 44.21 us)vk render.heavy queue/d1:-7.1%submit CPU (17.37 -> 16.13 us)vk render.light queue/d2:-6.7%submit CPU (16.59 -> 15.48 us),-6.4%wall (57.39 -> 53.70 us)vk render.light queues/d4:-6.0%submit CPU (16.87 -> 15.86 us)B1+B2:4,255,066patched renders,1,405verified,0mismatches,0unmapped (99.76%hit rate).renderpasses=200,dynamic_rendering=100,compute=81,sync=41,api.smoke=8):297 Pass, 133 NotSupported, 0 Fail,0diffs vs base,0recoveries.plasma-kwin_wayland.serviceactive/healthy onB1andB2;0GPU faults,0driver warnings,0AVCs,0new kernel errors, PMU00 -> 00on every boot; stock7.3.0-41restored cleanly (stock.diffempty).Risk: two-way · G17P and V25G83 render descriptor encoding (
fw/render_template.rs,queue/render/memory.rs). Self-verifying admission rejects any key on byte mismatch and falls back to full encoding withpr_warn_once!; M5 render paths and all compute paths are untouched.Not yet:
ta_notifyinstead of the oldpair_idlerule. Those are the same bytes as main's full encode, which the template checks before it admits a key.