From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A9A1C433FE for ; Mon, 2 May 2022 10:24:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384485AbiEBK1d (ORCPT ); Mon, 2 May 2022 06:27:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384709AbiEBK1R (ORCPT ); Mon, 2 May 2022 06:27:17 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1F751EC78; Mon, 2 May 2022 03:23:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A88B5B8136B; Mon, 2 May 2022 10:23:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59356C385A4; Mon, 2 May 2022 10:23:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651486997; bh=ueMC1dLbT4Lmdji3cjlLiq75yL+TORpoXbr3pfSH5uQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=uSABXWi3sciXzn1wUlJSSPRAfVub4lZTvP+xAkRL+LwhQcN2becnmeYjS6JvAYLnq /kKb72D/OsxQLTC165YrAyjQX1f7ab+5Ii/N/ndvDqeLQ7L/p87HOEkmp5VIEmnWnj c1x4rdmH6W4+z0HYXkHTAyYMmSEG9toZEpfCQE4DM+sIKAJg99y7sGRIf0N6BXbv44 Vx3KSgfJ0YDHez1WsXNx8+rqr4dAlCKFeQ0T0jvdlsBYGQ9BFg/uL01AcElbpUC/U5 6FAf2bDr6AlRrZT0+x3IhSrmQ14aHbJO9XHgHIMQEat6htIoK1mivRSZlc+eJTbXgd nCh5rKHJLf2zA== Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nlTD0-008OTv-QZ; Mon, 02 May 2022 11:23:14 +0100 Date: Mon, 02 May 2022 11:23:14 +0100 Message-ID: <87fslsi67h.wl-maz@kernel.org> From: Marc Zyngier To: Hector Martin Cc: Lorenzo Pieralisi , Rob Herring , Krzysztof =?UTF-8?B?V2lsY3p5xYRza2k=?= , Bjorn Helgaas , Alyssa Rosenzweig , Sven Peter , 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 In-Reply-To: <20220502093832.32778-3-marcan@marcan.st> References: <20220502093832.32778-1-marcan@marcan.st> <20220502093832.32778-3-marcan@marcan.st> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: marcan@marcan.st, lorenzo.pieralisi@arm.com, robh@kernel.org, kw@linux.com, bhelgaas@google.com, alyssa@rosenzweig.io, sven@svenpeter.dev, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Mon, 02 May 2022 10:38:31 +0100, Hector Martin 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 > --- > 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 M. -- Without deviation from the norm, progress is not possible.