[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 02/15] hw/pci: Refactor pci_device_iommu_address_space()
From: |
Joao Martins |
Subject: |
[PATCH v4 02/15] hw/pci: Refactor pci_device_iommu_address_space() |
Date: |
Thu, 22 Jun 2023 22:48:32 +0100 |
From: Yi Liu <yi.l.liu@intel.com>
Refactor pci_device_iommu_address_space() and move the
code that fetches the device bus and iommu bus into its
own private helper pci_device_get_iommu_bus_devfn().
This is in preparation to introduce pci_device_iommu_get_attr()
which will need to use it too.
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
[joao: Commit message, and better splitting]
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
---
Splitted from v1:
https://lore.kernel.org/all/20210302203827.437645-6-yi.l.liu@intel.com/
---
hw/pci/pci.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 4e32c09e81d6..90ae92a43d85 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -2632,8 +2632,8 @@ static void pci_device_class_base_init(ObjectClass
*klass, void *data)
assert(conventional || pcie || cxl);
}
}
-
-AddressSpace *pci_device_iommu_address_space(PCIDevice *dev)
+static void pci_device_get_iommu_bus_devfn(PCIDevice *dev, PCIBus **pdevbus,
+ PCIBus **pbus, uint8_t *pdevfn)
{
PCIBus *bus = pci_get_bus(dev);
PCIBus *iommu_bus = bus;
@@ -2686,6 +2686,18 @@ AddressSpace *pci_device_iommu_address_space(PCIDevice
*dev)
iommu_bus = parent_bus;
}
+
+ *pdevbus = bus;
+ *pbus = iommu_bus;
+ *pdevfn = devfn;
+}
+
+AddressSpace *pci_device_iommu_address_space(PCIDevice *dev)
+{
+ PCIBus *bus, *iommu_bus;
+ uint8_t devfn;
+
+ pci_device_get_iommu_bus_devfn(dev, &bus, &iommu_bus, &devfn);
if (!pci_bus_bypass_iommu(bus) && iommu_bus) {
if (iommu_bus->iommu_fn) {
return iommu_bus->iommu_fn(bus, iommu_bus->iommu_opaque, devfn);
--
2.17.2
- [PATCH v4 00/15] vfio: VFIO migration support with vIOMMU, Joao Martins, 2023/06/22
- [PATCH v4 01/15] hw/pci: Add a pci_setup_iommu_ops() helper, Joao Martins, 2023/06/22
- [PATCH v4 02/15] hw/pci: Refactor pci_device_iommu_address_space(),
Joao Martins <=
- [PATCH v4 03/15] hw/pci: Introduce pci_device_iommu_get_attr(), Joao Martins, 2023/06/22
- [PATCH v4 04/15] intel-iommu: Switch to pci_setup_iommu_ops(), Joao Martins, 2023/06/22
- [PATCH v4 05/15] memory/iommu: Add IOMMU_ATTR_DMA_TRANSLATION attribute, Joao Martins, 2023/06/22
- [PATCH v4 06/15] intel-iommu: Implement get_attr() method, Joao Martins, 2023/06/22
- [PATCH v4 07/15] vfio/common: Track whether DMA Translation is enabled on the vIOMMU, Joao Martins, 2023/06/22
- [PATCH v4 08/15] vfio/common: Relax vIOMMU detection when DMA translation is off, Joao Martins, 2023/06/22
- [PATCH v4 09/15] memory/iommu: Add IOMMU_ATTR_MAX_IOVA attribute, Joao Martins, 2023/06/22
- [PATCH v4 10/15] intel-iommu: Implement IOMMU_ATTR_MAX_IOVA get_attr() attribute, Joao Martins, 2023/06/22
- [PATCH v4 11/15] vfio/common: Move dirty tracking ranges update to helper, Joao Martins, 2023/06/22
- [PATCH v4 14/15] vfio/common: Optimize device dirty page tracking with vIOMMU, Joao Martins, 2023/06/22