From: Marc Zyngier <maz@kernel.org>
To: Hector Martin <marcan@marcan.st>
Cc: "Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Alyssa Rosenzweig" <alyssa@rosenzweig.io>,
"Sven Peter" <sven@svenpeter.dev>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH 2/3] PCI: apple: Probe all GPIOs for availability first
Date: Mon, 02 May 2022 11:23:14 +0100 [thread overview]
Message-ID: <87fslsi67h.wl-maz@kernel.org> (raw)
In-Reply-To: <20220502093832.32778-3-marcan@marcan.st>
On Mon, 02 May 2022 10:38:31 +0100,
Hector Martin <marcan@marcan.st> wrote:
>
> 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: 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hector Martin <marcan@marcan.st>
> ---
> drivers/pci/controller/pcie-apple.c | 24 ++++++++++++++++++++++++
> 1 file changed, 24 insertions(+)
>
> diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
> index e0c06c0ee731..e3aa2d461739 100644
> --- a/drivers/pci/controller/pcie-apple.c
> +++ b/drivers/pci/controller/pcie-apple.c
> @@ -507,6 +507,20 @@ static u32 apple_pcie_rid2sid_write(struct apple_pcie_port *port,
> return readl_relaxed(port->base + PORT_RID2SID(idx));
> }
>
> +static int apple_pcie_probe_port(struct device_node *np)
> +{
> + struct gpio_desc *gd;
> +
> + gd = gpiod_get_from_of_node(np, "reset-gpios", 0,
> + GPIOD_OUT_LOW, "PERST#");
> + if (IS_ERR(gd)) {
> + return PTR_ERR(gd);
> + }
> +
> + gpiod_put(gd);
> + return 0;
> +}
> +
> static int apple_pcie_setup_port(struct apple_pcie *pcie,
> struct device_node *np)
> {
> @@ -797,8 +811,18 @@ static int apple_pcie_init(struct pci_config_window *cfg)
>
> static int apple_pcie_probe(struct platform_device *pdev)
> {
> + struct device *dev = &pdev->dev;
> + struct device_node *of_port;
> int ret;
>
> + /* Check for probe dependencies for all ports first */
> + for_each_child_of_node(dev->of_node, of_port) {
> + ret = apple_pcie_probe_port(of_port);
> + of_node_put(of_port);
> + if (ret)
> + return dev_err_probe(dev, ret, "Port %pOF probe fail\n", of_port);
> + }
> +
> ret = bus_register_notifier(&pci_bus_type, &apple_pcie_nb);
> if (ret)
> return ret;
Acked-by: Marc Zyngier <maz@kernel.org>
M.
--
Without deviation from the norm, progress is not possible.
next prev parent reply other threads:[~2022-05-02 10:24 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-02 9:38 [PATCH 0/3] PCI: apple: PWREN GPIO support & related fixes Hector Martin
2022-05-02 9:38 ` [PATCH 1/3] PCI: apple: GPIO handling nitfixes Hector Martin
2022-05-02 10:20 ` Marc Zyngier
2022-05-02 12:16 ` Hector Martin
2022-05-02 11:39 ` Greg KH
2022-05-02 9:38 ` [PATCH 2/3] PCI: apple: Probe all GPIOs for availability first Hector Martin
2022-05-02 10:23 ` Marc Zyngier [this message]
2022-05-02 9:38 ` [PATCH 3/3] PCI: apple: Add support for optional PWREN GPIO Hector Martin
2022-05-02 10:31 ` Marc Zyngier
2022-05-02 12:15 ` Hector Martin
2022-05-02 15:14 ` Rob Herring
2022-05-02 15:32 ` Hector Martin
2022-05-03 3:20 ` Hector Martin
2022-05-04 0:33 ` Rob Herring
2022-05-04 3:36 ` Hector Martin
2022-05-05 15:38 ` Marc Zyngier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fslsi67h.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=alyssa@rosenzweig.io \
--cc=bhelgaas@google.com \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=marcan@marcan.st \
--cc=robh@kernel.org \
--cc=stable@vger.kernel.org \
--cc=sven@svenpeter.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).