Skip to content

drm/asahi: g17: advertise soft faults - #2081

Open
jgoyvaerts wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
jgoyvaerts:m4pro/g17-soft-faults
Open

jgoyvaerts wants to merge 1 commit into
aurora-silicon:integration/aurorafrom
jgoyvaerts:m4pro/g17-soft-faults

Conversation

@jgoyvaerts

@jgoyvaerts jgoyvaerts commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Turns DRM_ASAHI_FEATURE_SOFT_FAULTS back on for every GPU the G17 backend drives. One commit.

6f7faee (our #391) turned it off on G17 because every robustness2 rgba32 vertex_attribute_fetch case read non-zero data with it on. The explanation in that commit was wrong. Mesa pointed out-of-bounds vec3/vec4 vertex fetches at address 0 plus index times stride. On G17 that range is not unmapped. Once a client runs compute work, install_job_context_aliases() maps the execution context's null view (CONTEXT_VIEWS[0]) at VA 0..0x10000, and userspace maps the other context views up to 0x74000. The fetches read the render context from there. Mesa stopped redirecting robust fetches to address 0 on G17 in 4115628b637f ("asahi: explicitly bound robust native vector vertex fetches").

The G17 firmware has no fault_control word, but its own fault mode already gives soft faults. That is a property of the firmware family, not of the SoC: the driver gives every G17 queue the same fault setting (QueueConfig::unk_66 = 1, the word the M5 firmware names soft_fault_enabled). So there is no per-SoC field. supports_soft_faults() in g17/mod.rs advertises the bit whenever fault_control keeps its 0xb default, as on the other generations. The commit also notes in the driver and in the uAPI doc that the first 0x74000 bytes of a G17 VM hold the context views, so userspace must not use them as a zero sink.

How tested (M4 Pro T6040, firmware 25G83, the only part measured):

  • With the bit clear, a probe read each unmapped address twice. Missing translation at the leaf, at level 1 and at the root all returned zero. An atomic on a read-only page was dropped. There was no fault and no recovery.
  • With the bit set, the probe gave the same reads. Stores of 512 words to unmapped addresses, and an atomic on an unmapped address, completed and read back zero.
  • With the bit set, all 98,776 dEQP-VK.robustness.* cases give the same results as without it: 47,933 pass, 50,843 not supported, 0 fail. The 117 robustness2 rgba32 vertex_attribute_fetch cases pass when run directly with deqp-vk. A kprobe on map_pages showed that those cases run in VMs whose VA 0 holds the null view.
  • 0 GPU recoveries across these runs.
  • This revision (per-SoC field dropped): arm64 build of drivers/gpu/drm/asahi/ with the M5 backend enabled is clean (no new warnings); checkpatch clean; asahi KUnit 685 pass / 1 skip.

Not measured: T6041 (M4 Max), T8140 (A18 Pro), T8142 and T6050 (M5). The same unmapped-read probe and the robustness run would show any part that differs. RyanTheTide offered to run robustness2 and the unmapped-read probes on an A18 Pro and an M4 Pro.

For the speed-up, Mesa has to use the bit on G17P. Shared Mesa currently keeps G17P code generation independent of soft faults. With soft-fault bounded uniform loads and load speculation enabled on G17P, Cyberpunk 2077 runs 7.3% faster on the M4 Pro. The Mesa side is not part of this PR.

🤖 Generated with Claude Code

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for working out that the earlier robustness failures came from the context views at low VAs, and for documenting that range in the uAPI.

The reasoning in drivers/gpu/drm/asahi/g17/mod.rs:244-246 is that the G17 firmware's own fault mode gives soft faults. That is a property of the firmware family, but the flag is set only in hw/t6040.rs:63 ("Measured on the M4 Pro only"), and the other G17 configs get false. We usually select by the hardware or firmware property rather than by the list of machines a change was measured on.

Could soft_faults be true for every G17 config, or derived from the firmware family so no per-chip field is needed? If a part is known to behave differently, a comment there saying why would cover it. If you make it the default, we can run the robustness2 and unmapped-read probes on our A18 Pro and M4 Pro.

Commit 6f7faee ("drm/asahi: g17: do not advertise soft faults")
stopped advertising DRM_ASAHI_FEATURE_SOFT_FAULTS on G17, after every
robustness2 rgba32 vertex_attribute_fetch case read non-zero data with
the bit set. Its explanation was wrong. Mesa pointed the out-of-bounds
vec3/vec4 vertex fetches at address 0 plus index times stride, and that
range is not unmapped on G17: once a client runs compute work, the first
64 KiB of its VM hold the execution context's null view
(CONTEXT_VIEWS[0], the render context presented at its fixed low
address, as macOS presents it), and userspace maps the other context
views up to 0x74000. Mesa no longer redirects robust fetches there on
G17 (the Mesa change "asahi: explicitly bound robust native vector
vertex fetches", 4115628b637f in aurora-wip).

The G17 firmware takes no fault_control, but its own fault mode gives
soft faults. Measured on the M4 Pro (T6040, firmware 25G83) with the bit
clear and nothing else changed:
- shader loads from unmapped client addresses return zero, whether the
  missing translation is at the leaf, at level 1 or at the root;
- shader stores to unmapped or read-only pages, and atomics on
  read-only pages, are dropped;
- none of these reports a fault or causes a recovery.

This is a property of the firmware family, not of the SoC: the driver
gives every G17 queue the same fault setting (QueueConfig::unk_66 = 1,
the word the M5 firmware names soft_fault_enabled). Advertise soft
faults on every GPU the G17 backend drives, with fault_control at its
0xb default as on the other generations. Say in the driver and in the
uAPI that the context views are mapped memory.

With the bit set on the M4 Pro, unmapped addresses read zero, stores
and atomics to them are dropped without a fault, and all 98,776
dEQP-VK.robustness.* cases give the same results as without it (47,933
pass, 50,843 not supported, 0 fail), with no GPU recovery. The other
G17 SoCs (T6041, T8140, T8142, T6050) have not been measured.

Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
Assisted-by: LLM
@jgoyvaerts
jgoyvaerts force-pushed the m4pro/g17-soft-faults branch from d395290 to 50c9683 Compare November 19, 2026 14:51
@jgoyvaerts jgoyvaerts changed the title drm/asahi: g17: advertise soft faults on the M4 Pro drm/asahi: g17: advertise soft faults Nov 19, 2026
@jgoyvaerts

Copy link
Copy Markdown
Contributor Author

Done in 50c9683. Config::soft_faults is gone from g17/mod.rs and from every hw/*.rs config. supports_soft_faults() (g17/mod.rs:2573) now advertises the bit for the whole G17 backend whenever fault_control is 0xb. Its comment gives the family-level reason: every G17 queue record already carries unk_66 = 1, the word the M5 firmware names soft_fault_enabled. I know of no part that behaves differently, so no exception.

Measured on the M4 Pro (T6040, fw 25G83) only. Title, commit message and body updated. Re-checked: arm64 build of drivers/gpu/drm/asahi/ (M5 backend on) with no new warnings, checkpatch clean, asahi KUnit 685 pass / 1 skip.

Yes please: robustness2 and the unmapped-read probes on your A18 Pro and M4 Pro would cover the parts we have not measured.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for 50c9683. Advertising soft faults for the whole G17 backend from the firmware's fault mode, with the reason in the comment, is what we were after. We will run robustness2 and the unmapped-read probes on our A18 Pro and M4 Pro and post them here.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Row from our A18 Pro (MacBook Neo, T8140, G17P), as offered: production 7.3.0-40 vs the same tree plus this PR (fault_control default), one-shot boot, same machine.

  • dEQP-VK robustness subset, 20,090 cases (all 419 vertex_attribute_fetch plus every fifth other robustness case), 4 jobs: identical per case on both kernels, 9862 Pass / 10228 NotSupported / 0 Fail (vertex_attribute_fetch 336 Pass / 83 NotSupported).
  • Smoke: dEQP api.smoke + info 3/3 and 600 frames of vkcube on both; 0 GPU firmware crashes, no GPU kernel lines during the CTS run.
  • Vulkan features identical between the two kernels (robustBufferAccess2, robustImageAccess2, nullDescriptor and pipelineRobustness true on both).
  • Boot health: Enforcing, 0 failed units, 0 AVC.

So no regression on G17P. An M4 Pro row is still queued.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Row from our M4 Pro (J616s, T6040, G17P profile): production fleet kernel vs the same tree plus this PR, one-shot boot.

  • dEQP-VK robustness subset (20,090 cases, all 419 vertex_attribute_fetch first): identical per case on both kernels, 9,862 Pass / 10,228 NotSupported / 0 Fail (vertex_attribute_fetch 336 Pass / 83 NotSupported).
  • Smoke 3/3, 0 GPU firmware crashes; s2idle 2/2 without resets.

Together with the A18 Pro row above: no regression on either G17 machine we have.

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.

2 participants