lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87fslsi67h.wl-maz@kernel.org>
Date:   Mon, 02 May 2022 11:23:14 +0100
From:   Marc Zyngier <maz@...nel.org>
To:     Hector Martin <marcan@...can.st>
Cc:     Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
        Rob Herring <robh@...nel.org>,
        Krzysztof WilczyƄski <kw@...ux.com>,
        Bjorn Helgaas <bhelgaas@...gle.com>,
        Alyssa Rosenzweig <alyssa@...enzweig.io>,
        Sven Peter <sven@...npeter.dev>, linux-pci@...r.kernel.org,
        linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH 2/3] PCI: apple: Probe all GPIOs for availability first

On Mon, 02 May 2022 10:38:31 +0100,
Hector Martin <marcan@...can.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@...r.kernel.org
> Signed-off-by: Hector Martin <marcan@...can.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@...nel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ