diff mbox series

[RFC,RESEND,1/4] pci: Add PCI_BUS_IOMMU property

Message ID 1614414831-39712-2-git-send-email-wangxingang5@huawei.com
State New
Headers show
Series hw/arm/virt-acpi-build: Introduce iommu option for pci root bus | expand

Commit Message

Wang Xingang Feb. 27, 2021, 8:33 a.m. UTC
From: Xingang Wang <wangxingang5@huawei.com>

This Property can be useful to check whether this bus is attached to iommu.

Signed-off-by: Xingang Wang <wangxingang5@huawei.com>
Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
---
 include/hw/pci/pci_bus.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Eric Auger March 10, 2021, 10:25 a.m. UTC | #1
Hi Xingang,

On 2/27/21 9:33 AM, Wang Xingang wrote:
> From: Xingang Wang <wangxingang5@huawei.com>
> 
> This Property can be useful to check whether this bus is attached to iommu.

Strictly speaking this is not a Property (QEMU property) but a flag
> 
> Signed-off-by: Xingang Wang <wangxingang5@huawei.com>
> Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
> ---
>  include/hw/pci/pci_bus.h | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
> index 347440d42c..42109e8a06 100644
> --- a/include/hw/pci/pci_bus.h
> +++ b/include/hw/pci/pci_bus.h
> @@ -24,6 +24,8 @@ enum PCIBusFlags {
>      PCI_BUS_IS_ROOT                                         = 0x0001,
>      /* PCIe extended configuration space is accessible on this bus */
>      PCI_BUS_EXTENDED_CONFIG_SPACE                           = 0x0002,
> +    /* Iommu is enabled on this bus */
s/Iommu/IOMMU here and elsewhere
> +    PCI_BUS_IOMMU                                           = 0x0004,
>  };
>  
>  struct PCIBus {
> @@ -63,4 +65,15 @@ static inline bool pci_bus_allows_extended_config_space(PCIBus *bus)
>      return !!(bus->flags & PCI_BUS_EXTENDED_CONFIG_SPACE);
>  }
>  
> +static inline bool pci_bus_has_iommu(PCIBus *bus)
> +{
> +    PCIBus *root_bus = bus;
> +
> +    while (root_bus && !pci_bus_is_root(root_bus)) {
> +        root_bus = pci_get_bus(root_bus->parent_dev);
> +    }
> +
> +    return !!(root_bus->flags & PCI_BUS_IOMMU);
> +}
> +
>  #endif /* QEMU_PCI_BUS_H */
> 
Eric
Wang Xingang March 11, 2021, 11:59 a.m. UTC | #2
Hi Eric,

On 2021/3/10 18:25, Auger Eric wrote:
> Hi Xingang,
> 
> On 2/27/21 9:33 AM, Wang Xingang wrote:
>> From: Xingang Wang <wangxingang5@huawei.com>
>>
>> This Property can be useful to check whether this bus is attached to iommu.
> 
> Strictly speaking this is not a Property (QEMU property) but a flag
>>
>> Signed-off-by: Xingang Wang <wangxingang5@huawei.com>
>> Signed-off-by: Jiahui Cen <cenjiahui@huawei.com>
>> ---
>>   include/hw/pci/pci_bus.h | 13 +++++++++++++
>>   1 file changed, 13 insertions(+)
>>
>> diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
>> index 347440d42c..42109e8a06 100644
>> --- a/include/hw/pci/pci_bus.h
>> +++ b/include/hw/pci/pci_bus.h
>> @@ -24,6 +24,8 @@ enum PCIBusFlags {
>>       PCI_BUS_IS_ROOT                                         = 0x0001,
>>       /* PCIe extended configuration space is accessible on this bus */
>>       PCI_BUS_EXTENDED_CONFIG_SPACE                           = 0x0002,
>> +    /* Iommu is enabled on this bus */
> s/Iommu/IOMMU here and elsewhere
>> +    PCI_BUS_IOMMU                                           = 0x0004,
>>   };
>>   
>>   struct PCIBus {
>> @@ -63,4 +65,15 @@ static inline bool pci_bus_allows_extended_config_space(PCIBus *bus)
>>       return !!(bus->flags & PCI_BUS_EXTENDED_CONFIG_SPACE);
>>   }
>>   
>> +static inline bool pci_bus_has_iommu(PCIBus *bus)
>> +{
>> +    PCIBus *root_bus = bus;
>> +
>> +    while (root_bus && !pci_bus_is_root(root_bus)) {
>> +        root_bus = pci_get_bus(root_bus->parent_dev);
>> +    }
>> +
>> +    return !!(root_bus->flags & PCI_BUS_IOMMU);
>> +}
>> +
>>   #endif /* QEMU_PCI_BUS_H */
>>
> Eric
> 
> .
> 

Thanks, i will fix this.

Xingang

.
diff mbox series

Patch

diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h
index 347440d42c..42109e8a06 100644
--- a/include/hw/pci/pci_bus.h
+++ b/include/hw/pci/pci_bus.h
@@ -24,6 +24,8 @@  enum PCIBusFlags {
     PCI_BUS_IS_ROOT                                         = 0x0001,
     /* PCIe extended configuration space is accessible on this bus */
     PCI_BUS_EXTENDED_CONFIG_SPACE                           = 0x0002,
+    /* Iommu is enabled on this bus */
+    PCI_BUS_IOMMU                                           = 0x0004,
 };
 
 struct PCIBus {
@@ -63,4 +65,15 @@  static inline bool pci_bus_allows_extended_config_space(PCIBus *bus)
     return !!(bus->flags & PCI_BUS_EXTENDED_CONFIG_SPACE);
 }
 
+static inline bool pci_bus_has_iommu(PCIBus *bus)
+{
+    PCIBus *root_bus = bus;
+
+    while (root_bus && !pci_bus_is_root(root_bus)) {
+        root_bus = pci_get_bus(root_bus->parent_dev);
+    }
+
+    return !!(root_bus->flags & PCI_BUS_IOMMU);
+}
+
 #endif /* QEMU_PCI_BUS_H */