Skip to content

drm/asahi: mmu: translate an IOVA under the VM reservation alone - #1860

Merged
DjDeveloperr merged 1 commit into
aurora-silicon:integration/aurorafrom
sithglan:thomas/asahi-translate-iova-lock
Nov 14, 2026
Merged

DjDeveloperr merged 1 commit into
aurora-silicon:integration/aurorafrom
sithglan:thomas/asahi-translate-iova-lock

Conversation

@sithglan

Copy link
Copy Markdown
Contributor

On G18, every submission audits its mappings by translating each mapped page through Vm::translate_iova(). That function took the full GPUVM exec lock through lock_vm(), which also locks every external object of the VM (drm_gpuvm_exec_lock() → drm_gpuvm_prepare_objects()).

A page-table read of this DRM_GPUVM_RESV_PROTECTED VM needs only the VM's own reservation. That is GpuVm::exec_lock_vm(), which the map, unmap and bind paths already take. This change makes translate_iova() take it too.

The audits that call it are audit_render_mappings(), audit_application(), application_aliases() and audit_job_mappings().

Why it matters on the M6

During mpv playback under sway the VM holds about 60 external objects: imported dma-bufs and the compositor's buffers. Every translated page therefore locked and unlocked all of them. The G18 job worker spent about 7 ms per job, and the submitting ioctls waited behind it. This explains the extra frame drops of integration kernels compared with the j873 line on the same firmware and Mesa.

Testing

On the M6 (J873g, G18G B1, macOS 27.2 firmware), with mpv --vo=gpu --gpu-api=opengl playing a 4K60 H.264 clip for 20 s under sway, using aurora-silicon/mesa aurora-wip:

before after
G18 job worker per job 6.9 ms 1.9 ms
submit wait mostly 3–10 ms mostly 1–3 ms
dropped frames / 20 s 889 294–348

The picture is intact (checked by screenshot), and dmesg shows no new GPU or GPUVM messages.

The "after" drop counts come from three runs on a normal (non-tracing) integration kernel with this commit; the timings come from a tracing build.

With the same firmware and Mesa, the j873 line drops 242–271 frames. The remaining drops are shared with it, mainly the per-page audits themselves, so they are a separate problem.

Vm::translate_iova() took the GPUVM exec lock through lock_vm(), which
locks every external object of the VM (drm_gpuvm_exec_lock() ->
drm_gpuvm_prepare_objects()). Reading the page tables of this
DRM_GPUVM_RESV_PROTECTED VM needs only the VM's own reservation, which
GpuVm::exec_lock_vm() takes; the VA update paths already use it for the
same reason.

On G18 every submission audits its mappings (audit_render_mappings(),
audit_application(), application_aliases(), audit_job_mappings()) by
translating each mapped page. With a few dozen external objects in the
VM (imported dma-bufs and the compositor's buffers) that was some
800,000 reservation lock/unlock pairs a second during video playback,
and the job worker spent about 7 ms per job, holding the submitting
ioctls in their ticket wait.

Take that lock in translate_iova().

On the J873g (M6, G18G) with mpv playing a 4K60 H.264 clip under sway:
the job worker's time per job goes from 6.9 ms to 1.9 ms, the submit
wait from mostly 3-10 ms to mostly 1-3 ms, and dropped frames over 20 s
from 889 to about 350.

Signed-off-by: Thomas Glanzmann <[email protected]>
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