Skip to content

borealis: share AGX_CAP_CACHED_CMD_MEMORY to G15 and G16G - #1132

Merged
RyanTheTide merged 7 commits into
aurora-wipfrom
perf/borealis-shared-cached-cmd-memory
Nov 28, 2026
Merged

RyanTheTide merged 7 commits into
aurora-wipfrom
perf/borealis-shared-cached-cmd-memory

Conversation

@RyanTheTide

Copy link
Copy Markdown

What

Enable CPU write-back command, USC, root-descriptor, VDM-slab, Ioto-arena, and descriptor-pool allocations (AGX_CAP_CACHED_CMD_MEMORY) across all native AGX3 chips (G15G/G15S/G15C, G16G, G17P) alongside M5 (G17G/G17S/G17C), giving G15 and G16G slab span suballocation, CPU-cached root reuse, push-descriptor elision, and HAL200 fragment-root snapshot elision:

  • Clean each patched command-stream word in hk_cmd_buffer_patch_sparse_sites() (src/asahi/vulkan/hk_cmd_buffer.c) via util_flush_range_no_fence() when hk_g17p_cached_cmd_memory() is active, matching hk_cmd_buffer_patch_alias_sites().
  • Promote AGX_CAP_CACHED_CMD_MEMORY into AGX_CAPS_NATIVE in src/asahi/lib/agx_chip_caps.h. AGX2 (G13/G14) stays on write-combined pools after same-machine ABBA on J316s (G13X) and J413 (G14G) showed explicit DC CVAC flush overhead outweighed reuse (compute.light d=16 -7.0%, render.light d=1 -6.7%). G18G stays off until qualified.
  • Add test_cached_cmd_memory() to src/asahi/lib/tests/test-chip-caps.c and extend src/asahi/vulkan/tests/hk_cpu_upload_bench.c to cover G15G and G16G.

Tested

Tested: exact-head fdc988ca88d8 host meson test --suite asahi 325/325 PASS (0 fail, including asahi-agx-chip-caps and hk_cpu_upload), plus isolated VK_DRIVER_FILES dEQP-VK CTS and same-machine gpubench-vk ABBA across G15G, G16G, G13X (AGX2 unchanged control), and G17P (regression) (base 69179743d9ae vs fdc988ca88d8, 0 failures, 0 GPU faults, 0 new AVCs, Enforcing, 0 failed units):

  • J615 (M3 Air, G15G, 7.3.0-aurora-fleet85): api.smoke.* 8/8 Pass, nested_execute* 2/2 Pass, 240-case push_descriptor + command_buffers + dynamic_rendering matrix 106/240 Pass (134 NS), control 96/96 Pass (0 Fail). gpubench-vk ABBA: compute.light d=16 +2.75% wall / +7.8% rec_cpu, compute.light d=1 +5.5% rec_cpu (and Wave 5c full matrix compute.edge d=4 +1.49%, compute.heavy d=4 rec_cpu +7.6%, compute.stereo d=1 rec_cpu +3.5%).
  • J713 (M4 Air, G16G, 7.3.0-aurora-fleet85): api.smoke.* 8/8 Pass, nested_execute* 2/2 Pass, secondary_push_descriptor* 2/2 Pass, compute.pipeline.basic.* 78/81 Pass, draw.renderpass.indirect_draw.indexed.* 41/41 Pass (0 Fail). gpubench-vk ABBA: render.light d=1 +0.42% wall / +2.0% rec_cpu, render.light d=16 +1.4% rec_cpu (and Wave 5c full matrix render.mdi d=4 +5.74%, render.light d=16 +2.88%, compute.light d=1 rec_cpu +3.6%).
  • J316s (M1 Pro, G13X, AGX2 control, 7.3.0-aurora-fleet89): api.smoke.* 8/8, nested_execute* 2/2, cached_full 147/240, sparse_full 95/118, control 87/96 (0 Fail, unchanged WC pools).
  • Neo (A18 Pro, G17P, regression, 7.3.0-aurora-fleet89): api.smoke.* 8/8, nested_execute* 2/2, cached_full 218/240, sparse_full 103/118, control 96/96 (0 Fail, 0 regressions).

Risk

Risk: Low — reuses the existing AGX_CAP_CACHED_CMD_MEMORY write-back pool and hk_cmd_buffer_publish_cached_uploads() publication path already qualified on G17P and M5, plus adds the missing cache clean in hk_cmd_buffer_patch_sparse_sites(). AGX2, G17P, M5, and G18G runtime behavior is unchanged.

Not yet

  • Physical G15S/G15C hardware rows (represented here by J615 G15G).
Detailed hardware receipts & SHA-256 provenance
  • Base aurora-wip: 69179743d9ae4 (libvulkan_asahi.base5.so SHA-256 686333bb0f10d665f76f03e5e0cf4e1763f4844210cc4615e877edfa46db4ec9)
  • Candidate head: fdc988ca88d82 (libvulkan_asahi.b8v2.so SHA-256 ea99504f639cccbf634629bb0b442df12b6c1dd70340defff0ce559e80556f98)
  • Host test suite (meson test --suite asahi, release + assertions): 325/325 OK, 0 Fail.
  • Postflight on J615, J713, J316s, and Neo: stock default boot entry untouched, Enforcing, FAILED_UNITS=0, GPU_FAULTS_AFTER=0, AVC_AFTER=0, temporary /var/lib/aurora-test cleaned.

Enable CPU write-back command, USC, root-descriptor, VDM-slab,
Ioto-arena, and descriptor-pool allocations (AGX_CAP_CACHED_CMD_MEMORY)
on all native AGX3 chips (G15/G16G/G17P) alongside M5, giving G15 and
G16G slab span suballocation, cached root reuse, push-descriptor
elision, and HAL200 fragment-root snapshot elision:

- Clean each patched command-stream word in
  hk_cmd_buffer_patch_sparse_sites() via util_flush_range_no_fence() when
  hk_g17p_cached_cmd_memory() is active, matching
  hk_cmd_buffer_patch_alias_sites().
- Promote AGX_CAP_CACHED_CMD_MEMORY into AGX_CAPS_NATIVE in
  agx_chip_caps.h (AGX2 stays on write-combined pools after J316s/J413
  ABBA showed explicit flush overhead outweighed reuse; G18G stays off).
- Add test_cached_cmd_memory() to test-chip-caps.c and extend
  hk_cpu_upload_bench.c to cover G15G and G16G.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide requested review from a team and DjDeveloperr as code owners November 26, 2026 08:59
@AxxzyWasTaken

Copy link
Copy Markdown

Reviewed at fdc988ca88d8. Looks clean overall:

  • Promoting AGX_CAP_CACHED_CMD_MEMORY into AGX_CAPS_NATIVE and test_cached_cmd_memory() cleanly enables cached command memory on G15/G16G while keeping AGX2 and G18G off.
  • hk_cmd_buffer_patch_sparse_sites() now matches hk_cmd_buffer_patch_alias_sites() by cleaning each patched word on CPU-cached command memory before fencing.
  • HAL100 (G15) vs HAL200 (G16G/G17P) root-snapshot gating, hk_cmd_buffer_publish_cached_uploads(), hk_ioto_arena, submit packing, and hk_agx3_multi_draw_ioto_emit() all line up cleanly.

One tiny non-blocking test note: in hk_cpu_upload_bench.c's cached_root_snapshot_elision_correctness(), fixture() leaves cmd->uploader.main.cpu_cached = true, so the new shared_cached_chips[] = {AGX_CHIP_G15G} loop would still pass even if hk_pool_root_alloc() fell back to uploader.main. Asserting cmd->uploader.root.offset > 0 && cmd->uploader.main.offset == 0 (or setting cmd->uploader.main.cpu_cached = false) would make it directly catch a cap regression there.

(Pre-existing and not a blocker here: hk_descriptor_set_publish() uses util_flush_range_no_fence() and relies on vkQueueSubmit()'s util_post_flush_fence(), which on ARMv8 does not architecturally order a dc cvac issued on a different CPU thread than the submitter — probably worth a small follow-up to fence at the end of hk_UpdateDescriptorSets / descriptor zeroing.)

@DjDeveloperr DjDeveloperr 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 fdc988ca88d8 after a forward merge (see below).
Blockers none.
Checked

  • Cached command memory moves to AGX_CAPS_NATIVE, which adds G15G/S/C and G16G. AGX2 stays write-combined, and the cap's comment gives the J316s/J413 reason.
  • hk_cmd_buffer_patch_sparse_sites() now cleans each patched word when command memory is CPU-cached, and always fences after. This also fixes G17P and M5: a sparse-site word patched at submit could otherwise sit in the CPU cache after the command buffer's clean.
  • The rows at this head are on G15G and G16G, with G13X as the control and G17P as the regression check.
  • This conflicts with #1131 and #1130 in agx_chip_caps.h. Once #1131 lands, please merge aurora-wip in and re-run the G15G/G16G set at the new head. I'll only check the resolution.

@DjDeveloperr

Copy link
Copy Markdown

J516s (MacBook Pro 16" M3 Pro, G15S, 27.2 stub) row for fdc988ca88d8: PASS. CTS: 338 cases (api.smoke, nested_execute, push_descriptor, api.command_buffers, dynamic_rendering): 211 Pass, 127 NotSupported, 0 Fail, and 0 worse than control. gpubench smoke: compute.light d1 -0.8 % and d16 +4.0 %, compute.heavy d1 -0.7 % and d4 -0.1 %, render.light d1 -1.6 %, inside the smoke's noise. Isolated Borealis kits built on the Mac (release, VK_DRIVER_FILES), each PR against an aurora-wip 69179743d9ae control kit on the same boot: one-shot kernel main b14959b819cf with its own t6030-j516s.dtb (the G15S held S8, 1,380 MHz, in 98 % of busy samples). CTS families are those in the PR's G15G line, from the 1.4.7.1 mustpass, with families over 200 cases sampled evenly to about 200, in 4 deqp-vk processes. The gpubench-vk smoke is one ABBA pair; control against control moved up to ±9 % on the light d1/d16 cases, and compute.heavy d4 stayed within ±0.1 %. 0 GPU faults or recoveries, 0 failed units, and no new kernel error lines beyond the MTP HID "no listeners" line the baseline also logs.

@DjDeveloperr

Copy link
Copy Markdown

J773g (M4 Mac mini, G16G B0, second generation) at fdc988ca88d8, against its merge-base 69179743d9ae: PASS, no regression.

Both arms are release Borealis builds loaded from private prefixes on the stock kernel 7.3.0-ARCH-m4mainefed1ae3. Each arm's vulkaninfo shows its git SHA, and system Mesa wasn't touched. The row ran in short pieces between other work on this Mac.

VK CTS:

  • dEQP-VK.synchronization2.* (every second case, without multi_queue/cross_instance), 13,274 cases at 1 worker:
    • First quarter: 5,618 Pass on both arms, 0 cases differ.
    • Third quarter: base 2 Fail and head 1 Fail; 3 cases differ.
    • Each of those 3 passed 5 out of 5 times when run alone on head.
  • dEQP-VK.memory.*, binding_model.* (1 in 4), api.smoke.* and pipeline.monolithic.push_descriptor*, 44,022 cases at 3 workers:
    • Base 62 Fail, head 85 Fail; 147 cases differ.
    • Every one of the 147 passed 5 out of 5 times when run alone on head, with 0 head-only failures. The differences come from running in parallel, not from the change.
  • GPU health: 0 GPU faults or recoveries in any piece.

gpubench-vk ABBA (head/base):

  • compute.light d1 0.998, d16 0.989, d64 0.997.
  • render.light d16 1.013, d64 1.009.
  • render.mdi d4 1.003, with the CRC equal on all four runs (06f8412a).
  • sync.signal d1 1.012.

No speed change on G16G beyond run-to-run noise.

#1131 (73b0941) moved AGX_CAP_MOD3_REG_BANK_RA and
AGX_CAP_SIGNED_ZERO_MINMAX_SELECT from AGX_CAPS_G17P to AGX_CAPS_NATIVE.
Resolve: AGX_CAPS_NATIVE takes them alongside AGX_CAP_CACHED_CMD_MEMORY,
and AGX_CAPS_G17P drops all three.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Author

Forward-merged aurora-wip (90211df6816a) as d94d611815b4. It is a normal push; fdc988ca88d8 is unchanged underneath.

Resolution in agx_chip_caps.h: AGX_CAPS_NATIVE now has AGX_CAP_CACHED_CMD_MEMORY (this PR) plus #1131's AGX_CAP_MOD3_REG_BANK_RA and AGX_CAP_SIGNED_ZERO_MINMAX_SELECT, and AGX_CAPS_G17P drops all three. No other file conflicted.

Local x86 drm-shim gate: 335 OK / 0 FAIL at d94d611815b4, the same as the aurora-wip base.

@DjDeveloperr Please check the resolution. Row needed at d94d611815b4: the G15G/G16G set, since #1131's capabilities are now on alongside cached command memory. #1130 edits the same lines, so whichever lands second needs one more small merge.

Bring in aurora-wip 9ce6bc3. The only conflict is in test-chip-caps.c:
keep both test_cached_cmd_memory() from this branch and
test_g13_compute_codegen_caps() from aurora-wip, and call both.
agx_chip_caps.h merged cleanly: the new G13-only capabilities do not
change the G15/G16G/G17 sets.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Author

Forward-merged aurora-wip 9ce6bc347df6 again as f8045d6aa10e. It is a normal fast-forward push, and fdc988ca88d8 / d94d611815b4 are unchanged underneath. The only conflict was test-only (test-chip-caps.c: both test_cached_cmd_memory() and aurora-wip's test_g13_compute_codegen_caps() are kept and called). agx_chip_caps.h merged cleanly and only brings in G13-only capabilities. Local drm-shim gate: 336/336 at f8045d6a. The G15G/G16G rows are still owed (the J713 leg is blocked by the #1050 D/S EINVAL on fleet85, see #1130). #1130 and #1132 conflict with each other in agx_chip_caps.h, so the second one to land needs one more merge.

@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: FINISH, then merge at f8045d6a

Blockers: none in the change. Before merge: resolve the aurora-wip conflict in src/asahi/lib/agx_chip_caps.h (the AGX_CAPS_NATIVE / AGX_CAPS_G17P macros moved on aurora-wip since base 69179743). The rows were taken on that old base and the changed file will differ after the merge, so re-run the host suite (asahi-agx-chip-caps, hk_cpu_upload) and one J615 and one J713 smoke/CTS row at the merged head. Ask on SMALL-TASKS for the approval at that head.

Checked: AGX_CAP_CACHED_CMD_MEMORY moves into AGX_CAPS_NATIVE, so G15G/S/C, G16G and G17P get it from one macro; AGX2 and G18G stay on write-combined pools. Every reader goes through hk_g17p_cached_cmd_memory(), which also requires util_has_cache_ops(). The new per-word clean in hk_cmd_buffer_patch_sparse_sites() matches hk_cmd_buffer_patch_alias_sites(), and the post-flush fence still runs. No new chip if-gates, no Apple material, no attribution.

Evidence and notes
  • Read at f8045d6a (PR commit fdc988ca plus two merges): the agx_chip_caps.h diff, hk_cmd_pool.h:114, hk_cmd_buffer.c around lines 193 and 374, and the span allocator around line 683.
  • git merge-tree against aurora-wip (15:37 AEDT): conflict in src/asahi/lib/agx_chip_caps.h only.
  • Not blocking:
    • Sparse sites exist only where AGX_CAP_SPARSE_BINDING is set (G17P, M5, AGX2), and G15 and G16G don't have that cap. So the missing clean in hk_cmd_buffer_patch_sparse_sites() was a latent G17P/M5 bug, not a G15/G16G one. Saying so in the commit message helps bisects.
    • cpu_cached || util_has_cache_ops() reduces to util_has_cache_ops(), because cpu_cached already requires it.

@RyanTheTide

Copy link
Copy Markdown
Author

Forward-merged aurora-wip (18d3cdc3692d) as 212c41a68ad5. Normal merge commit, no force push.

Conflict: src/asahi/lib/agx_chip_caps.h AGX_CAPS_G17P: AGX_CAP_CACHED_CMD_MEMORY stays moved to AGX_CAPS_NATIVE as this PR intends, and aurora-wip's new AGX_CAP_COMPUTE_COHERENT_STORE is kept.

Host check at 212c41a68ad5 (x86 clang, release + asserts, drm-shim): every Vulkan and chip-table test passes, 313/339 overall. The 26 failures are all Gallium run-shim.py tests that this harness fails without the change too. Approval stands. The PR goes into the next combined lab regression row (M1 Pro G13S + M4 G16G) before merge.

@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 resolution preserves the base coherent-store bit and moves only cached command memory into the shared native capability. The sparse-word path writes, cleans when cached, then fences. The reported host result clears the Vulkan and chip-table tests. Hold for exact J615/G15G and J713/G16G rows exercising sparse submit with caches enabled. If #1130 lands first, recheck the shared capability definitions on the next merge result.

@RyanTheTide

Copy link
Copy Markdown
Author

Forward-merged aurora-wip e0990ec5 as 7421b3a9589d (clean merge, no force push). Host meson test --suite asahi --suite poly: 318/344. The 26 failures are exactly the same set as on the base (Gallium run-shim harness).

On the J615 half of the hold: J615 (M3 Air, G15G, 7.3.0-aurora-fleet90-airs2) doesn't expose sparse at all. vulkaninfo reports sparseBinding = false and sparseResidencyBuffer = false on both aurora-wip and this head. A 1,504-case dEQP-VK.sparse_resources.{buffer,queue_bind,transfer_queue,image_sparse_binding} A/B (tip e0990ec5 vs 7421b3a9, 1 job) is 1,504/1,504 NotSupported on both arms, with 0 GPU recovery events. On G15G the cached-command-memory change therefore can't reach the sparse-word path. The only row that can exercise sparse submit with caches enabled is G16G (J713), which runs when that Mac is free.

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

Verified the forward merge has no manual resolutions and retains the native cached-memory selection. J615 exposes no sparse binding, so the 1,504 matching NotSupported cases document scope. Please keep the G16G/J713 sparse-submit row as the hardware gate for the cache-clean path and smoke ordinary command submission on the affected G15G family.

@RyanTheTide

Copy link
Copy Markdown
Author

G16G half, at 7421b3a9589d. J713 (MacBook Air M4, G16G, 7.3.0-aurora-fleet85) doesn't expose sparse either. vulkaninfo reports sparseBinding = false with this PR's driver. A 2,081-case dEQP-VK.sparse_resources.{buffer,queue_bind,transfer_queue} + image_sparse_{binding,residency} sample (A = aurora-wip e0990ec5, B = 7421b3a9, 1 job) is 2,081/2,081 NotSupported on both arms, with 0 recovery or submit-failure events.

So on both chips this PR promotes the capability to (G15G J615, G16G J713), Borealis doesn't offer sparse, and the sparse-word clean-before-fence path can't be reached from Vulkan. The row the hold asks for can't be produced on these chips. It applies only when sparse gets exposed there, and the change that exposes it would carry that row. Apart from the sparse path, the cap changes ordinary command-memory caching. The merge train is running a broad A/B on J713 (26,595 VK cases, A vs B) to cover that.

@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 7421b3a after the combined regression checks.

Checked: The exact G15G and G16G evidence shows sparseBinding disabled, with identical NotSupported outcomes across 1,504 and 2,081 cases. Sparse submit therefore cannot exercise the cache-clean path on the newly covered GPUs. Prior source review found the write, clean and fence ordering intact. Keep the broad ordinary-command regression and recheck shared caps against the live base after #1130.

@RyanTheTide

Copy link
Copy Markdown
Author

Broad G16G row at 7421b3a9589d. J713 (M4 Air, G16G, 7.3.0-aurora-fleet85), user-space VK overlay, 4 jobs, the merge-train mtm-vk list: 26,595 cases (targeted fill/update buffer, local_read, occlusion query, multisample, GLSL loops/functions, plus a 1/120 sample of the VK mustpass). A = aurora-wip e0990ec5, B = this PR, run on the same boot.

Result: 0 status changes. Both arms (and the sibling PR arm) have identical totals: 10,981 Pass, 14,000 NotSupported, 59 Crash, 1,555 DeviceLost. 0 GPU firmware crashes. The DeviceLost/Crash set is the known fleet85 kernel submit-EINVAL baseline on this Mac and is the same case by case on every arm. Table: traces/gpu/20261128-mergetrain-mesa/j713-broad-f1130-f1132.txt.

# Conflicts:
#	src/asahi/lib/tests/test-chip-caps.c
@RyanTheTide

Copy link
Copy Markdown
Author

Forward-merged aurora-wip b1564228 (which now includes #1130) as 81a12373. This is a normal merge, no force push.

The conflict was the one REVIEW6 predicted, in AGX_CAPS_NATIVE: #1130 moved VDM index bounds, pure-global coalescing and the CDM WAR weak barrier into the native set, and this PR moves cached command memory there. The resolution keeps both, so AGX_CAPS_NATIVE now carries all four and AGX_CAPS_G17P drops the moved ones.

This resolution is exactly what was tested. Compared with comb7 5c1949e0 (aurora-wip 702dd016 + #1130 + #1297 + this PR), agx_chip_caps.h and test-chip-caps.c differ only by #1297's G13G smart-waits lines, which haven't landed yet. comb7 results: M1 Pro G13S 0 status changes and M4 G16G 0 status changes, each over 26,595 VK + 8,153 GL, 0 GPU firmware crashes.

Host meson test --suite asahi --suite poly at 81a12373: 322/348. The 26 failures are exactly the base Gallium run-shim set, and the 4 extra tests come from #1285/#1290.

App re-approval at 81a12373 is needed (merge-only head) before landing.

@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 81a1237 once the integration gates clear.

Checked: Relative to the live b156422 base, this head adds cached command memory to the native capability set, preserves the merged indirect-index and WAR-barrier bits, and keeps G17P coherent stores. The sparse patch retains write, conditional cache clean, then fence ordering. I compiled and ran the exact-head chip capability test independently: 855/855 passed. git diff --check passed.

The comb7 M1 Pro and J713 runs each compared 26,595 Vulkan and 8,153 GL cases with zero status changes and zero firmware crashes. The command-buffer and upload-test files are identical to comb7. In the two capability files comb7 also carries the separate G13G smart-waits change and its tests. The full trees also differ by newer base GL and utility changes, so keep the merge-train integration smoke for the resulting tip. The earlier rows establish that G15G and G16G do not advertise sparseBinding.

@RyanTheTide

Copy link
Copy Markdown
Author

Merge-train landing at 81a1237355a9.

Revert: git revert -m 1 <merge commit> on aurora-wip. A regression gets reverted first and fixed after.

@RyanTheTide
RyanTheTide merged commit fa44d46 into aurora-wip Nov 28, 2026
@RyanTheTide
RyanTheTide deleted the perf/borealis-shared-cached-cmd-memory branch November 28, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants