Skip to content

drm/msm: Keep shared VM mappings until the last user is gone - #454

Closed
vlw wants to merge 1 commit into
msm8916-mainline:wip/msm8916/7.0from
vlw:msm-gem-shared-vm
Closed

vlw wants to merge 1 commit into
msm8916-mainline:wip/msm8916/7.0from
vlw:msm-gem-shared-vm

Conversation

@vlw

@vlw vlw commented Nov 15, 2026

Copy link
Copy Markdown

Adreno 2xx–5xx share one GPU VM between all processes. Closing one GEM handle unmapped buffers that other processes (the compositor) still used, which caused a flood of IOMMU faults and corrupted rendering. The mapping is now torn down after the last user, which also keeps the objects from leaking.

Tested on a Samsung Galaxy A3 (SM-A300F, MSM8916) running LineageOS 24. No IOMMU faults; the number of GEM objects stays around 1000 under use.

Per CONTRIBUTING.md this touches a shared upstream driver, so it is posted here for early review before going to the upstream lists.

GPUs without per-process pagetables (a2xx..a5xx) give every context
the same global VM. msm_gem_close() still tears down the VMAs of the
object in ctx->vm, which is that shared VM, whenever any handle to it
is closed.

A buffer shared between processes is then unmapped as soon as one of
them closes its handle. For example, a window buffer passed from an
application to the compositor as a dma-buf. The other process keeps
using the stale iova. On Adreno 306 running Android this shows up as
a flood of IOMMU faults and corrupted rendering.

Skip the teardown on handle close for the shared VM. Do it in
msm_gem_vma_put() instead, once vma_ref drops to zero, the same way
the KMS VM is handled. The teardown cannot simply be left to
msm_gem_free_object(): the VMA holds a reference on the object
through its drm_gpuvm_bo, so the object would never be freed.

Tested on MSM8916 (Adreno 306) with Android: no IOMMU faults, and the
number of GEM objects stays stable.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Vladimir Bely <vlwwwwww@gmail.com>
@vlw vlw closed this Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant