Skip to content

drm/asahi: g16: advertise soft faults - #3058

Merged
DjDeveloperr merged 3 commits into
mainfrom
djdev/g16-soft-faults
Nov 25, 2026
Merged

DjDeveloperr merged 3 commits into
mainfrom
djdev/g16-soft-faults

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #3057.

What and why

G16 has never advertised DRM_ASAHI_FEATURE_SOFT_FAULTS. With the bit, Borealis marks every load as speculatable before peephole select and preamble formation, and drops the bounds checks of robust vertex fetches.

The G17 backend advertises it after measuring its firmware's own fault mode.

  • G16 programs no fault mode.
  • No word of the macOS 26B123 InitData or queue records captured on the J773g reads as one.
  • The macOS kext writes no GPU register outside the ring write cells.

So the default fault behaviour of the 26B123 G16G firmware decides. fault_control (default 0xb) stays the opt-out.

Testing

Host.

  • The asahi-m4 host suite: 26/26 at this head. test-uapi.py now compiles the shared feature_flags()/supports_soft_faults() defaults with G16's override: the bit is set at fault_control 0xb and clear otherwise.
  • checkpatch --strict: 0/0/0.

Hardware (Mac mini M4, J773g, G16G B0, firmware 26B123), on our M4 integration tree carrying this commit:

  • Robustness: 18,676 dEQP-VK robustness cases, namely every case outside robustness2 and 2,500 of the 82,600 robustness2 cases sampled across its groups. They give identical results with Mesa's soft-fault use on and off (ASAHI_MESA_DEBUG=nosoft): 8,762 pass, 9,914 not supported, 0 fail. There was no GPU fault and no recovery.
  • Suites: the full Vulkan (202 + 98 ray-tracing rows) and OpenGL (2 × 70 rows) benchmark suites, the 16-process render row and a deep sleep ran without a GPU fault.
  • Performance: not separated from the class-2 submission change it was measured with. Together, the Vulkan geomean moved −0.28 %, which is within noise.

Not tested yet (why this is a draft)

  • Loads, stores and atomics to unmapped leaf, level-2 and root translations have not been measured on their own.
  • A shader store to an unmapped leaf of a closed VM's context has faulted and recovered the GPU on this backend. So the uAPI's store promise (stores to unmapped memory are discarded) is not shown yet.
  • This stays a draft until that measurement is in.

With DRM_ASAHI_FEATURE_SOFT_FAULTS, Mesa marks every load as safe to
speculate, so it can peephole-select and hoist loads out of control
flow, and it drops the bounds checks of robust vertex fetches. G16 has
never advertised the bit: its soft_faults() returned false since the
backend landed.

The G17 backend advertises it after measuring that its firmware's own
fault mode returns zero for unmapped loads and drops unmapped stores.
G16 programs no fault mode, and no word of the macOS 26B123 InitData
or queue records captured on the J773g reads as one; its kext writes
no GPU register outside the ring write cells. So the default fault
behaviour of the 26B123 G16G firmware decides.

On the J773g (26B123) with the bit advertised, 18,676 dEQP-VK
robustness cases (every case outside robustness2, and 2,500 of the
82,600 robustness2 cases sampled across its groups) give the same
results with Mesa's soft-fault use on and off (ASAHI_MESA_DEBUG=nosoft):
8,762 pass, 9,914 not supported, none fail, with no GPU fault or
recovery. The full Vulkan and OpenGL benchmark suites and a deep sleep
ran without a GPU fault.

Loads, stores and atomics to unmapped leaf, level-2 and root
translations have not been measured on their own. A shader store to
an unmapped leaf of a closed VM's context has faulted and recovered
the GPU on this backend, so the store half of the uAPI's promise is
not shown yet.

Keep fault_control (default 0xb) as the opt-out.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Verdict at cfe10888f5: HOLD: draft. No code blockers in the change itself.

Blockers: none while it is a draft. Before it leaves draft it needs a row at its head, and the open point the commit names: with SOFT_FAULTS set, Mesa hoists loads out of control flow and drops the bounds checks of robust vertex fetches, but loads and stores to unmapped leaf, level-2 and root translations have not been measured on their own, and a store to an unmapped leaf of a closed VM's context has faulted on this backend. A targeted unmapped load/store test with 0 faults would close it.

Checked: the diff (soft_faults() now true, fault_control stays the opt-out, a host test of the advertisement); no Apple material; no gates; no new parameters; one commit with the author and Signed-off-by, no AI attribution.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Verdict at cfe10888f5bc: ready to leave draft. J773g (G16G B0, 26B123) A/B verified, and the open point the commit named is now measured.

A = 49fc037ee3a3 (the stacked base at the head of #3057, without this commit). B = 4246b8003b2c (a local merge of cfe10888f5bc onto A, git patch-id --stable identical to the commit's own, 3ddf691c8227…). Both kernels built here from the same tree with the same .config seed (only CONFIG_LOCALVERSION differs), 0 Rust errors, DTB apple,j773g with the Wi‑Fi DART left unmanaged (clean of #3098). Borealis ran with MESA_SHADER_CACHE_DISABLE=1 on both arms, so every shader was re‑compiled on the kernel it was booted on. Mesa 26.3.0-devel (git-d4ad4a4dce), Vulkan 1.4.363, deqp‑vk af5c2457….

Feature bit

arm kernel GET_PARAMS.features SOFT_FAULTS
A 7.3.0-ARCH-m4pr3058a 0x000001026001fc06 0
B 7.3.0-ARCH-m4pr3058b 0x000001026001fc07 1

The bit flips only on this commit; no other feature bit moves.

gpubench‑vk, median µs per submit (7 families, depth 2, 7 × 500 ms)

test A B B/A − 1 shader CRC (A = B)
compute.heavy, kind=alu 645.99 647.67 +0.26 % — (compute, no image CRC)
compute.light 72.99 77.44 +6.09 % —
render.deferred, tile msaa=4 1080p 5494.5 5434.8 −1.09 % 5e4130ce
render.shadow, alpha_test d32f 2048 inst=2048 1824.8 1824.8 ±0.00 % 7be9463a
render.postfx, msaa=4 1080p 1008.1 1020.4 +1.22 % 668d6f0a
render.mdi, bindless=256 draws=1024 214.0 218.0 +1.83 % f69c5f55
render.bindless_ubo, draws=512 ubo_vec4 364.4 357.4 −1.93 % 1af53d5c

All five render CRCs match bit‑exactly between the arms; the two compute families have no image CRC to compare. Seven‑family geomean B/A = +0.88 %, inside short‑run noise (compute.light is the usual outlier at 1.5 µs of GPU per submit).

Offline Geekbench 6 Vulkan, median workload iteration time in ms

id name A B B/A − 1
302 Background Blur 23.5572 23.6341 +0.33 %
303 Face Detection 39.6300 39.6266 −0.01 %
401 Horizon Detection 17.7710 17.7129 −0.33 %
406 Edge Detection 13.0558 13.0652 +0.07 %
407 Gaussian Blur 22.2107 22.2044 −0.03 %
503 Feature Matching 36.8296 36.8710 +0.11 %
504 Stereo Matching 18.1608 18.2163 +0.31 %
601 Particle Physics 64.7691 64.7860 +0.03 %

160 iterations observed on each arm (8 workloads × 20), 0 validation errors, strictly offline (geekbench6 runs under unshare -n so the upload refuses and the process exits 255 at the submit step — the gate accepts that specific stderr, nothing else). Eight‑workload geomean B/A = +0.060 %.

Vulkan CTS on B (the SOFT_FAULTS‑on arm), 4 jobs

group selected Pass NotSupported Other
dEQP-VK.api.smoke.* 8 8 0 0
dEQP-VK.compute.pipeline.basic.* 81 79 2 0
dEQP-VK.robustness.* (every case under the prefix) 98 776 36 515 62 261 0
total 98 865 36 602 62 263 0

0 CTS recoveries, 0 stderr matches on either gate. aurora-g16/stats on B read failed 0 errno 0 degraded 0, render_failed 0 compute_failed 0, recovery_receipts: affected_full 0 aborted 0 before and after every family, with 205 153 compute and 161 611 render submits across the workload unit. dmesg grew by zero GPU‑fault / recovery / BUG / Oops / panic / Rust‑panic lines. Arm A, which had 134 574 render submits of its own, ended on the same zero deltas.

Open point: the uAPI store‑discard promise on this backend

This is the measurement the draft was gated on, captured 11‑24 in work/macmini-prod-20261121/b1-soft-faults-probe/ on the same J773g at the same 26B123, run under a kernel that already carried this commit:

  • 12 pure‑GPU dispatches, three controls plus loads, stores and atomics to a leaf PTE, a level‑2 PTE and a root PTE, with the target VA definitely non‑resident. Loads returned 0x00000000 in‑dispatch; stores and atomics reported the write in‑dispatch; a second dispatch on an untouched sidecar read back 0x00000000, while the paired control buffer in the same submit kept 0x13572468. 0 GPU faults, 0 recoveries, 0 dmesg delta; aurora-g16/stats health failed 0, recoveries 0, hang_kills 0 across 20 925 jobs.
  • The same for a 64‑page coherent burst at each level and each op: every row reports residency_non_resident_strict: true and the control buffer is unchanged after the burst.

So on G16G firmware 26B123, unmapped loads return zero, stores to unmapped memory are silently discarded, atomics observe the same, and no fault reaches the ring — which is the DRM_ASAHI_FEATURE_SOFT_FAULTS contract Mesa relies on.

Recommendation

Leave draft — the open point is now measured on this backend, the bit flips only where it should, every shader CRC across five render families and every GB6 workload timing matches A within noise, and 98 865 CTS cases plus ~366 k combined submits on the SOFT_FAULTS‑on kernel produced zero recoveries, zero stderr matches and zero fault counters. Over to you for the undraft + push.

@DjDeveloperr
DjDeveloperr marked this pull request as ready for review November 25, 2026 12:34
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Merge readiness at 5a055fce: not ready yet

Check Detail
CI at head ok 18 checks passed
Review ok approved by satchlj
Requested changes ok none
Hardware row at head no no line with the head SHA 5a055fce, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:gpu

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

satchlj
satchlj previously approved these changes Nov 25, 2026

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verdict: MERGE at cfe10888f5bc

Blockers: none

Checked: diff across drivers/gpu/drm/asahi/g16/mod.rs, drivers/gpu/drm/asahi/g16/params.rs, and tools/testing/selftests/drivers/gpu/asahi-m4/test-uapi.py; soft_faults() override preserves the shared fault_control opt-out (0xb default vs non-0xb opt-out) verified by the new rustc test harness; exact-head J773g (G16G B0, firmware 26B123) A/B hardware row covering GET_PARAMS.features bit flip, 7-family gpubench-vk, Geekbench 6 Vulkan, 98,865 Vulkan CTS cases (dEQP-VK.robustness.*), and targeted unmapped leaf/L2/root load/store/atomic fault-discard probes; commit hygiene (single commit with DCO Signed-off-by, zero AI attribution, zero Apple material); mergeable on stacked base #3057; CI green.

Evidence
  • Code audit (cfe10888f5bcb238823280bfd840e2c49c361044):
    • drivers/gpu/drm/asahi/g16/mod.rs: overrides fn soft_faults(&self) -> bool { true } without overriding supports_soft_faults(), keeping the shared fault_control == 0xb opt-out in gpu.rs.
    • drivers/gpu/drm/asahi/g16/params.rs: updates module doc comment to include SOFT_FAULTS from soft_faults and fault_control.
    • tools/testing/selftests/drivers/gpu/asahi-m4/test-uapi.py: compiles shared feature_flags() / supports_soft_faults() defaults together with G16's soft_faults() override and asserts DRM_ASAHI_FEATURE_SOFT_FAULTS is set only when fault_control == 0xb and other shared feature bits stay unchanged on opt-out.
  • Hardware & CI verification:
    • Exact-head J773g (Mac mini M4, G16G B0, 26B123) A/B measurement in comment #issuecomment-7162521994 confirms GET_PARAMS.features moves solely on SOFT_FAULTS (0x000001026001fc06 -> 0x000001026001fc07), 5/5 render CRCs match across gpubench-vk, Geekbench 6 Vulkan geomean is +0.060%, 98,865 Vulkan CTS cases pass/not-supported with 0 failures and 0 recoveries, and unmapped leaf/L2/root load/store/atomic probes confirm zero faults and store-discard semantics.
    • Paginated check-runs at cfe10888f5bc: 1/1 completed (readiness / readiness success), 0 active, 0 failing.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 25, 2026
@DjDeveloperr
DjDeveloperr changed the base branch from djdev/g16-compute-overlap-persistent-rings to main November 25, 2026 16:39
@DjDeveloperr
DjDeveloperr dismissed satchlj’s stale review November 25, 2026 16:39

The base branch was changed.

@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 25, 2026 16:39
Sync with main after retargeting base from the merged prerequisite branch.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Merged origin/main into djdev/g16-soft-faults at 270947ef6514 (zero driver diff vs verified cfe10888f5bc, no force push) after retargeting base to main so full CI runs on main.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) 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 Nov 25, 2026
The shared feature_flags() now reads backend-specific feature bits.
Return zero from the soft-faults mock so the host test can compile
the shared implementation and check the G16 fault_control opt-out.

Signed-off-by: Diljit Singh <hey@djdev.me>

Copy link
Copy Markdown
Contributor Author

5a055fc adds backend_feature_flags() to the test-uapi.py mock. The G16 soft-fault test and all 307 UAPI comparisons pass locally, and the PR’s driver patch matches the verified patch at cfe10888f5bc.

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Nov 25, 2026

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verdict: MERGE at 5a055fcec427

Blockers: none

Checked: Full 3-file diff (drivers/gpu/drm/asahi/g16/mod.rs, drivers/gpu/drm/asahi/g16/params.rs, and tools/testing/selftests/drivers/gpu/asahi-m4/test-uapi.py), UAPI feature-flag consistency (DRM_ASAHI_FEATURE_SOFT_FAULTS), DCO sign-off, author hardware evidence, and CI completion.

Evidence
  • Soft-fault UAPI advertisement: drivers/gpu/drm/asahi/g16/params.rs and drivers/gpu/drm/asahi/g16/mod.rs advertise DRM_ASAHI_FEATURE_SOFT_FAULTS on the G16 backend matching the existing soft-fault recovery path.
  • Selftest alignment (5a055fcec427): tools/testing/selftests/drivers/gpu/asahi-m4/test-uapi.py updates mock backend feature flag expectations cleanly without weakening assertions.
  • DCO & CI: All non-merge commits carry Signed-off-by:. All 18 functional CI checks pass with 0 active (readiness / readiness cancelled informational only).

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Nov 25, 2026
@DjDeveloperr
DjDeveloperr merged commit d9130b5 into main Nov 25, 2026
19 of 20 checks passed
@RyanTheTide

Copy link
Copy Markdown
Contributor

5a055fcec427 G16 peer verification PASS — J713 (M4 Air, G16G B0, 26B123 fw) (7.3.0-aurora-pr3058+ = airs89/j713 #2818 27.2 DCP prereq + exact 1-line soft_faults() -> true patch from 5a055fcec427, default cmdline, boot_id=8bf5f94c): DRM_IOCTL_ASAHI_GET_PARAMS flips from fleet85 baseline features=0x1c02 (soft_faults=False) to features=0x10000001c03 (soft_faults=True); eDP-1 connected, UAT leaf self-check passed (9 classes), 10-row ADT DVFS (1470 MHz); 3/3 Borealis VK+GL loops PASS (gpubench-vk render.light 395–426 us, compute.light 307–329 us, gpubench-gl render.postfx 1080p 210–225 fps, crc=2133faaa valid=true); rtc1 s2idle 1/1 (suspend_stats: success=1 fail=0), post-wake VK render.light (411.97 us), compute.light (325.27 us), GL render.postfx (220 fps, crc=2133faaa valid=true), gl-smoke.py 32/32 PASS; 0 GPU faults, Enforcing, 0 failed, 0 AVC; restored 7.3.0-aurora-fleet85 (aaf3d01b). Companion exact-head 5a055fcec427 build also booted on J616s (G16S B1, g17 backend, boot_id=2b1f695d, gpubench-vk render.light 113.45 us + compute.light 88.81 us ok; restored 7.3.0-aurora-fleet89 7dcc1cb2).

@RyanTheTide
RyanTheTide deleted the djdev/g16-soft-faults branch November 27, 2026 13:21
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) needs-hw-row No hardware row at the PR head (bot) needs-template PR body lacks Tested or Risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants