qemu-arm
[Top][All Lists]
Advanced

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

RE: [RFC 2/7] hw/pci: Introduce pci_device_iommu_bus


From: Duan, Zhenzhong
Subject: RE: [RFC 2/7] hw/pci: Introduce pci_device_iommu_bus
Date: Thu, 18 Jan 2024 07:32:40 +0000


>-----Original Message-----
>From: Eric Auger <eric.auger@redhat.com>
>Subject: [RFC 2/7] hw/pci: Introduce pci_device_iommu_bus
>
>This helper will allow subsequent patches to retrieve the IOMMU bus
>and call its associated PCIIOMMUOps callbacks.
>
>Signed-off-by: Eric Auger <eric.auger@redhat.com>
>---
> include/hw/pci/pci.h |  1 +
> hw/pci/pci.c         | 16 ++++++++++++++++
> 2 files changed, 17 insertions(+)
>
>diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
>index 63c018b35a..649b327f9f 100644
>--- a/include/hw/pci/pci.h
>+++ b/include/hw/pci/pci.h
>@@ -403,6 +403,7 @@ typedef struct PCIIOMMUOps {
> } PCIIOMMUOps;
>
> AddressSpace *pci_device_iommu_address_space(PCIDevice *dev);
>+PCIBus *pci_device_iommu_bus(PCIDevice *dev);
>
> /**
>  * pci_setup_iommu: Initialize specific IOMMU handlers for a PCIBus
>diff --git a/hw/pci/pci.c b/hw/pci/pci.c
>index 76080af580..5bf07662fe 100644
>--- a/hw/pci/pci.c
>+++ b/hw/pci/pci.c
>@@ -2672,6 +2672,22 @@ static void
>pci_device_class_base_init(ObjectClass *klass, void *data)
>     }
> }
>
>+PCIBus *pci_device_iommu_bus(PCIDevice *dev)
>+{
>+    PCIBus *bus = pci_get_bus(dev);
>+    PCIBus *iommu_bus = bus;
>+
>+    while (iommu_bus && !iommu_bus->iommu_ops && iommu_bus-
>>parent_dev) {
>+        PCIBus *parent_bus = pci_get_bus(iommu_bus->parent_dev);
>+
>+        iommu_bus = parent_bus;

Variable parent_bus can be removed.

>+    }
>+    if (pci_bus_bypass_iommu(bus)) {
>+        return NULL;
>+    }
>+    return iommu_bus;
>+}
>+
> AddressSpace *pci_device_iommu_address_space(PCIDevice *dev)
> {
>     PCIBus *bus = pci_get_bus(dev);
>--
>2.41.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]