public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Florian Fainelli <florian.fainelli@broadcom.com>
To: Hans Zhang <18255117159@163.com>, Bjorn Helgaas <helgaas@kernel.org>
Cc: linux-pci@vger.kernel.org, "Dom Cobley" <popcornmix@gmail.com>,
	"Phil Elwell" <phil@raspberrypi.com>,
	"Jim Quinlan" <jim2101024@gmail.com>,
	"Broadcom internal kernel review list"
	<bcm-kernel-feedback-list@broadcom.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	"Manivannan Sadhasivam" <mani@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE"
	<linux-rpi-kernel@lists.infradead.org>,
	"moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE"
	<linux-arm-kernel@lists.infradead.org>,
	"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] PCI: brcmstb: Assign pcie->gen from pcie_get_link_speed()
Date: Mon, 4 May 2026 16:46:03 -0700	[thread overview]
Message-ID: <631c8f3f-3d38-42e0-b89a-64281d269bfd@broadcom.com> (raw)
In-Reply-To: <a491a592-5576-4987-a866-a8491f8612e8@163.com>

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 <popcornmix@gmail.com>
>>>> Reported-by: Phil Elwell <phil@raspberrypi.com>
>>>> Fixes: 03f920936977 ("PCI: controller: Validate max-link-speed")
>>>> Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
>>>> ---
>>>>   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.
> 
> Hi Florian,
> 
> 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;

Thank you for stepping in!
-- 
Florian


  reply	other threads:[~2026-05-04 23:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-01 20:24 [PATCH] PCI: brcmstb: Assign pcie->gen from pcie_get_link_speed() Florian Fainelli
2026-05-01 22:03 ` Bjorn Helgaas
2026-05-01 22:05   ` Florian Fainelli
2026-05-02 11:40 ` Bjorn Helgaas
2026-05-04 16:58   ` Florian Fainelli
2026-05-04 17:26     ` Hans Zhang
2026-05-04 23:46       ` Florian Fainelli [this message]
2026-05-05 12:54         ` Hans Zhang
2026-05-05 16:01         ` Bjorn Helgaas
2026-05-05 17:58           ` Florian Fainelli
2026-05-05 21:31             ` Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=631c8f3f-3d38-42e0-b89a-64281d269bfd@broadcom.com \
    --to=florian.fainelli@broadcom.com \
    --cc=18255117159@163.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=bhelgaas@google.com \
    --cc=helgaas@kernel.org \
    --cc=jim2101024@gmail.com \
    --cc=kwilczynski@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=lpieralisi@kernel.org \
    --cc=mani@kernel.org \
    --cc=phil@raspberrypi.com \
    --cc=popcornmix@gmail.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox