Skip to content

Commit 65658da

Browse files
rleonkawasaki
authored andcommitted
vfio/pci: Enable peer-to-peer DMA transactions by default
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 <[email protected]>
1 parent aefac27 commit 65658da

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/vfio/pci/vfio_pci_core.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <linux/nospec.h>
3030
#include <linux/sched/mm.h>
3131
#include <linux/iommufd.h>
32+
#include <linux/pci-p2pdma.h>
3233
#if IS_ENABLED(CONFIG_EEH)
3334
#include <asm/eeh.h>
3435
#endif
@@ -2091,6 +2092,9 @@ int vfio_pci_core_init_dev(struct vfio_device *core_vdev)
20912092
INIT_LIST_HEAD(&vdev->dummy_resources_list);
20922093
INIT_LIST_HEAD(&vdev->ioeventfds_list);
20932094
INIT_LIST_HEAD(&vdev->sriov_pfs_item);
2095+
vdev->provider = pci_p2pdma_enable(vdev->pdev);
2096+
if (IS_ERR(vdev->provider))
2097+
return PTR_ERR(vdev->provider);
20942098
init_rwsem(&vdev->memory_lock);
20952099
xa_init(&vdev->ctx);
20962100

include/linux/vfio_pci_core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ struct vfio_pci_core_device {
9494
struct vfio_pci_core_device *sriov_pf_core_dev;
9595
struct notifier_block nb;
9696
struct rw_semaphore memory_lock;
97+
struct p2pdma_provider *provider;
9798
};
9899

99100
/* Will be exported for vfio pci drivers usage */

0 commit comments

Comments
 (0)