Skip to content

Commit 3ee1f73

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 7d7b937 commit 3ee1f73

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
@@ -28,6 +28,7 @@
2828
#include <linux/nospec.h>
2929
#include <linux/sched/mm.h>
3030
#include <linux/iommufd.h>
31+
#include <linux/pci-p2pdma.h>
3132
#if IS_ENABLED(CONFIG_EEH)
3233
#include <asm/eeh.h>
3334
#endif
@@ -2094,6 +2095,9 @@ int vfio_pci_core_init_dev(struct vfio_device *core_vdev)
20942095
INIT_LIST_HEAD(&vdev->dummy_resources_list);
20952096
INIT_LIST_HEAD(&vdev->ioeventfds_list);
20962097
INIT_LIST_HEAD(&vdev->sriov_pfs_item);
2098+
vdev->provider = pci_p2pdma_enable(vdev->pdev);
2099+
if (IS_ERR(vdev->provider))
2100+
return PTR_ERR(vdev->provider);
20972101
init_rwsem(&vdev->memory_lock);
20982102
xa_init(&vdev->ctx);
20992103

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)