Skip to content

rust: drm: gpuvm: lock a shared reservation once in exec_lock() - #1392

Merged
RyanTheTide merged 1 commit into
aurora-silicon:integration/aurorafrom
IronsideXXVI:gpuvm-ignore-duplicates
Nov 10, 2026
Merged

RyanTheTide merged 1 commit into
aurora-silicon:integration/aurorafrom
IronsideXXVI:gpuvm-ignore-duplicates

Conversation

@IronsideXXVI

Copy link
Copy Markdown
Contributor

What users see

On an M4 (T8132, G16) with a 7.3-base kernel, mpv's default hardware decoding (hwdec=auto-safe, VA-API zero-copy into the Vulkan output) shows a blank window for 1080p video and logs VK_ERROR_DEVICE_LOST. For each failure the kernel logs:

aurora-g16 ...gpu: [File N Queue 1]: IOCTL: submit failed! (submission ID: N err: EFAULT)

Only that client fails; the compositor keeps running. The reproducer needs VA-API to load under the aurora driver name (omacom/omarchy-pkgs#2375, or the per-process emulation below).

Cause

mpv re-imports the same decoder dma-buf every frame and closes the old handle. The closed GEM object keeps its mappings while jobs are in flight (deferred unmap), so the VM's external-object list holds two objects that share one dma_buf->resv. Every G16 SUBMIT reads its control streams under GpuVm::exec_lock(), which runs drm_gpuvm_exec_lock() with flags 0: the shared reservation is locked twice with one ticket, ww_mutex returns -EALREADY, and g16/gate.rs turns that into EFAULT. The commit message has the full chain.

Fix

Set DRM_EXEC_IGNORE_DUPLICATES in GpuVm::exec_lock_impl(), as the C users of drm_gpuvm_exec do (nouveau nouveau_job_submit(), panthor panthor_submit_ctx_init(), xe, msm, imagination). A shared reservation is then locked once; nothing else changes. One file, +8/−5.

Fixes: points at 52ef95b, which introduced the deferred unmap at handle close. If you would rather point it at the G16 backend commit, that is fine with me.

Reproducer

mkdir -p /tmp/va && ln -sf /usr/lib/dri/v4l2_request_drv_video.so /tmp/va/aurora_drv_video.so
ffmpeg -f lavfi -i testsrc2=size=1920x1080:rate=30 -t 5 -c:v libx264 -pix_fmt yuv420p h264-1080.mp4
LIBVA_DRIVERS_PATH=/tmp/va mpv --no-config --hwdec=auto-safe --start=1.5 --pause h264-1080.mp4

Before the fix: blank window, VK_ERROR_DEVICE_LOST in mpv -v, one submit failed! (... err: EFAULT) in dmesg. (I measured with the stock mpv.conf, which contains only hwdec=auto-safe; the command above should be equivalent.)

Before / after

J604 (T8132, G16). Per clip: 3 runs of seek to 1.5 s and pause, window grab compared with a software-decoded grab of the same frame. After the fix, also 3 play-from-start runs.

Clip Before After
1080p H.264 / HEVC / VP9 (generated) blank 3/3 each, one EFAULT per run picture equals software, hardware decode in every run, 0 errors
4K H.264 (generated) picture equals software, 0 errors same
1080p H.264 / HEVC / VP9 (Big Buck Bunny) not run picture equals software, hardware decode in every run, 0 errors

Tested / not tested

Tested on one machine only: J604 (MacBook Pro 14" M4), on the 7.3 base 6ff31cb plus the J604 board patches, with this change unmodified. Not tested: other GPU generations, the idle-VM restore path, 10-bit video, long playback, browsers, or a build of current integration/aurora (the patch applies there cleanly, and the file is unchanged since 6ff31cb).

Possibly related, not verified: omacom/linux-aurora#174 (same close + re-import pattern, different symptom).

On a MacBook Pro 14" M4 (J604, T8132, G16), mpv with zero-copy VA-API
into its Vulkan output (what hwdec=auto-safe picks once the VA driver
loads) shows a blank window for 1080p H.264, HEVC and VP9 video and
reports VK_ERROR_DEVICE_LOST. For each failure the kernel logs:

  aurora-g16 ...gpu: [File N Queue 1]: IOCTL: submit failed! (submission ID: N err: EFAULT)

The submit is refused during validation:

1. Mesa drops a BO by closing its handle. The close callback
   (AsahiObject::close() -> Vm::drop_mappings()) defers the unmap while
   the VM has accepted jobs in flight, so the closed GEM object keeps
   its GPUVAs and its vm_bo stays on the VM's external-object list.
2. mpv re-imports the same decoder dma-buf for every frame. With the
   old handle gone from the prime cache, drm_gem_prime_import_dev()
   creates a second GEM object for it, and both objects share
   dma_buf->resv.
3. Every G16 SUBMIT reads its control streams through Vm::read_user()
   (g16/gate.rs), which takes GpuVm::exec_lock(), i.e.
   drm_gpuvm_exec_lock() with flags 0. drm_gpuvm_prepare_objects()
   then locks the shared reservation a second time with the same
   ticket, ww_mutex returns -EALREADY, and without
   DRM_EXEC_IGNORE_DUPLICATES drm_exec returns that error.
4. The gate maps any read_user() error to EFAULT, so the submit fails
   and Mesa reports the device as lost for that client.

Whether it triggers depends on the VA layout: when the re-import is
bound at the old address, that bind removes the stale mapping first
(seen at 4K); at 1080p the re-import landed at a new address and the
next submit failed every time after a seek.

C users of drm_gpuvm_exec and drm_exec that can see shared reservations
set DRM_EXEC_IGNORE_DUPLICATES for this case, for example
drivers/gpu/drm/nouveau/nouveau_sched.c (the struct drm_gpuvm_exec in
nouveau_job_submit()) and drivers/gpu/drm/panthor/panthor_drv.c
(panthor_submit_ctx_init()); xe, msm and imagination do the same. Set
it in exec_lock_impl(): a reservation shared by two objects is then
locked and unlocked once, and nothing else changes. exec_lock_vm()
shares the initializer and locks only the VM reservation, so its
behaviour does not change. The idle-VM restore path
(mmu/residency.rs), which also takes the full exec lock, is covered as
well.

Before the Fixes: commit, drop_mappings() unmapped at handle close, so
two live objects on one reservation could not both be on the
external-object list.

Tested only on the J604 (T8132, G16), on the Aurora 7.3 base 6ff31cb
plus the J604 board patches, with this change unmodified: stock mpv
with the VA-API alias, generated and real 1080p H.264/HEVC/VP9 and 4K
H.264 clips, 3 seek+pause and 3 play-from-start runs each, hardware
decoding in every run, pictures equal to software decoding, no Vulkan
errors and no "submit failed" lines (before: blank picture and one
EFAULT per run for every 1080p clip). Not tested on other GPU
generations, and the idle-VM restore path was not exercised.

Fixes: 52ef95b ("drm/asahi: add the T8140 firmware interface")
Assisted-by: LLM
Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
IronsideXXVI added a commit to IronsideXXVI/omarchy-j604 that referenced this pull request Nov 9, 2026
Kernel patch 0164 ("rust: drm: gpuvm: lock a shared reservation once in
exec_lock") was sent to aurora-silicon/linux against integration/aurora
as #1392 (open, not merged). UPSTREAM.md: the open-upstream table, Wave
2 row #22, note (g) and the kernel plan.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
@RyanTheTide
RyanTheTide merged commit d555cbe into aurora-silicon:integration/aurora Nov 10, 2026
4 checks passed
IronsideXXVI added a commit to IronsideXXVI/omarchy-j604 that referenced this pull request Nov 10, 2026
… switches

kernel/: 236 patches, 1.731 plus 0232-0236 (1.732 and the installed 1.733):

- 0232, 0234: deep-sleep test switches, all off by default, to find what
  resets the machine during suspend-to-RAM. With the defaults nothing
  changes.
- 0233: the swap_pace lead cap of 0230 was computed in 32 bits and
  wrapped, so the lead was never learned on 1.730-1.732 and pacing used
  its fallback; no cadence was lost. On 1.733 the lead is learned again.
- 0235-0236: the T8132 SIO coprocessor window moves into the shared SoC
  file, in the form to send upstream; the compiled device tree and
  boot.bin are byte-identical.

STATUS.md also records: the Glassy bar re-measured on 1.731 (still 59
fps stock, 119 with xray); fullscreen 1080p60 video within its cadence
bound since 1.730, and 4K60 in Chromium limited by software decoding;
AV1 hardware decode bit-exact through VA-API; the browser hardware
decode state; an idle power breakdown on 1.732; deep sleep with the
system controller and display controllers ruled out and the reset coming
from outside the kernel.

UPSTREAM.md and README.md: aurora-silicon/linux#1392 merged on
2026-11-10 and is carried in omacom/linux-aurora#438; the items posted
on 2026-11-10; Aurora's base has moved about 600 commits and a rebase
is planned.

Device tree binary, boot.bin and m1n1 are unchanged. CREDITS.md
follows.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
IronsideXXVI added a commit to IronsideXXVI/omarchy-j604 that referenced this pull request Nov 10, 2026
The J604 series moves from aurora-silicon/linux integration/aurora
6ff31cbfa2 to a82a1ebda940 (7.3.0) and is numbered again from 0001:
227 patches. 19 patches left because the new base has them (the same
patch, the same content, or an upstream change that does the same on
the J604, among them aurora-silicon/linux#1392). Two new patches keep
the 1.736 behaviour of the MTP handoff and of the T8132 PMGR domain
policy. The PCIe test switch of 1.736 (0244) is dropped.

kernel/RENUMBER.md maps the 1.736 patch numbers to the new files.
STATUS.md: rebase notes, boot image with the 1.800 device tree, the
cause of the inactive cluster idle drop (0240-0241), per-build rows.
README.md, UPSTREAM.md and CREDITS.md follow the new series.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
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