Skip to content

drm/asahi: g16: drain the engine before a render of another VM - #3353

Open
DjDeveloperr wants to merge 1 commit into
mainfrom
fix/g16-3201-cross-vm-render-drain
Open

DjDeveloperr wants to merge 1 commit into
mainfrom
fix/g16-3201-cross-vm-render-drain

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3201. Stacked on #3185.

What: on the g16 backend, a render now waits until every in-flight job of another VM has retired. This fixes linux#3201: GPU faults and fail-stops when several clients render at once.

  • Cause:
    • Every VM's render passes go through the one firmware TA/FS queue pair.
    • 69d102932933 ("pipeline warm cross-VM renders and eliminate hold[0] drains") lets a render of one VM be queued there behind another VM's render.
    • With several clients, the GPU then faults in the VM whose pass runs. Its VDM reads the kernel prefix in its pass slot and its own control stream, and its shader cores read from a null base, all at addresses that aren't mapped in the context the work runs in.
    • One client at a time never faults.
  • Change:
    • needs_engine_drain() and can_queue_behind() hold a render while any flight of another VM is in flight. This was the rule before 69d102932933.
    • Renders of one VM still pipeline.
    • Compute still runs beside other VMs' compute on its own workqueues (62e450e).
    • The cross-VM FS barrier (cross_vm_prev), which only served the overlap, is removed.
  • This replaces drm/asahi: g16: keep renders of a multisampling VM apart from other VMs #3180's MSAA-only rule (the multisampling VM mark, the per-flight flag and the fold checks):
  • Basis on macOS:
    • The g16 lane captured Metal running render.light with 2 and 4 processes on macOS 26B123, under the hypervisor on the J773g.
    • Every process gets its own TA queue and its own FS queue, each with its own job-list entry. All processes ring the same doorbell, and the firmware chooses among the queues.
    • g16 puts every process on one queue pair, so it has to drain before another VM's render.
    • Separate render queue pairs per VM, as the compute pipes already have, are the follow-up that brings the overlap back.

Tested: J773g (M4 Mac mini, macOS 26B123 firmware).

Risk: two-way door.

  • Scope: render admission on the g16 backend, so it reaches every GPU that backend runs: M4, and the M3 parts on the 26B123 protocol.
  • Cost: renders of different VMs no longer overlap. A compositor plus a game, or several 3D clients, serialize at each VM switch. render.light procs goes from 1.30× faster than Metal at d4 to 0.81×, until the per-VM queue follow-up lands.
  • Everything else stays as before: single-client rendering, compute beside other VMs' compute, and the existing render↔compute and InitBM drains.

Not yet:

69d102932933 ("drm/asahi: g16: pipeline warm cross-VM renders and
eliminate hold[0] drains") let a warm render of one VM queue on the
shared firmware TA/FS queue pair behind another VM's render. Every
VM's render passes go through that one queue pair.

With several clients at once this faults the GPU (linux#3201). On the
J773g, three deqp-vk processes over dEQP-VK.synchronization*multi_queue*
hit firmware recovery within seconds and fail-stop after a few
recoveries. The faults are in live VMs with work in flight: the VDM
reads the kernel prefix in its pass slot and the user control stream,
and the shader cores read from a null base, at addresses that are not
mapped in the context they run in. One client at a time never faults.

"keep renders of a multisampling VM apart from other VMs" covered the
multisampled case of the same thing: there, the two passes only had to
be published together, and only publishing one after the other retired
helped. Its MSAA-only rule does not cover linux#3201, whose passes are
single-sampled.

Use one rule instead: a render waits for every flight of another VM to
retire, as before 69d102932933. This replaces the multisampling VM mark,
its per-flight flag and the fold checks. Compute keeps running beside
another VM's compute on its own workqueue (62e450e), and renders of
one VM still pipeline. The cross-VM FS barrier that only served the
overlap goes away with it.

Closes: #3201
Signed-off-by: DjDeveloperr <[email protected]>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners November 27, 2026 05:31
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m3 Macs affected, from Merge risk (bot) blast:m4 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 456bce00: not ready yet

Check Detail
CI at head ok 3 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 456bce00
Conflicts no merge conflicts with main: merge it in (no force push)
PR text ok Risk: two-way · . - Scope: render admission on the g16 backend, so it reaches every GPU that backend runs: M4, and the M3 parts on the 26B123 protocol. - Cost: renders of different VMs no longer overlap. A compositor plus a game, or several 3D clients, serialize at each VM switch. render.light procs goes from 1.30× faster than Metal at d4 to 0.81×, until the per-VM queue follow-up lands. - Everything else stays as before: single-client rendering, compute beside other VMs' compute, and the existing render↔compute and InitBM drains.

Areas: area:gpu

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

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

J516s (MacBook Pro 16" M3 Pro, G15S) row at 456bce008249: PASS. multi_queue is clean, and cross-process renders cost about 2× (as with 8722b2e4). One-shot boot of the exact head on the default cmdline; build ID 7.3.0-m3-maint-g456bce008249. Mesa: aurora-wip 69179743d9ae, an isolated kit. The comparison is #3185 068d90ee2055, booted in the same hold.

  • CTS, multi_queue:
    • 900 sampled synchronization{,2}.op.multi_queue cases split across 3 deqp-vk processes: 732 Pass, 168 NotSupported, 0 Fail. At 068d90ee2055: 4 Fail.
    • The same 900 cases in one process: 732 Pass, 168 NotSupported, 0 Fail.
  • CTS, cross_instance: 300 cases, 100 Pass, 200 NotSupported.
  • CTS, sync subset: 671 cases in one process (basic, smoke, timeline_semaphore, op.single_queue, signal_order and implicit, for sync and sync2): 599 Pass, 72 NotSupported, 0 Fail.
  • gpubench-vk, cross-process rows (median µs per submission, 068d90ee2055 → this head):
    • render.light tri procs: d4 63.5 → 119.0, d16 45.2 → 136.5;
    • render.postfx 1440p msaa1 procs: d2 1,238 → 1,606, d4 1,286 → 2,564.
    • The earlier fix 8722b2e4 gave the same doubling on this Mac (render.light procs d4 63.2 → 119.5).
  • gpubench-vk, single-process rows, unchanged: render.light queue d4 51.8 → 51.4; render.postfx queue d1 1,726 → 1,707, d2 1,262 → 1,244.
  • Suspend: s2idle is refused at prepare, as on main (dwc3-apple … genpd_prepare returns -11), so no sleep was tested.
  • 0 GPU faults, 0 recoveries or hang kills, 0 "no completion-stamp progress" lines, 0 failed units, and no new kernel errors beyond this Mac's per-boot MTP HID line.
  • Clean reboot to stock, verified.

@erikwb

erikwb commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

J713 (MacBook Air 13" M4, G16G) row with 456bce008249: PASS. This PR also fixes a second symptom of the cross-VM render overlap: wrong images with no GPU fault when two graphics CTS processes run at once. #3185 on its own does not.

Symptom on main: two deqp-vk processes that both render. Random dEQP-VK.binding_model.shader_access.* and mutable_descriptor.* cases fail with Image verification failed. In a failing result, cells of the 2x2 grid have another cell's colour, a striped pattern, or are black, even when the case reads its descriptors in the vertex stage only. The same cases pass in one process. There's no GPU fault, recovery or kernel log line. A likely reason it doesn't fault: both processes lay out their GPU VA space the same way, so a pass that runs in the other VM's context reads mapped memory.

Kernels: three one-shot boots on the default cmdline, with this Mac's kernel config. The base is #3273 7f21093a0d31 (on #2673) + #3269 3b32d06f7ae5 + #3180 9c3c459d84f0, so the J713's external displays work. Its drivers/gpu/drm/asahi/g16 is identical to main 32a55ec3e9bb.

Borealis at aurora-wip b1e8ef5b4a9, the same build on all three. Every run uses 2 deqp-vk processes, each on its own share of the list, unless it says 1.

Run main #3185 this PR
2,894 shader_access.*.vertex.* cases, 1 process 0 fail 0 fail 0 fail
the same, 2 processes, 3 passes 65 / 77 / 64 58 / 62 / 68 0 / 0 / 0
2,894 shader_access.*.fragment.* cases 40 65 0
shader_access.* + mutable_descriptor.*, 100,722 cases (94,806 supported), 3 passes 575 / 751 / 756 733 / 744 / 614 0 / 0 / 0
api.image_clearing.*, every 4th case (11,409), MESA_SHADER_CACHE_DISABLE=true 6 1 0
1,345 shader_access.*.compute.* cases 0 0 0
  • Failing cases on main: 1,936 distinct over the 3 full passes: 896 mutable_descriptor, 324 vertex, 306 fragment, 287 vertex_fragment, 17 geometry, 106 others. Which cases fail changes every pass.
  • Every arm: 0 GPU faults or recoveries, 0 failed units. All three displays stayed up and the compositor stayed idle.

What sets it off, on the Mac's default kernel (main as of 2026-11-27 + display and power PRs) with the same Mesa:

  • A vertex-case process beside a compute-only deqp-vk process: 0 fail on both sides (2,894 + 3,900 cases).
  • A vertex-case process beside a fragment-case process: 52 and 42 fail. So it takes two VMs rendering at once.
  • ASAHI_MESA_DEBUG=nosoft (no soft-fault use in Mesa): still 48 fail. Soft faults aren't the cause.

Also: main f0b72363b06d with this PR merged, without the display PRs: 4 full passes of the 100,722-case list with 0 fail. Main f0b72363b06d alone gave 45–59 fails per vertex-subset pass on the same Mac.

The same parallel-only pattern on G15S (aurora-silicon/mesa#1152, blits with four processes) may have this cause too. Not tested here.

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

Superseded 12-01: not a hold under the merge bar (no shown failure). Final review deferred until #3185 lands; follow-ups: retarget, main CI (J713 PASS on file)

Verdict: HOLD at 456bce00

Blockers:

  1. Targets open non-main base branch fix/g16-m4-no-ta-wave (#3185 is still OPEN); full main CI has not run.

Checked:

  • Verified #3185 is still OPEN and base ref is fix/g16-m4-no-ta-wave (note J713 M4 PASS row is recorded at 456bce00).
  • Deferred final approval until #3185 lands and this PR is retargeted onto main with green CI.
Evidence
  • Base ref: fix/g16-m4-no-ta-wave (#3185 state: OPEN).

@github-actions github-actions Bot removed the ci-failing A check failed at the PR head (bot) label Nov 28, 2026
Base automatically changed from fix/g16-m4-no-ta-wave to main November 29, 2026 02:19
@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Nov 29, 2026

This branch has not been deployed

No deployments
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:m3 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) merge-conflict Conflicts with the base branch (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

drm/asahi g16: dEQP-VK.synchronization*multi_queue* faults the GPU and fail-stops it on J773g (main 61c7b88a)

2 participants