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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8BAFEC43334 for ; Thu, 21 Jul 2022 15:47:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=r5FWi0muorL9673oT29GSkJWFLgXoxigtRH8m7I/2aM=; b=ZHpQ2hRApR8hgC wImGwDS4QxYFgfmCQj5m4McKuAnu/Wm+e0UX48PrjbV3tKoFV8sxEedK0sLbcWAqSgvNBBKPageAp hxI1jxWjpJVtcbu77/kvVkSJQdS+XVT4lwl+EOrLdW0S7l1U0sVr/F/Q6I7lMvUUgPhk/WEyzCQO/ t5Fh7g6/ueE8fJeT4U9rRjiGsFytTOLCFDuZ1LI7OVyEvh5YWqZpG2X/3VxjlSzoRi14ypyeO9RQI jT0SaytjZBIdFuslkgXj29hD/5pad1Rh+Jfdvdk1KK3v4ZmSvMlA+XyQQIV8bqbjyS+1Y2+bhU7Ym NipwVod1VXu0zKDeDF+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oEYNu-009IGH-3A; Thu, 21 Jul 2022 15:46:43 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oEYNi-009IBu-CT; Thu, 21 Jul 2022 15:46:32 +0000 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 dfw.source.kernel.org (Postfix) with ESMTPS id CB47161C12; Thu, 21 Jul 2022 15:46:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC5A7C341C0; Thu, 21 Jul 2022 15:46:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658418389; bh=PXrSX6TqOGgu/mUPbX1MSmgTXFQ9SHdxh/ZWILLOrWM=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=XGWFT/851segzOr4xlR49pzv4LvKUjk8gig6g8kUKwDDgcAfTJIc0R03rIpTCY3aV 1KS2DiK3JMESQACTiJYmZnlYMzrquaz7yK9Ez8VrJ/LZQaJgf2rfBdSgOhwbUqkzpG D2pmFlqhbcZ+QcwhmIyeTcq2fZX2aRJQB4L5M27vI9F/cn/a7Ml03p2IFh2BhHstQY NKaz8J6QOMgt1His78n/IsY6GxYY/VWBhcWsosInI/8e3MsKz0I8NbQ3AAOrOvAXSX cmmhojATSEUiEIMJnHwSnQwTuUsqO49oryt5KKAbQk+sjHW9S6KS3PuTrCOx089Q5B KugxgcpzPBFXQ== Date: Thu, 21 Jul 2022 10:46:27 -0500 From: Bjorn Helgaas To: Jim Quinlan Cc: Jim Quinlan , "open list:PCI NATIVE HOST BRIDGE AND ENDPOINT DRIVERS" , Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , "maintainer:BROADCOM BCM7XXX ARM ARCHITECTURE" , Florian Fainelli , Lorenzo Pieralisi , Rob Herring , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE" , "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE" , open list Subject: Re: [PATCH v2 3/6] PCI: brcmstb: Add "refusal mode" to preclude PCIe-induced CPU aborts Message-ID: <20220721154627.GA1722428@bhelgaas> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220721_084630_533946_D56E7ED1 X-CRM114-Status: GOOD ( 34.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Jul 21, 2022 at 10:53:54AM -0400, Jim Quinlan wrote: > https://lore.kernel.org/linux-pci/20171215201434.GY30595@bhelgaas-glaptop.roam.corp.google.com/ > On Wed, Jul 20, 2022 at 6:06 PM Bjorn Helgaas wrote: > > On Sat, Jul 16, 2022 at 06:24:50PM -0400, Jim Quinlan wrote: > > > Our PCIe RC HW has an atypical behavior: if it does not have PCIe link > > > established between itself and downstream, any subsequent config space > > > access causes a CPU abort. This commit sets a "refusal mode" if the PCIe > > > link-up fails, and this has our pci_ops map_bus function returning a NULL > > > address, which in turn precludes the access from happening. > > > > > > Right now, "refusal mode" is window dressing. It will become relevant > > > in a future commit when brcm_pcie_start_link() is invoked during > > > enumeration instead of before it. > > > > > > Signed-off-by: Jim Quinlan > > > --- > > > drivers/pci/controller/pcie-brcmstb.c | 24 ++++++++++++++++++++++++ > > > 1 file changed, 24 insertions(+) > > > > > > diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c > > > index c026446d5830..72219a4f3964 100644 > > > --- a/drivers/pci/controller/pcie-brcmstb.c > > > +++ b/drivers/pci/controller/pcie-brcmstb.c > > > @@ -255,6 +255,7 @@ struct brcm_pcie { > > > u32 hw_rev; > > > void (*perst_set)(struct brcm_pcie *pcie, u32 val); > > > void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val); > > > + bool refusal_mode; > > > }; > > > > > > static inline bool is_bmips(const struct brcm_pcie *pcie) > > > @@ -687,6 +688,19 @@ static void __iomem *brcm_pcie_map_conf(struct pci_bus *bus, unsigned int devfn, > > > if (pci_is_root_bus(bus)) > > > return PCI_SLOT(devfn) ? NULL : base + where; > > > > > > + if (pcie->refusal_mode) { > > > + /* > > > + * At this point we do not have PCIe link-up. If there is > > > + * a config read or write access besides those targeting > > > + * the host bridge, our PCIe HW throws a CPU abort. To > > > + * prevent this we return the NULL address. The calling > > > + * functions -- pci_generic_config_*() -- will notice this > > > + * and not perform the access, and if it is a read access, > > > + * 0xffffffff is returned. > > > + */ > > > + return NULL; > > > + } > > > > Is this any different from all the other .map_bus() implementations > > that return NULL when the link is down? > > Not really, but long ago I submitted code that gated the config spec > access based on link status and was advised not to do it [1]. > I'll be happy to make it look like the others. > > [1] https://lore.kernel.org/linux-pci/20171215201434.GY30595@bhelgaas-glaptop.roam.corp.google.com/ My point there was that if you can deal with the abort cleanly, that's the best approach. Apparently brcmstb can't recover cleanly, so you have to settle for the 99% solution. The refusal_mode approach has the same race as checking *_pcie_link_up(), since the link may go down between the time brcm_pcie_start_link() sees that it is up and the time somebody does a config access: brcm_pcie_start_link pcie->refusal_mode = false brcm_pcie_map_conf if (pcie->refusal_mode) # still false So there's no advantage in making the code look different. Checking for link-up in the config access path can never completely remove the window, but it does make it smaller than using refusal_mode. Bjorn _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel