Re: [PATCH 0/6] rust: iommu: add a paging domain abstraction

From: Jason Gunthorpe

Date: Wed Nov 18 2026 - 16:06:52 EST


On Wed, Nov 18, 2026 at 02:41:32PM -0500, Nicolas Dufresne wrote:
> Jason,
>
> Le mercredi 18 novembre 2026 à 15:35 -0400, Jason Gunthorpe a écrit :
> > > No, not OK :/ We want to use GEM shmem, which calls into the DMA API internally
> > > through drm_gem_shmem_get_pages_sgt() -> dma_map_sgtable().
> >
> > You cannot continue to use DMA API once you start touching a paging
> > domain directly. It is why driver_managed exist.
>
> You are building a strong argument around something that is not what we intent
> this binding to be used for. If you had cared about the context you'd know we
> don't want to touch paging from userspace in this type of drivers.

Go re-read Daniel's answer and perhaps you can understand my confusion:

https://lore.kernel.org/all/3EB4C2ED-B699-4532-A562-68B78F6E29C6@xxxxxxxxxxxxx/

If you want to

"We plan to alloc a paging domain when a video encoder session is created. Then
we call iommu_attach_device() before a job runs"

You cannot use the DMA API.

You absolutely CANNOT attach a brand new driver controlled domain, use
the DMA API to populate it, and then detach it.

Then we have the issue that the rust bindings expose iommu_map, which
cannot even be used on any non-coherent arch due to lack of cache
flushing.

Further, from a Rust binding perspective all these unsafe things I
talked about have to be blocked by the Rust compiler:
1) You cannot attach a domain to a driver_managed_dma=false device
2) You cannot call DMA API functions on a driver_managed_dma=true device
3) I object to exposing iommu_get_domain_for_dev()/etc to Rust
due to how unsafe it is, but if you were to do it then the
returned pointer must never be used with attach or iommu_map/unmap
functions.
4) Since there is no cache flushing a non-coherent arch must never be
allowed to call iommu_map(), since it is unsafe to create memory
incoherence.

Thus, what exactly is the plan here? Do you see my concern?

Jason