Re: [PATCH v6 17/18] dma-buf: Let importers ask how peer-to-peer traffic is routed

From: Leon Romanovsky

Date: Tue Sep 15 2026 - 02:31:58 EST


On Mon, Sep 14, 2026 at 07:10:25PM -0300, Jason Gunthorpe wrote:
> On Mon, Sep 14, 2026 at 04:27:00PM +0200, Christian König wrote:
>
> > > +enum pci_p2pdma_map_type
> > > +dma_buf_p2pdma_map_type(struct dma_buf_attachment *attach,
> > > + unsigned int tlp_flags)
> > > +{
> > > + struct dma_buf *dmabuf = attach->dmabuf;
> > > + struct p2pdma_provider *provider;
> > > +
> > > + if (!dmabuf->ops->p2pdma_provider)
> > > + return PCI_P2PDMA_MAP_NONE;
> > > +
> > > + provider = dmabuf->ops->p2pdma_provider(dmabuf);
> > > + if (!provider)
> > > + return PCI_P2PDMA_MAP_NONE;
> > > +
> > > + return pci_p2pdma_map_type_tlp(provider, attach->dev, tlp_flags);
> >
> > Calling PCI subsystem functions from dma-buf is a hard NO-GO.
>
> This is why I had the mapping type arrangement able to know if a PCI
> path was involved so it could activate PCI support for that path. In
> an extendable way so other interconnects could also provide their
> unique knowledge too.
>
> > I shouldn't have allowed the mapping functions to be added to
> > DMA-buf in the first place, all of this belongs either into the DMA
> > layer or the exporter.
>
> DMA layer is not the place to form dmabuf's corrupted
> scatterlist. This must only be done in dmabuf.
>
> We don't want to open code this common logic in every exporter, it
> needs a helper. If you have a better place where to put the thing that
> makes the dmabuf unique broken scatterlist, then I'm open :) HCH isn't
> going to accept anything like that outside stuff hard wired to dmabuf.
>
> > We should probably have a single callback the exporter provides to
> > fill in a structure with PCI specific information for a mapping.
>
> Yeah, that is where I was going.
>
> I'm really sorry I haven't been able to come back to that mapping type
> series. Were you feeling positive about that? Maybe Leon or someone
> can pick it up from me. I was optimistic about scaling back to just
> the maping type negotiation as a first step

I can do it, but we should wait until the "Fix ACS ..." work is complete.

There is no reason to hold up everyone with incorrect PCI ACS behavior just
because we are arguing about where to put the code.

Thanks

>
> Jason