Skip to content

drm/asahi: mmu: publish a binding without the VM reservation - #2799

Merged
RyanTheTide merged 2 commits into
mainfrom
isw/g16-mark-published-resv-v2
Nov 29, 2026
Merged

RyanTheTide merged 2 commits into
mainfrom
isw/g16-mark-published-resv-v2

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What: G16: Vm::mark_binding_published() no longer takes the VM reservation. It runs inside the job's signalling section, where taking a reservation breaks the dma-fence rules (#1563). The VM keeps its own handle to the UAT. Fixes #1563.
Tested: J713 (M4 Air, G16G) at 24f98b9 in the combined one-shot kernel 7.3.0-aurora-dsw2: gpubench-vk submit/compute/render at depths 1 and 4 rc 0, 30 fresh short-lived Vulkan clients 0 failed, no GPU fault/timeout/recovery lines, 0 WARN/BUG, s2idle rc 0, 0 failed units. Shared mmu.rs regression on three more GPU families, same kernel and tests, all clean: M1 Pro (G13S), J473 (G14G), J616s (M4 Pro, G16S B1: gpubench submit/compute/render rc 0, 30 fresh Vulkan clients 0 failed, 0 GPU fault/timeout lines, s2idle rc 0).
Risk: two-way · all Macs on drm/asahi (shared mmu.rs; the change is G16's publish path)
Not yet: a lockdep-enabled run that triggers the old splat (the fleet config has no lockdep)

Evidence
Original description

Replaces #2341 (same changes, commit trailers fixed).

Fixes #1563

G16 publishes a job inside a SignallingGuard section: Shared::submit() from run_job, and Shared::run_poll(). Publishing calls Vm::mark_binding_published(), which took the VM's shared reservation through GpuVm::lock_inner() (dma_resv_lock) only to clone the UAT handle out of VmInner:

run_job -> SchedJob::run -> Job::start -> Shared::submit                  (SignallingGuard)
  -> Firmware::publish -> publish_prefix -> publish_prefix_into
    -> Vm::mark_binding_published -> GpuVm::lock_inner -> dma_resv_lock   (VM reservation)

That breaks the dma-fence signalling rules, because a holder of the reservation may wait for the fence this path signals, and dma_resv_lockdep() primes lockdep with that order. g16/job.rs already says work inside the guard must not take reservations.

The UAT handle never changes after the VM is created, so Vm now keeps a second Arc<UatInner> next to the one in VmInner, and mark_binding_published() uses it. The binding mutex and the UAT lock it takes next are driver locks and are unchanged. No other path under g16/ calls lock_inner() or exec_lock*(). The M3 caller (m3_runtime.rs) gets the same change and does not need the reservation either. The VM state is selected exactly as before, so every chip with this backend gets the fix.

Evidence

  • Base integration/aurora 0abc2f3. arm64 LLVM=1 build of drivers/soc/apple/, drivers/gpu/drm/asahi/ and drivers/media/platform/apple/avd/ with the fleet config (DRM_ASAHI=m with G15/G16/G18/M5, APPLE_AOP=m; rustc 1.97.1, bindgen 0.73.2): rc 0, and no error or warning in the changed file.
  • checkpatch.pl --strict: 0 errors, 0 warnings.

Not run on hardware (no G16 machine here). A CONFIG_PROVE_LOCKING boot on an M4 with one published job is the hardware check: the circular-locking report described in #1563 should not appear.

G16 publishes a job from inside a SignallingGuard section
(Shared::submit() from run_job, and Shared::run_poll()). Publishing
calls Vm::mark_binding_published() on the job's VM, which took the VM's
shared reservation through GpuVm::lock_inner() only to clone the UAT
handle out of VmInner:

  run_job -> SchedJob::run -> Job::start -> Shared::submit (signalling)
    -> Firmware::publish -> publish_prefix -> publish_prefix_into
      -> Vm::mark_binding_published -> GpuVm::lock_inner -> dma_resv_lock

dma-fence signalling rules forbid that: code holding a reservation may
wait for fences, so a fence-signalling path that takes one can deadlock
against it, and dma_resv_lockdep() primes lockdep with exactly that
order. The comment in g16/job.rs already says work inside the guard must
not take reservations.

The UAT handle never changes after the VM is created. Keep a second
reference to it in Vm, next to the one in VmInner, and use it in
mark_binding_published(). The binding mutex and the UAT lock it takes
next are driver locks and stay as they are. The M3 caller gets the same
change and does not need the reservation either.

Fixes: 24f6733 ("drm/asahi: add the T8132 G16 firmware backend")
Link: #1563
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Review at 24f98b9 (non-author, draft). No blocker found; ready once a lockdep boot row is in.

  • Merges cleanly onto integration/aurora 6748d83. One commit, human sign-off only. drm/asahi: mmu: publish a binding without the VM reservation #2341 is closed.
  • Vm::new() receives the Arc<UatInner>, clones it into VmInner and now keeps the original in Vm. The handle in VmInner is never reassigned (every use is a read or a clone), so the copy in Vm cannot go stale.
  • mark_binding_published() used the reservation only to clone that handle. The data it then checks and writes (owned_user_roots, the TTB slot, binding_published) is under the binding mutex and the UAT lock, taken in the same order as before, so dropping the reservation removes no protection.
  • Lock order: the remaining paths that take the reservation take it outermost (lock_inner() then the binding mutex), so reservation -> binding -> UAT is still the only order and the signalling path now enters at the binding mutex.
  • Both callers are covered by the one change: g16/engine.rs (inside the signalling section) and m3/m3_runtime.rs.
  • No extra reference cycle: Vm holding the UAT handle is the same ownership VmInner already had.

Small points, not blocking:

  • The binding mutex and the UAT lock are now the locks the signalling section depends on. If any holder of either one allocates with GFP_KERNEL or waits on a fence, lockdep will report that next. The row should say explicitly that no report at all appears, not only that the one from the issue is gone.
  • Rows still open: a CONFIG_PROVE_LOCKING boot with at least one rendered frame on an M4 (G16 path) and on an M3 (the m3_runtime caller), plus a short GL/Vulkan smoke run on each to show mark_binding_published() still accepts the binding.

Assisted-by: LLM (Claude:Opus 5.5)

@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 12ed5b3 after the lockdep and required hosted checks.

Checked: Vm and VmInner receive references to the same UAT at construction. Publication now uses the VM's retained reference directly. The binding-to-UAT acquisition order, live slot/root validation and publication update are preserved, with no VM reservation acquisition in this method. No DT change. The J713 submit and fresh-client row covers ordinary operation, with M1 Pro and J473 shared-MMU smoke. Please keep a lockdep-enabled G16 submit row to validate the signalling section and its remaining locks.

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:all 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 28, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at 12ed5b3f. App approved; rows J713 G16G + M1 Pro G13S + J473 G14G (combined dsw2 kernel, files byte-identical). Merges 1 h from now under the 6-point rule once hosted CI is green, unless you object.

@github-actions

Copy link
Copy Markdown

Merge readiness at 12ed5b3f: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text, pr-text / pr-text
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 12ed5b3f, a Mac and a result in the PR body or a comment
Conflicts ok none
PR text ok Risk: two-way · all Macs on drm/asahi (shared mmu.rs; the change is G16's publish path)

Areas: area:gpu

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

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

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

@RyanTheTide
RyanTheTide merged commit db486b2 into main Nov 29, 2026
21 of 27 checks passed
@RyanTheTide
RyanTheTide deleted the isw/g16-mark-published-resv-v2 branch November 29, 2026 00:17
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:all 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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

g16: mark_binding_published() takes the VM reservation inside the SignallingGuard section

1 participant