Skip to content

Commit 62193aa

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> Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 4635e2a commit 62193aa

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

drivers/pci/controller/pcie-apple.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,12 +872,36 @@ static const struct pci_ecam_ops apple_pcie_cfg_ecam_ops = {
872872
}
873873
};
874874

875+
static int apple_pcie_probe_port(struct device_node *np)
876+
{
877+
struct gpio_desc *gd;
878+
879+
/* check whether the GPPIO pin exists but leave it as is */
880+
gd = fwnode_gpiod_get_index(of_fwnode_handle(np), "reset", 0,
881+
GPIOD_ASIS, "PERST#");
882+
if (IS_ERR(gd))
883+
return PTR_ERR(gd);
884+
885+
gpiod_put(gd);
886+
return 0;
887+
}
888+
875889
static int apple_pcie_probe(struct platform_device *pdev)
876890
{
877891
struct device *dev = &pdev->dev;
892+
struct device_node *of_port;
878893
struct apple_pcie *pcie;
879894
int ret;
880895

896+
/* Check for probe dependencies for all ports first */
897+
for_each_available_child_of_node(dev->of_node, of_port) {
898+
ret = apple_pcie_probe_port(of_port);
899+
if (ret) {
900+
of_node_put(of_port);
901+
return dev_err_probe(dev, ret, "Port %pOF probe fail\n", of_port);
902+
}
903+
}
904+
881905
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
882906
if (!pcie)
883907
return -ENOMEM;

0 commit comments

Comments
 (0)