Skip to content

Commit 3f8e903

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 ad20204 commit 3f8e903

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
@@ -853,12 +853,36 @@ static const struct pci_ecam_ops apple_pcie_cfg_ecam_ops = {
853853
}
854854
};
855855

856+
static int apple_pcie_probe_port(struct device_node *np)
857+
{
858+
struct gpio_desc *gd;
859+
860+
/* check whether the GPPIO pin exists but leave it as is */
861+
gd = fwnode_gpiod_get_index(of_fwnode_handle(np), "reset", 0,
862+
GPIOD_ASIS, "PERST#");
863+
if (IS_ERR(gd))
864+
return PTR_ERR(gd);
865+
866+
gpiod_put(gd);
867+
return 0;
868+
}
869+
856870
static int apple_pcie_probe(struct platform_device *pdev)
857871
{
858872
struct device *dev = &pdev->dev;
873+
struct device_node *of_port;
859874
struct apple_pcie *pcie;
860875
int ret;
861876

877+
/* Check for probe dependencies for all ports first */
878+
for_each_available_child_of_node(dev->of_node, of_port) {
879+
ret = apple_pcie_probe_port(of_port);
880+
if (ret) {
881+
of_node_put(of_port);
882+
return dev_err_probe(dev, ret, "Port %pOF probe fail\n", of_port);
883+
}
884+
}
885+
862886
pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
863887
if (!pcie)
864888
return -ENOMEM;

0 commit comments

Comments
 (0)