Skip to content

Commit 2778ba1

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 0edfc39 commit 2778ba1

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

drivers/pci/controller/pcie-apple.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,20 @@ 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+
gd = fwnode_gpiod_get_index(of_fwnode_handle(np), "reset", 0,
515+
GPIOD_OUT_LOW, "PERST#");
516+
if (IS_ERR(gd)) {
517+
return PTR_ERR(gd);
518+
}
519+
520+
gpiod_put(gd);
521+
return 0;
522+
}
523+
510524
static int apple_pcie_setup_port(struct apple_pcie *pcie,
511525
struct device_node *np)
512526
{
@@ -801,8 +815,19 @@ static int apple_pcie_init(struct pci_config_window *cfg)
801815

802816
static int apple_pcie_probe(struct platform_device *pdev)
803817
{
818+
struct device *dev = &pdev->dev;
819+
struct device_node *of_port;
804820
int ret;
805821

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

0 commit comments

Comments
 (0)