Skip to content

Commit 534e1d7

Browse files
marcanjannau
authored andcommitted
PCI: apple: Probe all GPIOs for availability first
If we're probing the PCI controller and some GPIOs are not available and cause a probe defer, we can end up leaving some ports initialized and not others and making a mess. Check for PERST# GPIOs for all ports first, and just return -EPROBE_DEFER if any are not ready yet, without bringing anything up. Fixes: 1e33888 ("PCI: apple: Add initial hardware bring-up") Cc: stable@vger.kernel.org Acked-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Hector Martin <marcan@marcan.st>
1 parent 8e11091 commit 534e1d7

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

drivers/pci/controller/pcie-apple.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,21 @@ static u32 apple_pcie_rid2sid_write(struct apple_pcie_port *port,
507507
return readl_relaxed(port->base + PORT_RID2SID(idx));
508508
}
509509

510+
static int apple_pcie_probe_port(struct device_node *np)
511+
{
512+
struct gpio_desc *gd;
513+
514+
/* check whether the GPPIO pin exists but leave it as is */
515+
gd = fwnode_gpiod_get_index(of_fwnode_handle(np), "reset", 0,
516+
GPIOD_ASIS, "PERST#");
517+
if (IS_ERR(gd)) {
518+
return PTR_ERR(gd);
519+
}
520+
521+
gpiod_put(gd);
522+
return 0;
523+
}
524+
510525
static int apple_pcie_setup_port(struct apple_pcie *pcie,
511526
struct device_node *np)
512527
{
@@ -801,8 +816,19 @@ static int apple_pcie_init(struct pci_config_window *cfg)
801816

802817
static int apple_pcie_probe(struct platform_device *pdev)
803818
{
819+
struct device *dev = &pdev->dev;
820+
struct device_node *of_port;
804821
int ret;
805822

823+
/* Check for probe dependencies for all ports first */
824+
for_each_available_child_of_node(dev->of_node, of_port) {
825+
ret = apple_pcie_probe_port(of_port);
826+
if (ret) {
827+
of_node_put(of_port);
828+
return dev_err_probe(dev, ret, "Port %pOF probe fail\n", of_port);
829+
}
830+
}
831+
806832
ret = bus_register_notifier(&pci_bus_type, &apple_pcie_nb);
807833
if (ret)
808834
return ret;

0 commit comments

Comments
 (0)