Re: [PATCH v3 03/24] dma-buf: Add the SGT DMA mapping type
From: Jason Gunthorpe
Date: Wed Nov 25 2026 - 14:07:11 EST
On Wed, Nov 25, 2026 at 07:17:51PM +0100, Christian König wrote:
> On 11/25/26 16:55, Jason Gunthorpe wrote:
> > On Wed, Nov 25, 2026 at 12:19:08PM +0100, Christian König wrote:
> >> The low level API which talks for example to the IOMMU driver for
> >> creating the information how to access the buffer is simply not the
> >> task at hand for that framework. The stuff we already handle is more
> >> than complicated enough.
> >
> > No matter what name you give it we need something in the middle that
> > can see the phys_addr_t and the iommu_domain..
>
> No, absolutely not. That should be given to the exporter so that the
> exporter can call the DMA API to create the DMA addresses for the
> importer.
I think I've said it many times, and I thought you agreed: NAK to
giving GPU exporter drivers an iommu domain.
> The idea here is that the importer give all the information to the
> exporter so that the exporter can do the mapping on behalves of the
> importer.
No GPU driver must touch these internal details, they must only use
standard abstracted APIs that prevent them from abusing things.
My fear of DRM drivers abusing the DMA process is equal and possibly
greater than your fear of phys_addr_t :P
We are not giving DRM a nightmare API to continue to shoot us in the
foot with.
> > The primary issue here is the exporter *direct* call to the DMA API!
>
> Why?
Because we need things to be mapped in ways the DMA API will never
support.
DMA API will never support something like dma_buf_iommu_map(). I have
no idea at all how you expect to build this if exporters are directly
calling DMA API. It is not possible.
> > We cannot disconnect this from the DMA API, ie to use an iommu domain
> > or ualink, if exporting drivers are hardwiring calls into it.
>
> Well the plan is to not disconnect it at all. The exporting drivers
> just says to the underlying API here is my buffer please map that
> for this importer and that result is then given back to the importer
> through the DMA API again.
DMA API will only do basic PCI DMA mappings into dma_addr_t.
It will never handle iommu_domain, it will never handle ualink/etc.
Give us a plan for those if you don't like any of these ideas.
> > Fundamentally the need is for the driver to get the phys_addr list,
> > exactly like today, and then pass it to an op which formats that into
> > the right data structure for the importer. Be it dma_addr[],
> > iommu_domain, or some ualink_addr[] - or whatever.
>
> No, the phys_addr type should only ever been seen by the DMA API and
> not by DMA-buf.
Again, I don't care how you label things or what "library" they live
in, I can't tell if we are nitpicking names or what.
But there needs to be some kind of abstraction that takes in
phys_addr_t and makes sgt, dma_addr_t, or iommu_domain depending on
what the importer needs.
Exporters must not open code that.
Obviously DMABUF is involved here *somehow* since it is the only thing
that knows an importer even exists.
Would you be happy if we made a 'dma mapping for dmabuf' library that
did all of this and DMABUF just passes its type opaquely and drivers
just call its tightly abstracted functions?
That is the component Alistair is proposing, he just prefixed it with
dmabuf_* as the namespace because, lets be honest, only dmabuf needs
this weird looking thing.
Jason