Re: [PATCH 0/6] rust: iommu: add a paging domain abstraction
From: Jason Gunthorpe
Date: Thu Nov 19 2026 - 09:56:52 EST
On Thu, Nov 19, 2026 at 01:03:52PM +0000, Robin Murphy wrote:
> On 18/11/2026 9:06 pm, Jason Gunthorpe wrote:
> > 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?
>
> Yes, your concern is a restriction that you largely made up :)
>
> This is very much *not* driver_managed_dma, which TBH is poorly named since
> it really means either "no DMA at all and thus fine to nominally hotplug
> into live domains" or "userspace-managed DMA with no chance of ever
> inserting DMA API calls at the right points".
Now you are making things up :) When we invented driver_managed_dma it
was explicitly for the driver to take control of the domain attachment
away from the DMA API. For whatever reason the driver might have to do
that.
I wanted to convert all the places calling attach to this model but it
was too difficult with no way to test on all the embedded hardware,
but I still think that is the right thing to do.
Jason