Skip to content

drm/asahi: Clean up deferred BOs when dropping a VM#548

Open
DesktopECHO wants to merge 1 commit into
AsahiLinux:asahifrom
DesktopECHO:ika/drm-asahi-vm-deferred-cleanup
Open

drm/asahi: Clean up deferred BOs when dropping a VM#548
DesktopECHO wants to merge 1 commit into
AsahiLinux:asahifrom
DesktopECHO:ika/drm-asahi-vm-deferred-cleanup

Conversation

@DesktopECHO

@DesktopECHO DesktopECHO commented Jul 21, 2026

Copy link
Copy Markdown

Since DRM GPUVM immediate mode was enabled, unmapping a GPU VA can defer
drm_gpuvm_bo destruction until drm_gpuvm_bo_deferred_cleanup() is called.
The GEM bind and unbind paths drain that list, but Vm::drop() unmaps the
remaining user ranges without doing so.

Drain the deferred list after both teardown unmaps. Otherwise a deferred
drm_gpuvm_bo retains the imported GEM and dma-buf after its DRM file is
closed, leaving its backing pages pinned.

Fixes: 2aeee2d ("drm/asahi: Switch gpuvm to DRM_GPUVM_IMMEDIATE_MODE")

Validation:

  • Pre-patch: A GPU-accelerated VM would consume all system RAM while playing
    games until the system crashed.
  • Post-patch: The GPU-accelerated VM no longer consumes all host memory. Memory
    is returned, and host crashes no longer occur.

Since immediate mode was enabled, unmapping a GPU VA can defer
drm_gpuvm_bo destruction until drm_gpuvm_bo_deferred_cleanup() is called.
The GEM bind and unbind paths drain that list, but Vm::drop() unmaps the
remaining user ranges without doing so.

Drain the deferred list after both teardown unmaps. Otherwise a deferred
drm_gpuvm_bo retains the imported GEM and dma-buf after its DRM file is
closed, leaving its backing pages pinned.

Fixes: 2aeee2d ("drm/asahi: Switch gpuvm to DRM_GPUVM_IMMEDIATE_MODE")
Signed-off-by: DesktopECHO <33142753+DesktopECHO@users.noreply.github.com>
@DesktopECHO
DesktopECHO marked this pull request as ready for review July 21, 2026 19:10
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.

1 participant