Skip to content

Commit 8d623f7

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 9b54906 commit 8d623f7

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
@@ -845,13 +845,37 @@ static const struct pci_ecam_ops apple_pcie_cfg_ecam_ops = {
845845
}
846846
};
847847

848+
static int apple_pcie_probe_port(struct device_node *np)
849+
{
850+
struct gpio_desc *gd;
851+
852+
/* check whether the GPPIO pin exists but leave it as is */
853+
gd = fwnode_gpiod_get_index(of_fwnode_handle(np), "reset", 0,
854+
GPIOD_ASIS, "PERST#");
855+
if (IS_ERR(gd))
856+
return PTR_ERR(gd);
857+
858+
gpiod_put(gd);
859+
return 0;
860+
}
861+
848862
static int apple_pcie_probe(struct platform_device *pdev)
849863
{
850864
struct device *dev = &pdev->dev;
851865
struct pci_host_bridge *bridge;
866+
struct device_node *of_port;
852867
struct apple_pcie *pcie;
853868
int ret;
854869

870+
/* Check for probe dependencies for all ports first */
871+
for_each_available_child_of_node(dev->of_node, of_port) {
872+
ret = apple_pcie_probe_port(of_port);
873+
if (ret) {
874+
of_node_put(of_port);
875+
return dev_err_probe(dev, ret, "Port %pOF probe fail\n", of_port);
876+
}
877+
}
878+
855879
bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
856880
if (!bridge)
857881
return -ENOMEM;

0 commit comments

Comments
 (0)