xen/arm: Introduce pci_find_host_bridge_node helper
authorOleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Fri, 8 Oct 2021 22:43:26 +0000 (15:43 -0700)
committerStefano Stabellini <stefano.stabellini@xilinx.com>
Fri, 8 Oct 2021 22:43:26 +0000 (15:43 -0700)
Get host bridge node given a PCI device attached to it.

This helper will be re-used for adding PCI devices by the subsequent
patches.

Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.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-host-common.c
xen/include/asm-arm/pci.h

index c5941b10e9ff566302c39e5a8e752019b2ab29c7..af208e7298b83120a3d7e4e8044f2991eb1476ee 100644 (file)
@@ -236,6 +236,22 @@ err_exit:
     return err;
 }
 
+/*
+ * Get host bridge node given a device attached to it.
+ */
+struct dt_device_node *pci_find_host_bridge_node(struct device *dev)
+{
+    struct pci_host_bridge *bridge;
+    struct pci_dev *pdev = dev_to_pci(dev);
+
+    bridge = pci_find_host_bridge(pdev->seg, pdev->bus);
+    if ( unlikely(!bridge) )
+    {
+        printk(XENLOG_ERR "Unable to find PCI bridge for %pp\n", &pdev->sbdf);
+        return NULL;
+    }
+    return bridge->dt_node;
+}
 /*
  * This function will lookup an hostbridge based on the segment and bus
  * number.
index 8551704de36859a02bd453dbaf7d4ee717cd5400..ed765080029e2db7172101ffc370881bbd34f7a0 100644 (file)
@@ -89,6 +89,7 @@ int pci_generic_config_write(struct pci_host_bridge *bridge, pci_sbdf_t sbdf,
 void __iomem *pci_ecam_map_bus(struct pci_host_bridge *bridge,
                                pci_sbdf_t sbdf, uint32_t where);
 struct pci_host_bridge *pci_find_host_bridge(uint16_t segment, uint8_t bus);
+struct dt_device_node *pci_find_host_bridge_node(struct device *dev);
 
 static always_inline bool is_pci_passthrough_enabled(void)
 {