On 11/24/26 15:20, Jason Gunthorpe wrote:
On Tue, Nov 24, 2026 at 01:36:21PM +0100, Christian König wrote:
The core then negotiates compatible types and adds converters between them,
I have strong objections to that plan and would potentially NAK it.
DMA-buf should *NEVER* accept CPU physical addresses nor provide conversion between different address types.
Keep in mind that DMA-buf is solely a container for DMA addresses, nothing else and it should not provide any mapping functionality whatsoever.
dmabuf needs to provide support for drivers to help them use the interface, and going from physical to dma_addr_t is absolutely a common task every driver must do. I don't care how you call it, but it is a service that must be provided by *something* and matched to the needs of dmabuf.
I will definitely NAK any direction to open code dma mapping in every driver again. If we are going away from SGT then we are fixing all the DRM mistakes, including the wrong open coded DMA mapping, sketchy use of SGT, and abuse of P2P that seems to be endemic in drm.
Completely agree to that as well.
Meaing the exporter constructs a phys_addr list, gets a P2P provider, and some common code constructs what is passed to the importer. I don't care if this is in "dmabuf" or some "dmabuf library" or *whatever* but it must exist as common shared code.
dma_buf_phys_vec_to_sgt() is the template how to implement this transformation.
Well what I disagree with the dma_buf_ prefix here.
DMA-buf is just the container of the result of this process and it shouldn't hold any code to actually generate the addresses. That is simply not part of the job of transferring those information between drivers.
The whole conversion from phys_vec to DMA addresses is something some API should provide based on the data the exporter/importer have negotiated (e.g. p2pdma_provider for example).
I think we need something like a DMA P2P API which sits on top of the PCI and iova API.
and having SGT as a type is what allows that. It only exists for unconverted exporters and importers and eventually goes away once everything is converted. The idea being we don't have to convert everything all at once, whilst also being able to add support for different interconnect types. Are you ok with the SGT type if it is just transitional?
Not really, it just complicate things.
What we should do with the mapping interface is to add the information in which domain the DMA addresses are to be used.
You need to negotiate the actual C data types too, especially if you want to do that nasty idea where dmabuf populates an iommu domain.
Yeah agree as well, but to be honest that task is negligible. We first need to figure out where to put the code.
Christian.
Jason