[PATCH 02/10] PCI/P2PDMA: Introduce p2pdma_provider structure for cleaner abstraction
Jason Gunthorpe
jgg at nvidia.com
Tue Jul 29 13:15:02 UTC 2025
On Tue, Jul 29, 2025 at 09:52:09AM +0200, Christoph Hellwig wrote:
> On Sun, Jul 27, 2025 at 03:51:58PM -0300, Jason Gunthorpe wrote:
> > On Thu, Jul 24, 2025 at 09:59:22AM +0200, Christoph Hellwig wrote:
> > > On Thu, Jul 24, 2025 at 10:55:33AM +0300, Leon Romanovsky wrote:
> > > > Please, see last patch in the series https://lore.kernel.org/all/aea452cc27ca9e5169f7279d7b524190c39e7260.1753274085.git.leonro@nvidia.com
> > > > It gives me a way to call p2p code with stable pointer for whole BAR.
> > > >
> > >
> > > That simply can't work.
> >
> > Why not?
> >
> > That's the whole point of this, to remove struct page and use
> > something else as a handle for the p2p when doing the DMA API stuff.
>
> Because the struct page is the only thing that:
>
> a) dma-mapping works on
The main point of the "dma-mapping: migrate to physical
address-based API" series was to remove the struct page dependencies
in the DMA API:
https://lore.kernel.org/all/cover.1750854543.git.leon@kernel.org/
If it is not complete, then it needs more fixing.
> b) is the only place we can discover the routing information,
This patch adds the p2pdma_provider structure to discover the routing
information, this is exactly the problem being solved here.
> but also more importantly ensure that the underlying page is
> still present and the device is not hot unplugged, or in a very
> theoretical worst case replaced by something else.
I already answered this, for DMABUF the DMABUF invalidation scheme is
used to control the lifetime and no DMA mapping outlives the provider,
and the provider doesn't outlive the driver.
Hotplug works fine. VFIO gets the driver removal callback, it
invalidates all the DMABUFs, refuses to re-validate them, destroys the
P2P provider, and ends its driver. There is no lifetime issue.
Obviously you cannot use the new p2provider mechanism without some
kind of protection against use after hot unplug, but it doesn't have
to be struct page based.
Jason
More information about the dri-devel
mailing list