Re: [PATCH v1 08/10] vfio/pci: Enable peer-to-peer DMA transactions by default

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 06, 2025 at 04:02:01PM -0600, Alex Williamson wrote:
> On Mon,  4 Aug 2025 16:00:43 +0300
> Leon Romanovsky <leon@xxxxxxxxxx> wrote:
> 
> > From: Leon Romanovsky <leonro@xxxxxxxxxx>
> > 
> > Make sure that all VFIO PCI devices have peer-to-peer capabilities
> > enables, so we would be able to export their MMIO memory through DMABUF,
> > 
> > Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx>
> > ---
> >  drivers/vfio/pci/vfio_pci_core.c | 4 ++++
> >  include/linux/vfio_pci_core.h    | 1 +
> >  2 files changed, 5 insertions(+)
> > 
> > diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
> > index 31bdb9110cc0f..df9a32d3deac9 100644
> > --- a/drivers/vfio/pci/vfio_pci_core.c
> > +++ b/drivers/vfio/pci/vfio_pci_core.c
> > @@ -28,6 +28,7 @@
> >  #include <linux/nospec.h>
> >  #include <linux/sched/mm.h>
> >  #include <linux/iommufd.h>
> > +#include <linux/pci-p2pdma.h>
> >  #if IS_ENABLED(CONFIG_EEH)
> >  #include <asm/eeh.h>
> >  #endif
> > @@ -2088,6 +2089,9 @@ int vfio_pci_core_init_dev(struct vfio_device *core_vdev)
> >  	INIT_LIST_HEAD(&vdev->dummy_resources_list);
> >  	INIT_LIST_HEAD(&vdev->ioeventfds_list);
> >  	INIT_LIST_HEAD(&vdev->sriov_pfs_item);
> > +	vdev->provider = pci_p2pdma_enable(vdev->pdev);
> > +	if (IS_ERR(vdev->provider))
> > +		return PTR_ERR(vdev->provider);
> 
> I think this just made all vfio-pci drivers functionally dependent on
> CONFIG_PCI_P2PDMA.  Seems at best exporting a dma-buf should be
> restricted if this fails.  Thanks,

It is temporary solution in next patch "vfio/pci: Add dma-buf export
support for MMIO regions", the strict ifdef is added.

  2107 #ifdef CONFIG_VFIO_PCI_DMABUF
  2108         vdev->provider = pci_p2pdma_enable(vdev->pdev);
  2109         if (IS_ERR(vdev->provider))
  2110                 return PTR_ERR(vdev->provider);
  2111
  2112         INIT_LIST_HEAD(&vdev->dmabufs);
  2113 #endif

I will split "vfio/pci: Add dma-buf export ..." patch to introduce CONFIG_VFIO_PCI_DMABUF
before this "vfio/pci: Enable peer-to-peer ..." patch.

Thanks

> 
> Alex
> 
> >  	init_rwsem(&vdev->memory_lock);
> >  	xa_init(&vdev->ctx);
> >  
> > diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h
> > index fbb472dd99b36..b017fae251811 100644
> > --- a/include/linux/vfio_pci_core.h
> > +++ b/include/linux/vfio_pci_core.h
> > @@ -94,6 +94,7 @@ struct vfio_pci_core_device {
> >  	struct vfio_pci_core_device	*sriov_pf_core_dev;
> >  	struct notifier_block	nb;
> >  	struct rw_semaphore	memory_lock;
> > +	struct p2pdma_provider  *provider;
> >  };
> >  
> >  /* Will be exported for vfio pci drivers usage */
> 




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux