xen/arm: Mark device as PCI while creating one
authorOleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Fri, 8 Oct 2021 22:48:31 +0000 (15:48 -0700)
committerStefano Stabellini <stefano.stabellini@xilinx.com>
Fri, 8 Oct 2021 22:48:31 +0000 (15:48 -0700)
While adding a PCI device mark it as such, so other frameworks
can distinguish it from DT devices.
For that introduce an architecture defined helper which may perform
additional initialization of the newly created PCI device.

Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
[applicable parts]
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Rahul Singh <rahul.singh@arm.com>
Tested-by: Rahul Singh <rahul.singh@arm.com>
xen/arch/arm/pci/pci.c
xen/drivers/passthrough/pci.c
xen/include/asm-arm/pci.h
xen/include/asm-x86/pci.h

index 138da19284ab60720dc9d69ec5ee3b4a490946fb..082c14e127a86d725e3ac140daf50b258f4be636 100644 (file)
@@ -34,6 +34,11 @@ struct pci_dev *dev_to_pci(struct device *dev)
     return container_of(dev, struct pci_dev, arch.dev);
 }
 
+void arch_pci_init_pdev(struct pci_dev *pdev)
+{
+    pci_to_dev(pdev)->type = DEV_PCI;
+}
+
 static int __init dt_pci_init(void)
 {
     struct dt_device_node *np;
index e1b735d9e81c5d9acf21bfcf7fc449e17a85b47f..3aa8c3175f64e7659651cb45054f7d7f71e39ec1 100644 (file)
@@ -329,6 +329,8 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg, u8 bus, u8 devfn)
     *((u8*) &pdev->devfn) = devfn;
     pdev->domain = NULL;
 
+    arch_pci_init_pdev(pdev);
+
     rc = pdev_msi_init(pdev);
     if ( rc )
     {
index ed765080029e2db7172101ffc370881bbd34f7a0..00ccc3161b103d165a655c9e34c60c4ec02ea7a9 100644 (file)
@@ -95,6 +95,9 @@ static always_inline bool is_pci_passthrough_enabled(void)
 {
     return pci_passthrough_enabled;
 }
+
+void arch_pci_init_pdev(struct pci_dev *pdev);
+
 #else   /*!CONFIG_HAS_PCI*/
 
 struct arch_pci_dev { };
@@ -104,5 +107,9 @@ static always_inline bool is_pci_passthrough_enabled(void)
     return false;
 }
 
+struct pci_dev;
+
+static inline void arch_pci_init_pdev(struct pci_dev *pdev) {}
+
 #endif  /*!CONFIG_HAS_PCI*/
 #endif /* __ARM_PCI_H__ */
index e07695103265056967544cd5d7e7d7b5d2fd7dc1..edd7c3e71a5f1dd40d8cfba6683a0b999ece9563 100644 (file)
@@ -38,4 +38,6 @@ static always_inline bool is_pci_passthrough_enabled(void)
     return true;
 }
 
+static inline void arch_pci_init_pdev(struct pci_dev *pdev) {}
+
 #endif /* __X86_PCI_H__ */