Skip to content

Commit 0d402bd

Browse files
Marc Zyngierbjorn-helgaas
authored andcommitted
PCI: xgene: Defer probing if the MSI widget driver hasn't probed yet
As a preparatory work to make the XGene MSI driver probe less of a sorry hack, make the PCI driver check for the availability of the MSI parent domain, and defer the probing otherwise. Signed-off-by: Marc Zyngier <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2c9e7f8 commit 0d402bd

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

drivers/pci/controller/pci-xgene.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/jiffies.h>
1313
#include <linux/memblock.h>
1414
#include <linux/init.h>
15+
#include <linux/irqdomain.h>
1516
#include <linux/of.h>
1617
#include <linux/of_address.h>
1718
#include <linux/of_pci.h>
@@ -594,6 +595,24 @@ static struct pci_ops xgene_pcie_ops = {
594595
.write = pci_generic_config_write32,
595596
};
596597

598+
static bool xgene_check_pcie_msi_ready(void)
599+
{
600+
struct device_node *np;
601+
struct irq_domain *d;
602+
603+
if (!IS_ENABLED(CONFIG_PCI_XGENE_MSI))
604+
return true;
605+
606+
np = of_find_compatible_node(NULL, NULL, "apm,xgene1-msi");
607+
if (!np)
608+
return true;
609+
610+
d = irq_find_matching_host(np, DOMAIN_BUS_PCI_MSI);
611+
of_node_put(np);
612+
613+
return d && irq_domain_is_msi_parent(d);
614+
}
615+
597616
static int xgene_pcie_probe(struct platform_device *pdev)
598617
{
599618
struct device *dev = &pdev->dev;
@@ -602,6 +621,10 @@ static int xgene_pcie_probe(struct platform_device *pdev)
602621
struct pci_host_bridge *bridge;
603622
int ret;
604623

624+
if (!xgene_check_pcie_msi_ready())
625+
return dev_err_probe(&pdev->dev, -EPROBE_DEFER,
626+
"MSI driver not ready\n");
627+
605628
bridge = devm_pci_alloc_host_bridge(dev, sizeof(*port));
606629
if (!bridge)
607630
return -ENOMEM;

0 commit comments

Comments
 (0)