Skip to content

drm/asahi: g14_v27_2: use non-blocking Uat::try_bind() under Runtime.state - #3238

Merged
RyanTheTide merged 2 commits into
aurora-silicon:mainfrom
AxxzyWasTaken:pr/g14-v27-2-try-bind
Nov 29, 2026
Merged

RyanTheTide merged 2 commits into
aurora-silicon:mainfrom
AxxzyWasTaken:pr/g14-v27-2-try-bind

Conversation

@AxxzyWasTaken

@AxxzyWasTaken AxxzyWasTaken commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What: Fixes a permanent Runtime.state <-> Uat::bind() self-deadlock on the G14 firmware 27.2 backend whenever UAT context slots are exhausted (guaranteed with 2 concurrent VMs under asahi.robust_isolation=1, or 63 concurrent VMs normally):

  • Widen Uat::try_bind() in drivers/gpu/drm/asahi/mmu.rs to #[cfg(any(CONFIG_DRM_ASAHI_G15, CONFIG_DRM_ASAHI_G14_V27_2))] and move the is_no_peer() -ENOTSUPP guard into Uat::bind_inner() so bind() and try_bind() enforce identical checks.
  • Switch publish_compute() and publish_render() in drivers/gpu/drm/asahi/g14_v27_2.rs from blocking Uat::bind() to non-blocking Uat::try_bind() under Runtime.state, binding before QueueRender::prepare() so retries neither churn render-buffer/scene allocations nor confuse allocator -ENOSPC with UAT context-slot exhaustion.
  • Handle PublishError::BindBusy in Runtime::pump() without blocking under Runtime.state:
    • When state.running(), clear waiting_bind, leave the packet at state.pending[0] without mutating slots/counters/rings, and return so Runtime::service() can retire in-flight work, release VmBind, and re-pump.
    • When !state.running(), arm bounded delayed retries via Notify::retry() capped at COMMAND_TIMEOUT_MS; on expiry, pop the front packet, call release_guard(), and complete via fail_packet(ENOSPC) without poisoning VmStatus or the healthy runtime.
    • Clear waiting_bind on publication, front withdraw() (waking service for successors or notifying idle), fail_all(), and across sleep_prepare()/sleep_complete().
  • Add standalone Rust host test harness tools/asahi/g14-v27-2-try-bind-tests.py registered in tools/asahi/run-host-tests.py.

Closes: #3068

Tested: tools/asahi/run-host-tests.py --only g14-v27-2-try-bind: 10/10 passed (10 positive scenarios including multi-threaded robust_isolation=1 contention, same-VM pipelining, render ENOSPC before queue.prepare(), idle external-hold recovery/timeout, withdraw(), sleep_prepare()/sleep_complete(), stop(), plus 9/9 negative-control mutations killed).

  • tools/asahi/run-host-tests.py --only asahi-m4: 1/1 passed (test-mmu-retention.py).
  • Cross-compiled ARCH=arm64 LLVM=1 drivers/gpu/drm/asahi/aurora.o cleanly with 0 warnings in touched files across 4 configs (G15=y/G14_V27_2=y with APPLE_SOC_SLEEP=y and =n, G15=y/G14_V27_2=n, and G15=n/G14_V27_2=n).
  • git diff --check clean; scripts/checkpatch.pl --strict --git HEAD~1..HEAD reports 0 errors / 0 code warnings.

Not yet: On-hardware M2 (G14 firmware 27.2) boot and asahi.robust_isolation=1 multi-client stress run.

Risk: two-way · M2 family Macs using G14 firmware 27.2 (CONFIG_DRM_ASAHI_G14_V27_2)

@AxxzyWasTaken
AxxzyWasTaken requested review from a team and DjDeveloperr as code owners November 26, 2026 11:10
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:m2 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-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Merge readiness at 948fee2d: not ready yet

Check Detail
CI at head running running: KUnit macsmc, KUnit clpc, KUnit apple-spmi-nvmem, KUnit trusted-keys
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head no no line with the head SHA 948fee2d, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · M2 family Macs using G14 firmware 27.2 (CONFIGDRMASAHIG14V272)

Areas: area:gpu

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

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 26, 2026
…state

publish_compute() and publish_render() run with Runtime.state locked and
previously called blocking Uat::bind(). When all UAT user context slots
are occupied (for example with asahi.robust_isolation=1 while another VM
has a job in flight), Uat::bind() sleeps inside SlotAllocator::get() while
holding Runtime.state. Runtime::service() must acquire Runtime.state to
retire in-flight work and drop its VmBind guards, causing a permanent
self-deadlock.

Widen Uat::try_bind() to CONFIG_DRM_ASAHI_G14_V27_2 and move the
is_no_peer() guard into bind_inner() so bind() and try_bind() enforce the
same checks. Switch publish_compute() and publish_render() to try_bind()
before preparing render scenes or mutating pool/queue state, returning a
distinct PublishError::BindBusy on ENOSPC so allocator ENOSPC from
QueueRender::prepare() is not misclassified as a context-slot wait.

In Runtime::pump(), handle BindBusy without blocking under Runtime.state:
- When work is in flight (state.running()), leave the front packet queued
  and return so Runtime::service() can retire work, drop its VmBind, and
  re-pump.
- When idle (!state.running()), arm a bounded delayed retry via
  Notify::retry() capped at COMMAND_TIMEOUT_MS. If the slot remains
  externally held past the deadline, pop the front packet, release its
  guard, and complete it with fail_packet(ENOSPC) so neither the client's
  VmStatus nor the healthy runtime is poisoned.
- Clear waiting_bind on publication, front withdrawal (waking service for
  a successor or notifying idle when empty), fail_all(), and across
  sleep_prepare()/sleep_complete().

Add a standalone host test harness under tools/asahi/ covering concurrent
robust_isolation=1 retirement without deadlock, idle external slot hold
recovery and timeout, withdraw/sleep/stop interactions, and negative
control mutations, and register it in tools/asahi/run-host-tests.py.

Closes: aurora-silicon#3068
Signed-off-by: AxxzyWasTaken <[email protected]>

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

Publication no longer waits for a UAT slot while holding Runtime.state; render checks the slot before preparing its scene. Slot pressure has a distinct retry path, and the exact-head standalone harness passed all 10 cases here. Apple build, host tests and KUnit are green. Keep the PR held for the requested M2 firmware-27.2 multi-client run.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge-train status at d1c27c87: not mergeable yet, because Tested: and Not yet: are empty. Before review and merge it needs a row at this head on an M2 with G14 firmware 27.2: a J473 or J413 on the 27.2 stub, GPU workload plus suspend/resume, 0 GPU faults or recoveries. We can run it on our J473 or J413 if you'd like; just say so here. I'll do the adversarial review against the rowed head.

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor Author

Updated the PR body so Tested: and Not yet: start inline on their label lines (no commit change, head remains d1c27c87f408).

Yes please — I do not have an M2 machine locally, so running the exact-head G14 firmware 27.2 row on your J473 or J413 would be very helpful. Thanks!

@RyanTheTide

Copy link
Copy Markdown
Contributor

Tested d1c27c8 on J473 (M2 mini, G14G B0, fw 27.2): PASS, as part of a batch boot.

Kernel: 7.3.0-aurora-ibg14b = main d8c60437 + no-ff merges of #3250 c12e5891, #3238 d1c27c87, #3230 f6a5d7a1 and #3214 f1e87917 (each head is an ancestor; the only conflict was the tools/asahi/run-host-tests.py registry). Signed combo27 config, combo27 J473 Stage 2, saved production options. Host tests on the composed tree: fw-window-gc 11/11, try-bind 10/10, legacy-wq-prepub-abort 10/10, dcp-hdmi-sleep-unplug 13/13.

Row (one guarded one-shot, restored to fleet89 after):

  • Desktop row: GNOME session, vkcube, glxgears, WebGL; all sinks muted.
  • 3 short s2idle cycles (rtc, 15 s) with HDMI + USB-C displays attached, plus 1 after load: 4/4 rc=0, triangle/vkcube pass after each, HDMI DCP powered back with HPD connected each time.
  • Heavy compute 3 rounds (gpubench-vk light, heavy, alu and bw at depths 1..64): 12/12 ok, klog_bad 0.
  • GL render.postfx 8/8 loops, then 10 fresh Vulkan clients 10/10. GNOME shell PID unchanged for the whole boot.
  • 0 GPU faults, timeouts, recoveries or firmware crashes. Enforcing, 0 failed units.
  • The one red check is AVC=2, both from restorecon writing the harness's own Firefox log file (setfiles_t on var_lib_t). That is fixture noise, not this kernel.

Evidence: traces/gpu/20261129-ib-g14batch/20261129-005245-j473-ibg14b-a.

For this PR: no UAT context slot unavailable lines, and the multi-client phase (GL + 10 Vulkan clients plus GNOME) ran clean. This boot used the default options, so asahi.robust_isolation=1 contention wasn't exercised. Note that #3249 conflicts with this PR in g14_v27_2.rs (waiting_bind vs waiting_ring), so one of them needs a rebase after the other merges.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Tested d1c27c8 on J316s. G13 row: tested on J316s (M1 Pro, G13S C0) at this head, PASS. Kernel 7.3.0-aurora-ibg13b = main d95848ae + no-ff merges of #3250 c12e5891, #3238 d1c27c87 and #3230 ac06a535 (each head an ancestor).

  • One GRUB one-shot on the fleet89 saved default.
  • Hardware GL ES smoke (surfaceless, Apple M1 Pro (G13S C0)) and Vulkan device enumeration pass.
  • gpubench-vk compute.heavy and compute.light, 3 rounds each: all ok.
  • 2 s2idle cycles (rtc1, 15 s): rc=0, with GL, Vulkan and compute passing after each.
  • 0 GPU timeouts, faults, recoveries or firmware crashes. Enforcing, AVC 0, 0 failed units.
  • The production kernel gives the identical result in the same check (baseline-fleet89-j316s.txt).
  • Restored: custom.cfg byte-identical, kernel removed.

The J473 G14 27.2 row on the same kernel also passes (heavy 12/12, GL 8/8, Vulkan 10/10, s2idle 4/4). Evidence: traces/gpu/20261129-ib-g13batch/ (README).

@RyanTheTide

Copy link
Copy Markdown
Contributor

code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at d1c27c87. App approved. Rows at this head: J473 (G14, fw 27.2) + J316s (G13) PASS. Merges in 1 h under the 6-point rule, in order #3214 -> #3250 -> #3238 -> #3230, unless you object.

@github-actions github-actions Bot removed the needs-hw-row No hardware row at the PR head (bot) label Nov 28, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging under the 6-point rule (Ryan 09:29, permanent), at d1c27c87. (1) The review App approved at this head. (2) Full CI is green. (3/4) Rows: J473+J316s. (5) There's no blocking review. (6) Dj was pinged here 65 min ago with no objection. Revert: git revert -m 1 <merge>.

Resolve the run-host-tests.py list: keep both g14-v27-2 entries (fw-window-gc from main, try-bind from this branch).

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Forward-merged main (ee36fbdc, which now has #3250) into this branch at 948fee2d (normal push, your commits untouched). The only conflict was the run-host-tests.py list, where both sides added a g14-v27-2 entry; both are kept. g14-v27-2-try-bind-tests (10/10) and g14-v27-2-fw-window-gc-tests pass on the merged tree. It merges once CI and the App re-approval at 948fee2d are in; the J473 + J316s rows carry over (no code change).

@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 948fee2 after hosted CI and integration validation.

Checked: the two parents are the previously approved head and current main. Git remerge diff shows the sole manual resolution is the host-test registry, which retains both the firmware-window and try-bind suites with their mutation lists. The try-bind test file is identical to the reviewed head. The GPU source changes relative to that head include the merged main changes, with no manual resolution in those files. The merge-train host tests passed. Keep the existing J473 and J316s evidence tied to its tested build.

@github-actions github-actions Bot added the needs-hw-row No hardware row at the PR head (bot) label Nov 28, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

Merging under the 6-point rule (Ryan 09:29, permanent), at 948fee2d. (1) The review App approved at this head. (2) Full CI is green. (3/4) Rows: J473+J316s;fwd-merge-only. (5) There's no blocking review. (6) Dj was pinged here 611 min ago with no objection. Revert: git revert -m 1 <merge>.

@RyanTheTide
RyanTheTide merged commit 8ebb0f7 into aurora-silicon:main Nov 29, 2026
20 of 21 checks passed
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:m2 Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (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: g14_v27_2: blocking Uat::bind() under Runtime.state mutex self-deadlocks

2 participants