mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: "Alistair Popple" <apopple@nvidia.com>,
	"Sumit Semwal" <sumit.semwal@linaro.org>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Simona Vetter" <simona.vetter@ffwll.ch>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Vivek Kasireddy" <vivek.kasireddy@intel.com>,
	"Dongwon Kim" <dongwon.kim@intel.com>,
	"Kevin Tian" <kevin.tian@intel.com>,
	"Xu Yilun" <yilun.xu@linux.intel.com>,
	"Karl Mehltretter" <kmehltretter@gmail.com>,
	"Baolu Lu" <baolu.lu@linux.intel.com>,
	"Felix Kuehling" <felix.kuehling@amd.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	intel-xe@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
	linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org,
	linux-rdma@vger.kernel.org, iommu@lists.linux.dev,
	"Keith Busch" <kbusch@kernel.org>, "Jens Axboe" <axboe@kernel.dk>,
	"Christoph Hellwig" <hch@lst.de>,
	"Sagi Grimberg" <sagi@grimberg.me>,
	linux-nvme@lists.infradead.org,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@kernel.org>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Simon Horman" <horms@kernel.org>,
	"Mina Almasry" <almasrymina@google.com>,
	netdev@vger.kernel.org, "Alexey Kardashevskiy" <aik@amd.com>,
	zhipingz@meta.com, treding@nvidia.com, jhubbard@nvidia.com,
	chaitanyak@nvidia.com, "Leon Romanovsky" <leon@kernel.org>
Subject: Re: [PATCH v3 03/24] dma-buf: Add the SGT DMA mapping type
Date: Wed, 25 Nov 2026 19:17:51 +0100	[thread overview]
Message-ID: <5fb8bb60-7d9f-49b1-899c-40a890fdc14b@amd.com> (raw)
In-Reply-To: <20261125155559.GL246011@ziepe.ca>

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.

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.

> If you don't want DMABUF to be that thing, then I'm not sure what you
> have in mind.

A P2P DMA API the exporter can use to create the addresses for the importer.

>>> If I drop the type/placement negotiation for now and focus on SGT removal I can
>>> simplify things a lot. Plan would be something like:
>>>
>>> 1) Introduce a new C data type (dma_phys_list?) for exporters to pass physical
>>>    location info and context for mapping.
>>
>> Something like this maybe?
>>
>> struct {
>> 	u32	mapping_type;
>> 	u32	num_entries;
>> 	union {
>> 		dma_addr_t	*dma_addr;
>> 		u64		*generic_64bit_addr;
>> 		...
>> 	};
>> }
>> ....
> 
> "phsyical location info" means phys_addr_t and related, not
> dma_addr_t. Step #3 has it as the *input* to dma_phys_list_to_sgt().
> 
> The flow today has the exporter get a phys_addr_t (ie a struct page),
> build a scatterlist and directly invoke the DMA API.

Yeah and that is completely correct and should stay that way.

> The primary issue here is the exporter *direct* call to the DMA API!

Why?

> 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.

> 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.

Otherwise DMA-buf becomes the middle layer for creating the DMA mapping and that was I want to avoid.

> This is the main issue here, disconnecting the exporters from being
> hardwired to the DMA API.
> 
> That's what Alistair is explaining. This sequence:
> 
>>> 2) Introduce two new dma_buf_ops - map_dma_phys_list() and unmap_dma_phys_list()
>>>    - which are replacements for {un}map_dma_buf that converted exporters use to
>>>    return a dma_phys_list instead of returning a sg_table.
>>>
>>> 3) Move dma_buf_phys_vec_to_sgt() somewhere other than drivers/dma-buf and
>>>    rename it dma_phys_list_to_sgt().
> 
>>> 4) Update dma_buf_{un}map_sgt() to call the new map_dma_phys_list() ops and
>>>    dma_phys_list_to_sgt() to create an sg_table for unconverted importers
>>>    importing from a converted exporter.
> 
> Effectively converts all the exporters to produce a phys_addr_t, and
> then moves the DMA mapping action into one single place in common
> code.

Ok in that case I have misunderstood that and that is still a clear NO-GO from my side.

The exporter should talk to the DMA API and create the mapping on behalves of the importer.

Regards,
Christian.

> 
> With one single place we can figure out how to replace it with a call
> that does an iommu_domain:
> 
>>> 5) Add dma_buf_iommu_map() taking a IOMMU domain/iova/offset/size to be called
>>>    from iommufd for mapping an attachment into an IOMMU domain.
> 
> But that relies on iommu_map having access to the dma_phys_list *which
> is true physical*
> 
>> I think a whole bunch of other drivers would be really happy to use
>> that interface as well, yes.
> 
> Right, that is clear now, that it is not just iommufd that wants a
> dma_buf_iommu_map()
> 
> But I don't understand at all how you imagine to implement
> dma_buf_iommu_map() if you don't want this in the DMABUF core code.
> 
>> That totally sounds like a plan to me.
> 
> I'm confused if you agreed to what Alistair said :(
> 
> Jason


  reply	other threads:[~2026-11-25 18:18 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  5:55 [PATCH v3 00/24] DMA-buf mapping types Alistair Popple
2026-11-20  5:55 ` [PATCH v3 01/24] treewide: Rename dma_buf_(un)map_attachment() to dma_buf_(un)map_sgt() Alistair Popple
2026-11-23 13:28   ` Christian König
2026-11-20  5:55 ` [PATCH v3 02/24] dma-buf: Introduce DMA-buf mapping types Alistair Popple
2026-11-20  5:55 ` [PATCH v3 03/24] dma-buf: Add the SGT DMA mapping type Alistair Popple
2026-11-23 13:36   ` Christian König
2026-11-23 16:57     ` Jason Gunthorpe
2026-11-23 18:37       ` Christian König
     [not found]         ` <awT8prWsj11TBdmP@nvdebian.thelocal>
2026-11-24 12:36           ` Christian König
2026-11-24 14:20             ` Jason Gunthorpe
2026-11-24 16:02               ` Christian König
2026-11-24 19:46                 ` Jason Gunthorpe
     [not found]                   ` <awZ_Os1pXelOGaFP@nvdebian.thelocal>
2026-11-25 11:19                     ` Christian König
2026-11-25 15:55                       ` Jason Gunthorpe
2026-11-25 18:17                         ` Christian König [this message]
2026-11-24 14:00         ` Jason Gunthorpe
2026-11-20  5:55 ` [PATCH v3 04/24] dma-buf: Negotiate the mapping type in dma_buf_dynamic_attach() Alistair Popple
2026-11-20  5:55 ` [PATCH v3 05/24] dma-buf: Route SGT related actions through the attachment's mapping type Alistair Popple
2026-11-20  5:55 ` [PATCH v3 06/24] dma-buf: Allow single exporter drivers to avoid the match_mapping function Alistair Popple
2026-11-20  5:55 ` [PATCH v3 07/24] dma-buf: Convert exporters allocating a table per map to the SGT mapping type Alistair Popple
2026-11-20  9:02   ` Karol Wachowski
2026-11-20  5:55 ` [PATCH v3 08/24] iommufd/selftest: Convert the test exporter " Alistair Popple
2026-11-20  5:55 ` [PATCH v3 09/24] dma-buf: Convert exporters keeping a table per attachment " Alistair Popple
2026-11-20  5:55 ` [PATCH v3 10/24] drm: Convert drm_gem_map_dma_buf() and its users " Alistair Popple
2026-11-20  5:55 ` [PATCH v3 11/24] drm/xe/dma-buf: Use " Alistair Popple
2026-11-20  5:55 ` [PATCH v3 12/24] drm/amdgpu: " Alistair Popple
2026-11-20  5:55 ` [PATCH v3 13/24] udmabuf: Convert to " Alistair Popple
2026-11-20  5:55 ` [PATCH v3 14/24] drm/omapdrm: " Alistair Popple
2026-11-20  5:55 ` [PATCH v3 15/24] accel/ivpu: Convert the userptr exporter " Alistair Popple
2026-11-20  5:55 ` [PATCH v3 16/24] drm/vmwgfx: Use match_mapping instead of dummy calls Alistair Popple
2026-11-20  5:55 ` [PATCH v3 17/24] dma-buf: Convert dma_buf_phys_vec_to_sgt() and its users to the SGT mapping type Alistair Popple
2026-11-20  5:55 ` [PATCH v3 18/24] iio: buffer: convert to use " Alistair Popple
2026-11-20  5:55 ` [PATCH v3 19/24] functionfs: " Alistair Popple
2026-11-20  5:55 ` [PATCH v3 20/24] dma-buf: Remove unused SGT stuff from the common structures Alistair Popple
2026-11-20  5:55 ` [PATCH v3 21/24] dma-buf: Add kunit tests for mapping type Alistair Popple
2026-11-20  5:56 ` [PATCH v3 22/24] dma-buf: Let the exporter select mapping type at pin/map Alistair Popple
2026-11-20  5:56 ` [PATCH v3 23/24] dma-buf: Add dma_buf_mapping_map() returning a type-tagged mapping and implement it for sgt Alistair Popple
2026-11-20  5:56 ` [PATCH v3 24/24] dma-buf: Add kunit tests for mapping type selection Alistair Popple

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5fb8bb60-7d9f-49b1-899c-40a890fdc14b@amd.com \
    --to=christian.koenig@amd.com \
    --cc=aik@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=almasrymina@google.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=apopple@nvidia.com \
    --cc=axboe@kernel.dk \
    --cc=baolu.lu@linux.intel.com \
    --cc=chaitanyak@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=dongwon.kim@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=edumazet@kernel.org \
    --cc=felix.kuehling@amd.com \
    --cc=hch@lst.de \
    --cc=horms@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=jhubbard@nvidia.com \
    --cc=kbusch@kernel.org \
    --cc=kevin.tian@intel.com \
    --cc=kmehltretter@gmail.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=matthew.brost@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sagi@grimberg.me \
    --cc=simona.vetter@ffwll.ch \
    --cc=sumit.semwal@linaro.org \
    --cc=thomas.hellstrom@linux.intel.com \
    --cc=treding@nvidia.com \
    --cc=vivek.kasireddy@intel.com \
    --cc=yilun.xu@linux.intel.com \
    --cc=zhipingz@meta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®