Skip to content

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

Closed
RyanTheTide wants to merge 1 commit into
integration/aurorafrom
isw/g16-mark-published-resv
Closed

RyanTheTide wants to merge 1 commit into
integration/aurorafrom
isw/g16-mark-published-resv

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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. The only warnings are about the Co-Authored-By trailer form.

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.

Assisted-by: LLM (Claude:Opus 5.5)

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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Blockers: 1.

  1. Commit c07143d carries Co-Authored-By: Claude Opus 5.5 <[email protected]>. Please re-commit with only the human Signed-off-by. The PR body's Assisted-by line covers the help.

The change itself is right. uat_inner is set once when the Vm is built (mmu.rs:2544, :2572) and never reassigned, so the second Arc (drivers/gpu/drm/asahi/mmu.rs:1238) always matches VmInner::uat_inner. mark_binding_published() (:3135-3147) now takes only binding and the UAT lock, which it already took after the reservation, so no new lock order is added inside the signalling section. The extra reference only keeps UatInner (device lifetime) alive for as long as the Vm. Neither caller, g16/engine.rs:1041 or m3/m3_runtime.rs:500, needs anything else from VmInner there.

HW row: the change has never run. It needs a CONFIG_PROVE_LOCKING boot on this head on the G16 backend (M4 Air, J713), with a desktop session and a GPU benchmark long enough to publish jobs: 0 lockdep reports (in particular none naming dma_resv_lock from mark_binding_published) and 0 GPU faults. It also needs a boot on an M3 Air (J613/J615) on the extended firmware profile, the m3_runtime.rs:500 caller. 0 AVC, 0 failed units and no new kernel errors on both.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Replaced by #2799: the same changes with the commit trailers fixed, on the current integration/aurora.

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.

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

1 participant