Skip to content

drm/asahi: g17: cut G17P/V25G83 render submit CPU via template delta-patching - #3342

Merged
DjDeveloperr merged 6 commits into
mainfrom
feat/g17-submit-cpu-templates
Dec 3, 2026
Merged

DjDeveloperr merged 6 commits into
mainfrom
feat/g17-submit-cpu-templates

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

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):

  • Add a heap-backed TemplateSlot in drivers/gpu/drm/asahi/g17/fw/render_template.rs that caches the static key (Key::matches() / Key::write_into() out of line with exhaustive destructuring), golden TaDescriptor and FragmentDescriptor, and dynamically discovered register indices (handling both G17P and V25G83 with or without optional SCS entries).
  • Templates enter Pending and 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.
  • Once admitted, each of the 32 ring slots tracks its template generation so subsequent ring wraps delta-patch only per-render fields in place without re-copying all 11.6 KiB.
  • In 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 M5 Generation::prepare().
  • Expose g17_render_template full=... patched=... verified=... mismatched=... unmapped=... counters in capacity debugfs.
  • Add KUnit tests in fw/render_template.rs and host unit tests in tools/asahi/g17-render-template-tests.py (registered in tools/asahi/run-host-tests.py with 3 negative-control mutations).

Tested:

  • Forward merge at 4c1d61691000 (main at 4c6f0f70989f merged into aa9ee1470cb2 as 855b8b2f0bae, then 4c1d61691000 adapts the template to ta_notify, which replaced pair_idle on main in 82783e2782d3). Local checks on pc:
    • g17 host tests in the pinned host-tests container (rustc 1.96.0, clang 18, run-host-tests.py --only g17 --jobs 8): 333/333 passed, including g17-render-template-tests.py and its 3 killed mutations. An extra mutation that writes a constant first_kick fails the fixture at TA byte 2242, so the fixture checks the new field.
    • arm64 asahi profile W=1 modules_prepare drivers/gpu/drm/asahi/ (LLVM, warm build dir): aurora.o built 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 --strict on 4c1d61691000: 0 errors, 0 warnings, 0 checks.
  • J700 (T8140 / G17P B1) at aa9ee1470cb2: 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.
  • J714s (M5 Pro, G17S B1) at aa9ee1470cb2: 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.
  • J616s (M4 Pro, V25G83) at aa9ee1470cb2: 13,537 VK-GL-CTS cases gave the same results as the saved kernel, with mismatched=0. Row.
  • Host unit tests (tools/asahi/run-host-tests.py --only g17 --jobs 4 at exact head 7a0225d1f478): 225/225 passed (including g17-render-template-tests.py compiling production fw/kick.rs, fw/compute.rs, fw/render.rs, fw/render_template.rs with rustc --test and 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).
  • Zero new compiler warnings building aurora.ko at 7a0225d1f478.
  • J700 (T8140 / G17P B1) exact-head 4-boot BAAB (7a0225d1f478 vs 8e2ee15f3ca30, one-shot grub2-reboot with rebuilt initramfs and verified /sys/module/aurora/notes/.note.gnu.build-id on all 4 boots):
    • P-core pinned (taskset -c 0,5) submit CPU:
      • vk render.light queue/d32: 20.89 -> 17.64 us (-15.6%, B1=18.39, B2=16.89 vs A1=20.93, A2=20.85)
      • vk render.light queues/d8: 18.63 -> 16.33 us (-12.4%, B1=15.71, B2=16.95 vs A1=18.63, A2=18.63)
      • vk render.light queue/d8: 18.20 -> 16.21 us (-11.0%, B1=16.34, B2=16.08 vs A1=18.61, A2=17.80)
      • vk render.light queue/d1: 15.62 -> 14.34 us (-8.2%, B1=14.39, B2=14.29 vs A1=15.80, A2=15.44)
      • vk render.light queues/d4: 15.60 -> 14.34 us (-8.1%, B1=14.36, B2=14.32 vs A1=15.60, A2=15.60)
      • gl render.light queue/d1: 25.58 -> 24.60 us (-3.8%, B1=24.63, B2=24.57 vs A1=25.68, A2=25.48)
      • vk compute.light (untouched): flat within 0.5%
    • Unpinned 4-boot BAAB:
      • 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)
    • Template verification across B1 + B2: 4,255,066 patched renders, 1,405 verified, 0 mismatches, 0 unmapped (99.76% hit rate).
    • Vulkan CTS (430 cases: renderpasses=200, dynamic_rendering=100, compute=81, sync=41, api.smoke=8): 297 Pass, 133 NotSupported, 0 Fail, 0 diffs vs base, 0 recoveries.
    • Desktop & health: plasma-kwin_wayland.service active/healthy on B1 and B2; 0 GPU faults, 0 driver warnings, 0 AVCs, 0 new kernel errors, PMU 00 -> 00 on every boot; stock 7.3.0-41 restored cleanly (stock.diff empty).

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 with pr_warn_once!; M5 render paths and all compute paths are untouched.

Not yet:

  • A J714s (M5 Pro) row at the new head. M5 render pairs have no template, so the row is a no-regression check of the merged tree.
  • An approval of the new head from someone other than the pusher.
  • The J700 (G17P) and J616s (V25G83) rows above ran before the forward merge. At the new head, the template writes the tiling notification word from main's ta_notify instead of the old pair_idle rule. Those are the same bytes as main's full encode, which the template checks before it admits a key.
  • The in-kernel KUnit suites were not run locally (no QEMU). Hosted CI runs them.

…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>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 27, 2026 03:49
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Merge readiness at 4c1d6169: not ready yet

Check Detail
CI at head running running: KUnit asahi
Review ok approved by RyanTheTide
Requested changes ok none
Hardware row at head ok comment at 4c1d6169
Conflicts ok none
PR text ok Risk: two-way · G17P and V25G83 render descriptor encoding (fw/rendertemplate.rs, queue/render/memory.rs). Self-verifying admission rejects any key on byte mismatch and falls back to full encoding with prwarnonce!; M5 render paths and all compute paths are untouched.

Areas: area:gpu

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>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J714s (MacBook Pro 14" M5 Pro, G17S B1) second-generation boot-sanity row at exact head 7a0225d1f478: PASS. 0 GPU faults, 0 WARN, no new CTS failures.

  • Kernel: 7.3.0-m5-rows-k3342h, a warm native build on the M5 of this PR's head alone.
  • Boot: the default command line, headless. The default kernel (7.3.0-m5-cdirect16) was restored afterwards with a clean systemctl reboot, and all 253 ESP file hashes were verified.
  • Mesa: the system Mesa for Vulkan, and a fixed GL kit for the GL smoke.
  • This PR changes the G17P/V25G83 render path; the M5 render path is untouched, so this row checks for no regression.

1. Vulkan CTS (deqp-vk 1.4.7.1, 16 jobs):

2. gpubench smoke (depths 1 and 2, --timestamps off):

  • Vulkan: render.light/heavy/tvb/deferred/mdi/shadow/postfx, copy.bw, compute.light/heavy. 20 of 20 rows ok.
  • GL: the gpubench-gl smoke with --verify. 13 of 13 ok.

3. Kernel log:

  • 0 GPU MMU faults, 0 G17 recoveries, 0 WARN/BUG/Oops, 0 "compute publication … gave up" and 0 refused submissions, in every window and over the whole boot.
  • One distinct error-level line, which the default boot also logs.
  • Failed units: tailscaled.service only.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Fixed the KUnit asahi failure in template_matches_full_across_programs_scs_and_ring_wraparound with 2a18b26.

The cause was the test, not the encoder or main (main does not touch g17/fw/ and merges cleanly). encode() keeps each slot's state, including how many inline MCache ranges it wrote, under ordinal % RING_SLOTS (32) and expects that index to name the same descriptor storage, as the driver's 32-deep RECORDS ring does. The test used a 4-entry ring indexed by ordinal % 4, so two template slots shared one ring entry: at ordinal 66 the template cleared the 5 ranges it recorded for ordinal 34 while the entry still held ordinal 62's 7, leaving 2 stale ranges in the fragment descriptor.

The test rings are now RING_SLOTS deep and indexed the same way (ordinals 0..4 and 32..68 still wrap twice). A compile-time check now ties RING_SLOTS to RECORDS. No runtime descriptor code changed.

Tested locally: KUnit asahi on arm64 QEMU with LLVM=1 and the CI kunitconfig: 465 run, 461 passed, 0 failed, 4 skipped. g17 host tests: 225/225. checkpatch clean.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Non-author review at 2a18b26db1a4: READY, 0 blockers.

  • 2a18b26db1a4 changes no runtime code:
    • Both render_template.rs hunks are in the #[kunit_tests] template_tests module. The test ring is now RING_SLOTS deep and indexed by ordinal % RING_SLOTS.
    • The memory.rs hunk is a compile-time assert!(RING_SLOTS == RECORDS).
    • The production caller already indexes descriptor storage by ordinal % RECORDS (32), the same slot encode() keys its per-slot state on.
    • So the J700 row at 7a0225d1f478 and the J714s row in the comments stand for this head.
  • Template path (6de15a03861d):
    • A key is admitted only after a patched copy matches a full write_pair_descriptors() byte for byte. A mismatch or a patch error rejects the key and encodes in full, and real validation errors still propagate.
    • An admitted slot re-copies the golden descriptors when its generation is stale. Otherwise it clears only the inline MCache ranges it recorded. The golden copy is captured before set_mcache(), so it carries no ranges.
    • Patching writes only register indices discovered below each array's kernel-written count.
    • The per-array bounds loop removed from memory.rs was defense in depth: RegisterArray::set() and set_without() already refuse counts past REGISTER_ARRAY_ENTRIES.
    • Fragment status page: nothing on the host reads it, and the GPU writes its status word at +0, so clearing only the first 64 bytes is enough. M5 does the same.
    • M5 and all compute paths are untouched. ScratchRequest, IntersectionTables and RayQueryStage only gain PartialEq/Eq.
  • checkpatch --strict and rustfmt:
    • 2a18b26db1a4 is clean.
    • 6de15a03861d gives 9 warnings, 8 of them lines over 100 columns in the new code (seven in render_template.rs, one in render.rs); 7a0225d1f478 gives 1. The rest are the usual MAINTAINERS notices for new files.
    • rustfmt reports 11 hunks in the new render_template.rs. Not blocking, but a rustfmt pass would fix both.
  • Commits: all three are signed off, with no attribution, and the branch merges cleanly onto main.
  • CI at this head: 0/20 checks pass, 20 still pending at posting, 0 failing.
  • Owed:
    • CI green at this head.
    • The V25G83 (M4 Pro/Max) row from the PR's Not yet. Until then that path rests on the KUnit and host-test parity checks.
  • Suggestion, not blocking: the J700 row is a gpubench BAAB run. A J700 CTS render subset at this head would add direct evidence for the new encode path, beyond the template's own self-check.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 27, 2026

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Nov 29, 2026
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>

@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 aa9ee1470cb2

Blockers:

  • Hosted CI at aa9ee1470cb2 is still queued (21 jobs 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 aa9ee1470cb2 G17P hardware verification (J700 or J616s render smoke) after the main merge removed MCache table tracking from render_template::encode().

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.
Evidence
  • Head: aa9ee1470cb2acdef8bef7704ea8d75d8080a1c0 (base main, MERGEABLE).
  • Status checks at review time: 21 queued, 3 skipped, 0 failed.

RyanTheTide
RyanTheTide previously approved these changes Dec 1, 2026

@RyanTheTide RyanTheTide 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.

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.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed merge-conflict Conflicts with the base branch (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Dec 1, 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: 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

@RyanTheTide

Copy link
Copy Markdown
Contributor

Row: aa9ee1470cb2 + J700 (MacBook Neo, A18 Pro, G17P B1) + PASS: 0 regressions vs the saved kernel, 0 GPU faults, g17_render_template mismatched=0.

  • Kernel: 7.3.0-mrows3342, built from this exact head with the Neo's own 7.3.0-aurora-edge config (LLVM 22.1.6, rustc 1.97.1). Booted once through a non-default BLS entry plus grub2-reboot, with the saved entry, Stage 2, DTB and command line unchanged. aurora.ko build-id 4ec43506ae7a. SELinux Enforcing, 0 failed units, desktop session up.
  • Same-day A/B against the saved 7.3.0-aurora-edge: same installed Mesa (d4ad4a4dce, Borealis), same VK-GL-CTS lists (13,537 cases). Each list gives the same result on both kernels:
    • draw.renderpass.{indexed_draw,simple_draw,basic_draw}: 538/538 pass
    • pipeline.monolithic.{multisample,depth,stencil} (every 10th case): 4693/7765 pass, the rest not supported
    • synchronization{,2}.timeline_semaphore.* (without the image_64x64x8 cases): 5153/5153 pass
    • compute.pipeline.basic: 79/81 pass, 2 not supported
    • 0 Fail on either kernel.
  • Template counters (debugfs capacity):
    • after boot: full=663 patched=14 verified=26 mismatched=0 unmapped=0
    • after the CTS run: full=27464 patched=27463 verified=5900 mismatched=0 unmapped=0
  • Kernel log: 0 GPU faults, timeouts or recoveries during the run.
  • Restore: the Mac was rebooted back to its saved default and the trial files were removed.

I didn't re-run the submit-CPU numbers.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Dec 2, 2026
@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed ci-failing A check failed at the PR head (bot) labels Dec 2, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Local verification at aa9ee1470cb2 passed all 295 G17 host checks, including the render-template control and the three targeted mutation rejections. The ARM64 production Asahi driver compiled and linked, and the built-in Asahi configuration compiled with the KUnit fragment and both render-template test wrappers present. The in-kernel KUnit suite was not executed locally.

The J700 CTS receipt covers G17P. The remaining hardware control is the J616s/J616C V25G83 render-template run, tracked under Aurora Agents request 1fabfcb2-7159-4874-8d9f-3210927299cb.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Second row at exact head aa9ee147: PASS (J616s, 16" MacBook Pro M4 Pro, the V25G83 path; this adds a second board to the Neo row above)

  • A: saved 7.3.0-aurora-fleet94. B: one-shot 7.3.0-mrows3342 built from aa9ee1470cb2 (the same kit as the Neo row, aurora.ko build-id 4ec43506ae7a; its config differs from fleet94 only by APPLE_PANEL_NOTCH), booted through a non-default BLS entry + grub2-reboot; saved entry, Stage 2, DTB and command line unchanged. SELinux Enforcing, desktop session up.
  • Same installed Mesa, same VK-GL-CTS lists as the Neo row (13,537 cases). Every list gives the same result on both kernels:
    • draw.renderpass.{indexed_draw,simple_draw,basic_draw}: 538/538 pass
    • pipeline.monolithic.{multisample,depth,stencil} (every 10th case): 4693/7765 pass, the rest not supported
    • synchronization{,2}.timeline_semaphore.* (without the image_64x64x8 cases): 5153/5153 pass
    • compute.pipeline.basic: 79/81 pass, 2 not supported
    • 0 Fail on either kernel.
  • Template counters (debugfs aurora-g17/capacity, B only; base has no template path):
    • after boot: full=416 patched=449 verified=8 mismatched=0 unmapped=0
    • after the CTS run: full=23100 patched=32388 verified=5507 mismatched=0 unmapped=0
  • Kernel log: 0 GPU faults, timeouts or recoveries in either arm.
  • Restore: rebooted to the saved default, trial entry/kernel/modules removed, 0 failed units.

I didn't re-run the submit-CPU numbers.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

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>
@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) and removed ready-to-merge Meets the merge policy: merge it (bot) labels Dec 2, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Forward-merged main (4c6f0f70989f) into this branch and fixed the build break. The new head is 4c1d61691000.

What changed and why. main replaced RenderArgs::pair_idle with RenderArgs::ta_notify in 82783e2782d3 (#2213, the strided tiling notification policy). TaDescriptor::write now sets the tiling descriptor's first_kick word from ta_notify on every firmware build that uses it. The template still worked that word out from the ordinal and pair_idle, and its key destructure named pair_idle, so the merged tree did not compile. The merge itself (855b8b2f0bae) applied without conflicts. 4c1d61691000 is the whole fix (5 lines added, 8 removed):

  • The template patches first_kick from ta_notify, the same way TaDescriptor::write does.
  • ta_notify stays out of the template key, because it changes from one render to the next.
  • The KUnit test and the host fixture vary ta_notify where they used to vary pair_idle.

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:

  • g17 host tests in the pinned host-tests container (rustc 1.96.0, clang 18): 333/333 passed, including the render-template fixture and its 3 mutations. With a constant first_kick, the fixture fails at TA byte 2242, so it does check this field.
  • arm64 asahi profile W=1 modules_prepare drivers/gpu/drm/asahi/: the driver builds and links. There are 44 warnings, none in files this PR touches; a recent W=1 build based on main shows the same ones.
  • checkpatch.pl --strict: no errors, warnings or checks.
  • KUnit did not run locally (no QEMU).

What this changes on hardware. M5 render pairs have no template. On the J714s, this PR's code therefore behaves as it did at aa9ee1470cb2, and only main's commits are new. On the J700 and the J616s, the template now sets the tiling notification word with main's policy instead of the old pair_idle rule. That is what main already does.

main has since moved to 1262f9e1b6af, and none of its new commits touch g17/.

Still needed: a fresh J714s exact-head row and an approval from someone other than the pusher. This push dismissed the earlier approval.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 are aa9ee147 and 4c6f0f70, in that order, and the merge base is 27284bfe (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.rs and tools/asahi/run-host-tests.py. Every path changed only on main matches main, every path changed only on the branch matches aa9ee147, and nothing else differs. For the four overlapping files, a three-way git merge-file merges cleanly, and the result is byte-identical to the blob in 855b8b2f. No hunks are lost or added.
  • first_kick in the template. TemplateSlot::patch (render_template.rs:585) sets first_kick = ta_notify, matching TaDescriptor::write (render.rs:1328). patch runs 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. Keeping ta_notify out of Key (:95, :121) is right: it changes from kick to kick, and keying on it would only churn the template. The fragment descriptor's first_kick still follows ordinal == 0 in both the full and the patched encode.
  • Other callers. The only place that builds RenderArgs for a real kick is Pair::prepare (queue/render.rs:617), which computes ta_notify from main's policy. The direct, prepare and replay paths all go through it. write_m5 copies the args with ..*args, and M5 never uses this descriptor or the template (render_template is None there). pair_idle appears nowhere at this head. Main's other changes since the base don't touch the render encoders: in fw/render.rs the only change is pair_idle to ta_notify, and in memory.rs it is the command-storage mapping protection. Nothing new writes into a descriptor after encode. patch still resets the fields that set_completion_link and bind_work_slot write.
  • Tests, mutation check. I ran tools/asahi/g17-render-template-tests.py on this head's sources. The control passes 2/2. Three mutants of the first_kick line are all caught: dropping the patch (2 tests fail), the old ordinal == 0 rule (2 fail), and a constant 1 (1 fails, with a path mismatch at i=1). In both the KUnit test and the host fixture, ta_notify = ordinal % 4 == 0 gives 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, 82783e27 actually replaced an unconditional first_kick = 1; pair_idle was removed in an earlier commit. The net change against this branch's base is the same. A first_kick mutant could join the three in run-host-tests.py, but the byte comparison already catches it.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J700 (MacBook Neo, A18 Pro, G17P B1): PASS at exact head 4c1d61691000, head vs base

Two one-shot boots on the same J700, about 9 minutes apart, through an aura-try trial Stage 2 (b18). Stock options plus panic=10. Identical .config.

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=0 and unmapped=0 in every sample. patched went 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 with VK_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_chain indep: 387 / 428 / 448 vs 448 / 329 / 330 us. The head is lower in one run and higher in two.
  • pass_chain frag_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.light depth 1: 15.7 / 16.7 / 16.8 vs 16.1 / 18.0 / 18.4 us. The head is lower in all three.
  • render.light depth 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_kick value 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.

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

Copy link
Copy Markdown
Contributor Author

PASS on J714s (MacBook Pro 14" M5 Pro, T6050 G17S B1) at exact head 4c1d616910005976fa5b2504546c4a9a9d03d3b3 (0-conflict merge 1c15060b1292 onto origin/main 2c667a4be5a6, release 7.3.0-m5-pr3342-4c1d6169, boot_id=c30b02c9-3b64-4719-a18d-a5be79c99d04, SLC 16 planes, headless WSI, 0 display windows): no-regression render/RT smoke passed (rt.scene 67.52 FPS vs origin/main ABBA mean 67.62 FPS, -0.14%, exact CRC match); aurora-g17/capacity reports g17_render_template full=0 patched=0 verified=0 mismatched=0 unmapped=0 (expected on G17S B1, mismatched=0, online=1, crashed=0, quarantined=0); 0 GPU faults, 0 timeouts, 0 recoveries, 0 kernel WARN/Oops; clean stock 7.3.0-m5-pr67 handback (boot_id=154b9874-a3e5-46c8-a5a5-837ba7143a0e).

@RyanTheTide RyanTheTide 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.

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.

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Dec 3, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Local stand-in for the hosted KUnit asahi job (queued since 23:43Z), on pc:

  • g17 host tests on the merge tree of main d1ae4f292b93 + 4c1d61691000 (e9df3eba3a46, no conflicts), pinned host-tests container, run-host-tests.py --only g17: all 337 runs pass. The 21 that read control commits (g17-telemetry-integration, g17-object-fence) first failed because the tree had no git directory; they pass with it mounted.
  • make ARCH=arm64 LLVM=1 drivers/gpu/drm/asahi/ at 4c1d61691000 with CONFIG_KUNIT=y: builds and links, and the two render_template KUnit cases are in aurora.o. They were not executed here (no arm64 KUnit on our hosts); the host test runs the same production code. The asahi files main changed after the J714s merge build (2c667a4b) are only .kunitconfig and fwid.rs.

Rows at this head: J700 and J714s. Approved by RyanTheTide. Merging.

@DjDeveloperr
DjDeveloperr merged commit 231ca30 into main Dec 3, 2026
13 of 15 checks passed
@DjDeveloperr
DjDeveloperr deleted the feat/g17-submit-cpu-templates branch December 3, 2026 01:16
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:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants