Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp167904iob; Mon, 2 May 2022 16:08:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyI3v5hXaJx1rzqiAE0OtGvHAnb4VWjxPS49SKsMuIb6ht050NtQ/R5nAFWpZRjEIRbtST7 X-Received: by 2002:a05:6a00:890:b0:4f6:686e:a8a9 with SMTP id q16-20020a056a00089000b004f6686ea8a9mr13219675pfj.83.1651532881994; Mon, 02 May 2022 16:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651532881; cv=none; d=google.com; s=arc-20160816; b=HTCp/yLg5LhQB9woLm9nlku9KE7znNBiP0qXXa6g007qg+AkstZy5XOZef614CQrOm MtNa60UfCjzFZwycWd61/Fou9M7P1dPuZBs58LCPC5l7egTYW5/PIWT+Phgdu8+1X343 W/LePaUKzwBruYFUvId6u9DjXmUdu7b41ScVYce8Ja19HwwtVjjgW9mayQKOFAv9gY5g 1HHHg0xoP6e4K4l1nWv1pONoE/yWjI3S5yHVPasL5b3EZa1GqHZ5dYLHPFYg4hAThPMM I+FmkOQfZhA+PS3nWVaQ67UjpaKD2SqNBtGr3mccZBW32k7ybVUosYQ9MZzzpBTg5VGB C/rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=dIHFX1lPnIkZc5XdLidXpsJ5ionkmkeQbkv1pMADjhU=; b=z8lEnX5XgrGdVptrYVSzmw8zoh+pRHaYHtwZvAWW6dTkSGsYE8KhCMMcwHXz4ezJ5c 3k8qfMpOfgA65q5FFYl5Lw59a+vs0lnoUkz1fRdNz3tMvQP31xoiJb9V7AWslq4PiyCt f7Ui4Afw1TNHnWzlOR//BRRA7KZw3uI2sjJO7B0ukIlZHu5Fu/1VFy8msP+kFSllC+X/ x3JCFf2NX3B/XBIlNa+jyWcBxjhoGT/LKqocTEgLZbZXKebTLY4fvIXHfoBpHj9kt8QK EqgOWjeJK0Fu/CkdpVxqIc+RRHQ1A5xK9Rs5iCg/LfpOW2Pe5i703/fxte0KWVm6KBvZ DUgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uSABXWi3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d20-20020a056a0010d400b0050d9b909542si3009347pfu.265.2022.05.02.16.08.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 16:08:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uSABXWi3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BACBF2CCA0; Mon, 2 May 2022 16:07:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384526AbiEBK1f (ORCPT + 99 others); Mon, 2 May 2022 06:27:35 -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 X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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.