Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3246333ioo; Sun, 29 May 2022 18:44:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHooltS1pqaP++RAaTxE7QWD7Joyf487CKahLXxd/6SiATTHSmqXy9IeigTKIxb57z1Ujz X-Received: by 2002:a17:90b:1809:b0:1df:de43:e56 with SMTP id lw9-20020a17090b180900b001dfde430e56mr20882537pjb.135.1653875096651; Sun, 29 May 2022 18:44:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653875096; cv=none; d=google.com; s=arc-20160816; b=yGZgWCmOztcKdDJp0gUx2OBskJtbsJHFaMNailG1vDaiRxRQftL0yhkVQrCEjl3LIX WVe8a/anc51b0IU8tfWqwM61olya2+A7Rh5FHSgqDAZmgy/QVg5ZHIp3Eo98TnlElQwE 3eaJqWanBlidwDlygWiQ1BSs5vWXqEFkHu3OgGOGUD2Tm5FQdrX2QclF/EMj9oCQP5a1 9dTOCToH2AyadJJgiVLL1DtlqBRK4z1eoat1KBXQMFSPAkgWbXskY3h2z1pYjxbCKYJL Yz7FdhkJpAxKZLXjpdJnfxk/igyFuVtJd75saYoNs+tUgc2Jkroa5tHxC/VZIg5ysZQe J1Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=OcZ1DaHw5AgDwn1rt/1/DpSSQI/ATbdMoEOFrgRgoaU=; b=SpiYtuaANTM3Nti5BW/xogiLECHqOdwyQFUMdl3A88JoLLIz44a9fWtVOiB+BSn2KQ YrOA1Q2aYYj4z3PSW3/iixSsXIN0zDNkJfBsR8p9Hx0PJ8A7Q84zx9+1sgV5DJM1k3aj ch8zjlokUeWDXj7OqA/aLxtDUY+YRm7rDbONqJDvf3rdCpTyb9vXa6wItoWGyzFF/gTH PoBuac1WccKjVOyTYkZR59a+adWj5FVpJcgfYGDmNovMmMp4CLqnEQ0dThqljxSSecdZ 6d2l7OCdf7OUc/soLbXej98xFwY6Lbbu9xbLSp73xBeRVLpUfl0KOlV/N9RBwWFYlwH/ A31Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=j8lpnedg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q10-20020a170902f78a00b0015eabaaa16fsi8923941pln.578.2022.05.29.18.44.45; Sun, 29 May 2022 18:44:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=j8lpnedg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231318AbiE2Qwb (ORCPT + 99 others); Sun, 29 May 2022 12:52:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229533AbiE2Qw1 (ORCPT ); Sun, 29 May 2022 12:52:27 -0400 Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 977506128D; Sun, 29 May 2022 09:52:26 -0700 (PDT) Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-f314077115so4351396fac.1; Sun, 29 May 2022 09:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=OcZ1DaHw5AgDwn1rt/1/DpSSQI/ATbdMoEOFrgRgoaU=; b=j8lpnedgMvxQJPzPVvk5GPf7XdZKuiL5ICo4yMUHb0g37ee0X9cLzTAa50b4eMyfZ/ 7aPe4TsSZTebdbDdcGmVdR88wO1xlEl+rl3y5EXUPWRQq/yqGpWVxlcfFX/+DmyP9CZI QWeXK4e9f2mdgRLI8PqLmzT4si5+O2LhfL+kLQyH5WbC+Yt9purRJPWzxR4bahUGdGw2 o/n8u5MZlcbKd/d1Fnd3Az9+2FoZrqqhGDgV4EUp+e4th2cvuMsHFiPkeF6oRNgFzmQ3 fCzgEmtRZ48f3VGWsYCLZOSgMja8+6XXerLPmmugRD01TUQxCYECUbAVJhN7rhIuC6aN ymwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OcZ1DaHw5AgDwn1rt/1/DpSSQI/ATbdMoEOFrgRgoaU=; b=ZuJFUjGjBw4e+xiWYIqzk0TGjX+RS6UrIkhO+v//epaSDxjUT+rfsaaVEc6qjQFy3k k+f6v0e1o688ag9R50OTaN7dEUf3BqJQh2SUcsxYpNeWLQw7WVgQ963jtYFds8wSgaKD 8L/+f48evVdyWv8NxumioJB0nvzssosXDw4Nb8HNgMEIoHA0k2BmnwJdXzuy0l9v6J+G HKqzpkp4I9MDGRMGslK/x1WeGH6TWhK9JgkDXzm/TttbFmMdlkGJcBQ8tWQ4b5FkV762 6i4FHinkXjuktOBL93VbHr5CfhYGu25/i3UrrKFvp+OiqNxACVD26rBxG6J/yzv09XOZ c8Ug== X-Gm-Message-State: AOAM533BdgwLpW/EVd4bbOQNvboP+zliCtOKA+MOJ8MmY2vvNxDMzukF QAEWZ5VYoW1WHR/M3NastRIymrZgphyWI2MRhts1CcyU6R4akw== X-Received: by 2002:a05:6870:b3a4:b0:e9:2370:5e9 with SMTP id w36-20020a056870b3a400b000e9237005e9mr8465718oap.73.1653843145680; Sun, 29 May 2022 09:52:25 -0700 (PDT) MIME-Version: 1.0 References: <20220528224423.7017-1-jim2101024@gmail.com> <20220528224423.7017-2-jim2101024@gmail.com> In-Reply-To: <20220528224423.7017-2-jim2101024@gmail.com> From: Jim Quinlan Date: Sun, 29 May 2022 12:52:14 -0400 Message-ID: Subject: Re: [PATCH v2 1/1] PCI: brcmstb: Fix regression regarding missing PCIe linkup To: linux-pci , Nicolas Saenz Julienne , Bjorn Helgaas , James Dutton , Cyril Brulebois , bcm-kernel-feedback-list , Jim Quinlan , Jim Quinlan , Thorsten Leemhuis Cc: Florian Fainelli , Lorenzo Pieralisi , Rob Herring , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE" , "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE" , open list Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 Sat, May 28, 2022 at 6:44 PM Jim Quinlan wrote: > > commit 93e41f3fca3d ("PCI: brcmstb: Add control of subdevice voltage regulators") > Signed-off-by: Jim Quinlan > introduced a regression on the PCIe RPi4 Compute Module. If the PCIe > root port DT node described in [2] was missing, no linkup would be attempted, > and subsequent accesses would cause a panic because this particular PCIe HW > causes a CPU abort on illegal accesses (instead of returning 0xffffffff). > > We fix this by allowing the DT root port node to be missing, as it behaved > before the original patchset messed things up. > > In addition, two small changes are made: > > 1. Having pci_subdev_regulators_remove_bus() call > regulator_bulk_free() in addtion to regulator_bulk_disable(). > 2. Having brcm_pcie_add_bus() return 0 if there is an > error in calling pci_subdev_regulators_add_bus(). > Instead, we dev_err() and turn on our refusal mode instead. > > It would be best if this commit were tested by someone with a Rpi CM4 > platform, as that is how the regression was found. I have only emulated > the problem and fix on different platform. > > Note that a bisection identified > > commit 830aa6f29f07 ("PCI: brcmstb: Split brcm_pcie_setup() into two funcs") > > as the first failing commit. This commit is a regression, but is unrelated > and was fixed by a subsequent commit in the original patchset. > > [1] https://bugzilla.kernel.org/show_bug.cgi?id=215925 > [2] Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml > > Fixes: 93e41f3fca3d ("PCI: brcmstb: Add control of subdevice voltage regulators") > Fixes: 830aa6f29f07 ("PCI: brcmstb: Split brcm_pcie_setup() into two funcs") > Link: https://bugzilla.kernel.org/show_bug.cgi?id=215925 Thorston -- I forgot to replace the bugzilla link; I'll get it on V3. -- Jim > Signed-off-by: Jim Quinlan > --- > drivers/pci/controller/pcie-brcmstb.c | 43 +++++++++++++++++++-------- > 1 file changed, 30 insertions(+), 13 deletions(-) > > diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c > index ba5c120816b2..0839325f79ab 100644 > --- a/drivers/pci/controller/pcie-brcmstb.c > +++ b/drivers/pci/controller/pcie-brcmstb.c > @@ -540,29 +540,42 @@ static int pci_subdev_regulators_add_bus(struct pci_bus *bus) > > static int brcm_pcie_add_bus(struct pci_bus *bus) > { > - struct device *dev = &bus->dev; > - struct brcm_pcie *pcie = (struct brcm_pcie *) bus->sysdata; > + struct brcm_pcie *pcie; > int ret; > > - if (!dev->of_node || !bus->parent || !pci_is_root_bus(bus->parent)) > + /* > + * Right now we only alloc/enable regulators and initiate pcie link > + * when under the root port bus of the current domain. In the > + * future we may want to alloc/enable regulators under any port > + * device (e.g. a switch). > + */ > + if (!bus->parent || !pci_is_root_bus(bus->parent)) > return 0; > > ret = pci_subdev_regulators_add_bus(bus); > - if (ret) > - return ret; > + if (ret) { > + dev_err(pcie->dev, "failed to alloc/enable regulators\n"); > + goto err; > + } > > - /* Grab the regulators for suspend/resume */ > + /* Save the regulators for RC suspend/resume */ > + pcie = (struct brcm_pcie *) bus->sysdata; > pcie->sr = bus->dev.driver_data; > > + /* Attempt PCIe link-up */ > + if (brcm_pcie_linkup(pcie) == 0) > + return 0; > +err: > /* > - * If we have failed linkup there is no point to return an error as > - * currently it will cause a WARNING() from pci_alloc_child_bus(). > - * We return 0 and turn on the "refusal_mode" so that any further > - * accesses to the pci_dev just get 0xffffffff > + * If we have failed linkup or have an error when turning on > + * regulators, there is no point to return an error value to the > + * caller (pci_alloc_child_bus()) as it will summarily execute a > + * WARNING(). Instead, we turn on our "refusal_mode" and return 0 > + * so that any further PCIe accesses succeed but do nothing (reads > + * return 0xffffffff). If we do not turn on refusal mode, our > + * unforgiving PCIe HW will signal a CPU abort. > */ > - if (brcm_pcie_linkup(pcie) != 0) > - pcie->refusal_mode = true; > - > + pcie->refusal_mode = true; > return 0; > } > > @@ -570,13 +583,17 @@ static void pci_subdev_regulators_remove_bus(struct pci_bus *bus) > { > struct device *dev = &bus->dev; > struct subdev_regulators *sr = dev->driver_data; > + struct brcm_pcie *pcie; > > if (!sr || !bus->parent || !pci_is_root_bus(bus->parent)) > return; > > if (regulator_bulk_disable(sr->num_supplies, sr->supplies)) > dev_err(dev, "failed to disable regulators for downstream device\n"); > + regulator_bulk_free(sr->num_supplies, sr->supplies); > dev->driver_data = NULL; > + pcie = (struct brcm_pcie *) bus->sysdata; > + pcie->sr = NULL; > } > > /* Limits operation to a specific generation (1, 2, or 3) */ > -- > 2.17.1 >