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 2CD65FF8855 for ; Tue, 5 May 2026 21:31:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type: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=yy7bEKzcQGtAlqENwVNI0EQc1wIGMr6oPzwoQMSpSAo=; b=IzFMrbzpjjPc+QMUMzneyg0vVj Zd1N9haHVSxbrDvLhinpUX1I8i2DvtlNMcSphrQld2IdDp7BG5wtoIa7oTixQ4mnzciLgw3G8OKg0 /NGYgrcZx1o6srYI2Dz6atef9MPONmBgPR1Lj6QRUIWmkuad6Ys6ZhHfPwhyFgWYq7eo3I0/LKOvV /4AEud2MP2U3dt17JEsCXzLl5ZQKvxa0QaS1HFy2zHLzSSreAXzRyOsLpLjopw8wYCSo1LiFKZehq mnuuL4I412YWi3s5M3M5hVaF/lqnv2pYLrHN1973nxuthAKAr7Yv4piozPYuLuhJiUGeyp40ik/8z 9UL1+50g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1wKNMB-0000000HXfz-2UDt; Tue, 05 May 2026 21:31:07 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1wKNM8-0000000HXfN-2i0q; Tue, 05 May 2026 21:31:06 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 832FF40BA2; Tue, 5 May 2026 21:31:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44779C2BCB4; Tue, 5 May 2026 21:31:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778016663; bh=i9ndZnTLt8zIDy5Mkgz7fGXuWdU3oQ9A5bMpZWxB1ZA=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=kEyYBLGA+XfMJXuZ3Uwb/EoPqSdmtYKeCCZpRwkybIP1z4TrzcAbQK+PV0M6tix7X G4baoMSN6EPb3enZoZt0d3xWs6EBbjXSH6xJtQZZ4XIzR7+YMl9Dy6pjL9rpw1sE4w FOoZtqxUlxfuoh/kYMQ1aVu04f8wYnt5NvrKvwdf0T9OzFn2U5lEaLYD3ZW8kS/zbt MRRaKR7O+I6vb+HqxiM01+N19la4tFuCqMTZZFNMUWiBP/2xCqRgOhVr1zlSrWKb8V 9YTyWKGVUiycFNVBmKTGNwtMGpu5esSVfCKygbJfR3f6BIayeh2Mn6xSD3/2Gk577q nOAYkX3YxlPNA== Date: Tue, 5 May 2026 16:31:02 -0500 From: Bjorn Helgaas To: Florian Fainelli Cc: Hans Zhang <18255117159@163.com>, linux-pci@vger.kernel.org, Dom Cobley , Phil Elwell , Jim Quinlan , Broadcom internal kernel review list , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Manivannan Sadhasivam , Rob Herring , Bjorn Helgaas , "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE" , "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE" , open list Subject: Re: [PATCH] PCI: brcmstb: Assign pcie->gen from pcie_get_link_speed() Message-ID: <20260505213102.GA750989@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260505_143104_950110_0D2AE32C X-CRM114-Status: GOOD ( 40.19 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, May 05, 2026 at 10:58:49AM -0700, Florian Fainelli wrote: > On 5/5/26 09:01, Bjorn Helgaas wrote: > > On Mon, May 04, 2026 at 04:46:03PM -0700, Florian Fainelli wrote: > > > On 5/4/26 10:26, Hans Zhang wrote: > > > > On 5/5/26 00:58, Florian Fainelli wrote: > > > > > On 5/2/26 04:40, Bjorn Helgaas wrote: > > > > > > On Fri, May 01, 2026 at 01:24:38PM -0700, Florian Fainelli wrote: > > > > > > > After commit 03f920936977 ("PCI: controller: Validate max-link-speed"), > > > > > > > pcie->gen stopped being assigned and as a result the established PCIe > > > > > > > link would stop supporting Gen3 speeds on 2712 since pcie->gen is used > > > > > > > to populate LnkCntl2 and LnkCap in brcm_pcie_set_gen(). > > > > > > > > > > > > > > Link: https://github.com/raspberrypi/linux/issues/7343 > > > > > > > Reported-by: Dom Cobley > > > > > > > Reported-by: Phil Elwell > > > > > > > Fixes: 03f920936977 ("PCI: controller: Validate max-link-speed") > > > > > > > Signed-off-by: Florian Fainelli > > > > > > > --- > > > > > > >   drivers/pci/controller/pcie-brcmstb.c | 3 +-- > > > > > > >   1 file changed, 1 insertion(+), 2 deletions(-) > > > > > > > > > > > > > > diff --git a/drivers/pci/controller/pcie-brcmstb.c > > > > > > > b/drivers/pci/ controller/pcie-brcmstb.c > > > > > > > index 714bcab97b60..6138fc4bc064 100644 > > > > > > > --- a/drivers/pci/controller/pcie-brcmstb.c > > > > > > > +++ b/drivers/pci/controller/pcie-brcmstb.c > > > > > > > @@ -2072,8 +2072,7 @@ static int brcm_pcie_probe(struct > > > > > > > platform_device *pdev) > > > > > > >           return PTR_ERR(pcie->clk); > > > > > > >       ret = of_pci_get_max_link_speed(np); > > > > > > > -    if (pcie_get_link_speed(ret) == PCI_SPEED_UNKNOWN) > > > > > > > -        pcie->gen = 0; > > > > > > > +    pcie->gen = pcie_get_link_speed(ret); > > > > > > > > > > > > Take a look at https://sashiko.dev/#/ > > > > > > patchset/20260501202438.376033-1- > > > > > > florian.fainelli%40broadcom.com > > > > > > > > > > > > The notes at https://github.com/raspberrypi/linux/issues/7343 assumed > > > > > > PCI_SPEED_UNKNOWN was 0, but in fact it is 0xff, which means you might > > > > > > want the more defensive patch instead. > > > > > > > > > > > > I'll be happy to replace what's on pci/for-linus if so. > > > > > > > > > > I am starting to think a revert is the simplest path forward, it's > > > > > not clear what pcie_get_link_speed() brings to the table honestly. > > > > > > > > The pcie_get_link_speed function is designed to prevent other Root Port > > > > drivers from accessing the array pcie_link_speed out of bounds. > > > > > > Yes, so that's useful in the first hunk of your commit where we were > > > printing the link speed without checking that the 'max-link-speed' would be > > > bounds check, however it is not really useful for assigning to pcie->gen in > > > our case, so I would prefer the second option: > > > > > > ret = of_pci_get_max_link_speed(np); > > > - if (pcie_get_link_speed(ret) == PCI_SPEED_UNKNOWN) > > > - pcie->gen = 0; > > > + pcie->gen = (ret < 0) ? 0 : ret; > > > > The point of this validation is to make sure we don't program the > > brcmstb hardware with something it doesn't support. > > > > of_pci_get_max_link_speed() only returns an error (ret < 0) if DT > > didn't contain a 'max-link-speed' property. That doesn't tell us > > anything about what brcmstb devices support. > > > > I think this test should be something like what advk_pcie_probe() or > > rockchip_pcie_parse_dt() do. If of_pci_get_max_link_speed() fails or > > returns something not supported by the hardware, they default to the > > fastest speed known to be supported. > > Doing that could be challenging because it varies on a per-controller > instance on some chips like 2712, this would also be a behavioral difference > compared to today where the driver resorts to HW-defaults if the property is > not specified. I think it's OK to default to what the hardware advertises if that makes sense for this hardware and driver. The fact that this is all device & driver dependent was part of what motivated the series in the first place -- the generic OF code can't do that kind of per-controller validation.