[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC 3/7] vfio/pci: Pass the usable IOVA ranges through PCIIOMMUOps
|
From: |
Eric Auger |
|
Subject: |
[RFC 3/7] vfio/pci: Pass the usable IOVA ranges through PCIIOMMUOps |
|
Date: |
Wed, 17 Jan 2024 09:02:07 +0100 |
Pass the collected usable IOVA regions using the PCIIOMMUOps
set_host_iova_ranges() callback, if implemented.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
hw/vfio/pci.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index d7fe06715c..63937952bb 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2485,6 +2485,28 @@ int vfio_pci_get_pci_hot_reset_info(VFIOPCIDevice *vdev,
return 0;
}
+static int vfio_pci_set_iova_ranges(VFIOPCIDevice *vdev, Error **errp)
+{
+ VFIODevice *vbasedev = &vdev->vbasedev;
+ PCIDevice *pdev = &vdev->pdev;
+ VFIOContainerBase *bcontainer = vbasedev->bcontainer;
+ PCIBus *bus, *iommu_bus;
+
+ if (!bcontainer->iova_ranges) {
+ return 0;
+ }
+
+ bus = pci_get_bus(pdev);
+ iommu_bus = pci_device_iommu_bus(pdev);
+ if (iommu_bus && iommu_bus->iommu_ops &&
+ iommu_bus->iommu_ops->set_host_iova_ranges) {
+ return iommu_bus->iommu_ops->set_host_iova_ranges(
+ bus, iommu_bus->iommu_opaque,
+ pdev->devfn, bcontainer->iova_ranges, errp);
+ }
+ return 0;
+}
+
static int vfio_pci_hot_reset(VFIOPCIDevice *vdev, bool single)
{
VFIODevice *vbasedev = &vdev->vbasedev;
@@ -3004,6 +3026,11 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
goto error;
}
+ ret = vfio_pci_set_iova_ranges(vdev, errp);
+ if (ret) {
+ goto error;
+ }
+
vfio_populate_device(vdev, &err);
if (err) {
error_propagate(errp, err);
--
2.41.0
[RFC 3/7] vfio/pci: Pass the usable IOVA ranges through PCIIOMMUOps,
Eric Auger <=
[RFC 5/7] virtio-iommu: Remove the implementation of iommu_set_iova_ranges, Eric Auger, 2024/01/17
[RFC 6/7] hw/vfio: Remove memory_region_iommu_set_iova_ranges() call, Eric Auger, 2024/01/17
[RFC 7/7] memory: Remove IOMMU MR iommu_set_iova_range API, Eric Auger, 2024/01/17
RE: [RFC 0/7] VIRTIO-IOMMU/VFIO: Fix host iommu geometry handling for hotplugged devices, Duan, Zhenzhong, 2024/01/18
- Re: [RFC 0/7] VIRTIO-IOMMU/VFIO: Fix host iommu geometry handling for hotplugged devices, Eric Auger, 2024/01/18
- RE: [RFC 0/7] VIRTIO-IOMMU/VFIO: Fix host iommu geometry handling for hotplugged devices, Duan, Zhenzhong, 2024/01/19
- Re: [RFC 0/7] VIRTIO-IOMMU/VFIO: Fix host iommu geometry handling for hotplugged devices, Jean-Philippe Brucker, 2024/01/25
- Re: [RFC 0/7] VIRTIO-IOMMU/VFIO: Fix host iommu geometry handling for hotplugged devices, Eric Auger, 2024/01/29
- Re: [RFC 0/7] VIRTIO-IOMMU/VFIO: Fix host iommu geometry handling for hotplugged devices, Jean-Philippe Brucker, 2024/01/30
- Re: [RFC 0/7] VIRTIO-IOMMU/VFIO: Fix host iommu geometry handling for hotplugged devices, Eric Auger, 2024/01/31