[RFT 0/5] drm/msm: DMABUF_DEBUG fixes

From: Rob Clark

Date: Tue Oct 06 2026 - 09:11:02 EST


With DMABUF_DEBUG=y, the page information is stripped from the sgt that
we get for an externally allocated buffer that is dma-buf imported (as
opposed to an exported GEM buffer that is re-imported). This is a bit
unfortunate, since we need that information for mapping the buffer in
both paths:

1. Userspace GPU pgtables (TTBR0), where we use io_pgtable directly.
Fortunately this we can fix ourselves easily.

2. Iommu managed pgtables (scanout, kernel GPU buffers (TTBR1)). In
normal usage that iommu subsystem envisions the dma-mapping and
iommu-mapping are combined. We can't really work around this but
we can stop trying to pretend to be a normal iommu user and just
go directly to the iommu_domain_ops.

This all depends on being dma_map_direct() for the dma_map_sgtable()
to work. This should be the case on modern things that use arm-smmu.
It's less clear when it comes to older pre-arm-smmu hw. It's possible
that this series causes those things to catch fire. If so, look to
commit 0e764a01015d ("iommu/arm-smmu: Allow client devices to select
direct mapping") for inspiration.

Rob Clark (5):
drm/msm: Cleanup if pages_to_sg() fails
drm/msm/gem: dma_map/unmap_sgtable()
drm/msm: Extract out map/unmap helpers
drm/msm: Convert iommu map/unmap to helpers
drm/msm: Convert map helper to use dma-address

drivers/gpu/drm/msm/msm_gem.c | 57 ++++++----
drivers/gpu/drm/msm/msm_iommu.c | 182 ++++++++++++++++++++------------
2 files changed, 153 insertions(+), 86 deletions(-)

--
2.55.0