Thread (54 messages) 54 messages, 7 authors, 2025-07-31

Re: [PATCH 05/10] PCI/P2PDMA: Export pci_p2pdma_map_type() function

From: Leon Romanovsky <leon@kernel.org>
Date: 2025-07-25 18:54:06
Also in: dri-devel, kvm, linux-iommu, linux-media, linux-mm, linux-pci, lkml

On Fri, Jul 25, 2025 at 10:30:46AM -0600, Logan Gunthorpe wrote:

On 2025-07-24 02:13, Leon Romanovsky wrote:
quoted
On Thu, Jul 24, 2025 at 10:03:13AM +0200, Christoph Hellwig wrote:
quoted
On Wed, Jul 23, 2025 at 04:00:06PM +0300, Leon Romanovsky wrote:
quoted
From: Leon Romanovsky <leonro@nvidia.com>

Export the pci_p2pdma_map_type() function to allow external modules
and subsystems to determine the appropriate mapping type for P2PDMA
transfers between a provider and target device.
External modules have no business doing this.
VFIO PCI code is built as module. There is no way to access PCI p2p code
without exporting functions in it.
The solution that would make more sense to me would be for either
dma_iova_try_alloc() or another helper in dma-iommu.c to handle the
P2PDMA case. dma-iommu.c already uses those same interfaces and thus
there would be no need to export the low level helpers from the p2pdma code.
I had same idea in early versions of DMA phys API discussion and it was
pointed (absolutely right) that this is layering violation.

At that time, that remark wasn't such clear to me because HMM code
performs check for p2p on every page and has call to dma_iova_try_alloc()
before that check. But this VFIO DMABUF code shows it much more clearer.

The p2p check is performed before any DMA calls and in case of PCI_P2PDMA_MAP_BUS_ADDR
p2p type between DMABUF exporter device and DMABUF importer device, we
don't call dma_iova_try_alloc() or any DMA API at all.

So unfortunately, I think that dma*.c|h is not right place for p2p
type check.

Thanks
Logan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help