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

From: Robin Murphy

Date: Thu Nov 19 2026 - 08:05:36 EST


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". The model here is basically just dma_link except you run your own explicit IOVA allocator, and you have to make the IOMMU and DMA API calls separately because there are no bundled helpers. Sure it's a relatively specialist use-case that's not for any old driver, and isn't without its own caveats, mostly that extra care would be needed if the device also had reserved regions and/or IOMMU-translated MSIs, but for the typical embedded media devices (in which I firmly include embedded NPUs, since from this perspective the way they work is still about the same) which do want to operate this way, those do not apply so it's fine and pretty straightforward.

Thanks,
Robin.