[PATCH v2] PCI: brcmstb: Assign pcie->gen from of_pci_get_max_link_speed()

Florian Fainelli posted 1 patch 2 weeks, 5 days ago
drivers/pci/controller/pcie-brcmstb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH v2] PCI: brcmstb: Assign pcie->gen from of_pci_get_max_link_speed()
Posted by Florian Fainelli 2 weeks, 5 days ago
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().

Whether the 'max-link-speed' property is not specified, or it exceeds
Gen3, resort to the HW defaults.

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>
Change-Id: Ic5431469dd7a6c8b391f84f27119dad876256880
---
Changes in v2:

- utilize of_pci_get_max_link_speed() directly
- also validate against exceeding Gen3

 drivers/pci/controller/pcie-brcmstb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
index 714bcab97b60..08a0e7091ced 100644
--- a/drivers/pci/controller/pcie-brcmstb.c
+++ b/drivers/pci/controller/pcie-brcmstb.c
@@ -2072,8 +2072,10 @@ 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)
+	if (ret < 0 || ret > 3)
 		pcie->gen = 0;
+	else
+		pcie->gen = ret;
 
 	pcie->ssc = of_property_read_bool(np, "brcm,enable-ssc");
 
-- 
2.34.1
Re: [PATCH v2] PCI: brcmstb: Assign pcie->gen from of_pci_get_max_link_speed()
Posted by Bjorn Helgaas 1 week, 3 days ago
On Wed, May 06, 2026 at 09:45:37AM -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().
> 
> Whether the 'max-link-speed' property is not specified, or it exceeds
> Gen3, resort to the HW defaults.
> 
> 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>
> Change-Id: Ic5431469dd7a6c8b391f84f27119dad876256880

Applied to pci/for-linus for v7.1, thanks!

Sashiko pointed out a couple issues, but they're unrelated to this
patch, so I'll watch for future patches to address them.

> ---
> Changes in v2:
> 
> - utilize of_pci_get_max_link_speed() directly
> - also validate against exceeding Gen3
> 
>  drivers/pci/controller/pcie-brcmstb.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
> index 714bcab97b60..08a0e7091ced 100644
> --- a/drivers/pci/controller/pcie-brcmstb.c
> +++ b/drivers/pci/controller/pcie-brcmstb.c
> @@ -2072,8 +2072,10 @@ 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)
> +	if (ret < 0 || ret > 3)
>  		pcie->gen = 0;
> +	else
> +		pcie->gen = ret;
>  
>  	pcie->ssc = of_property_read_bool(np, "brcm,enable-ssc");
>  
> -- 
> 2.34.1
>
Re: [PATCH v2] PCI: brcmstb: Assign pcie->gen from of_pci_get_max_link_speed()
Posted by Hans Zhang 2 weeks, 5 days ago

On 5/7/26 00:45, 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().
> 
> Whether the 'max-link-speed' property is not specified, or it exceeds
> Gen3, resort to the HW defaults.
> 
> 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>
> Change-Id: Ic5431469dd7a6c8b391f84f27119dad876256880

Reviewed-by: Hans Zhang <18255117159@163.com>

> ---
> Changes in v2:
> 
> - utilize of_pci_get_max_link_speed() directly
> - also validate against exceeding Gen3
> 
>   drivers/pci/controller/pcie-brcmstb.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
> index 714bcab97b60..08a0e7091ced 100644
> --- a/drivers/pci/controller/pcie-brcmstb.c
> +++ b/drivers/pci/controller/pcie-brcmstb.c
> @@ -2072,8 +2072,10 @@ 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)
> +	if (ret < 0 || ret > 3)
>   		pcie->gen = 0;
> +	else
> +		pcie->gen = ret;
>   
>   	pcie->ssc = of_property_read_bool(np, "brcm,enable-ssc");
>
Re: [PATCH v2] PCI: brcmstb: Assign pcie->gen from of_pci_get_max_link_speed()
Posted by Manivannan Sadhasivam 2 weeks, 5 days ago
On Wed, May 06, 2026 at 09:45:37AM -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().
> 
> Whether the 'max-link-speed' property is not specified, or it exceeds
> Gen3, resort to the HW defaults.
> 
> 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>

Since this is a 7.1 material:

Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>

> Change-Id: Ic5431469dd7a6c8b391f84f27119dad876256880

This Change-Id is irrelevant to upstream.

- Mani

> ---
> Changes in v2:
> 
> - utilize of_pci_get_max_link_speed() directly
> - also validate against exceeding Gen3
> 
>  drivers/pci/controller/pcie-brcmstb.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
> index 714bcab97b60..08a0e7091ced 100644
> --- a/drivers/pci/controller/pcie-brcmstb.c
> +++ b/drivers/pci/controller/pcie-brcmstb.c
> @@ -2072,8 +2072,10 @@ 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)
> +	if (ret < 0 || ret > 3)
>  		pcie->gen = 0;
> +	else
> +		pcie->gen = ret;
>  
>  	pcie->ssc = of_property_read_bool(np, "brcm,enable-ssc");
>  
> -- 
> 2.34.1
> 

-- 
மணிவண்ணன் சதாசிவம்
Re: [PATCH v2] PCI: brcmstb: Assign pcie->gen from of_pci_get_max_link_speed()
Posted by Florian Fainelli 2 weeks, 5 days ago
On 5/6/26 10:08, Manivannan Sadhasivam wrote:
> On Wed, May 06, 2026 at 09:45:37AM -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().
>>
>> Whether the 'max-link-speed' property is not specified, or it exceeds
>> Gen3, resort to the HW defaults.
>>
>> 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>
> 
> Since this is a 7.1 material:
> 
> Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>

Thanks!

> 
>> Change-Id: Ic5431469dd7a6c8b391f84f27119dad876256880
> 
> This Change-Id is irrelevant to upstream.

Should I resubmit or can it be stripped while applying?
-- 
Florian
Re: [PATCH v2] PCI: brcmstb: Assign pcie->gen from of_pci_get_max_link_speed()
Posted by Manivannan Sadhasivam 2 weeks, 4 days ago
On Wed, May 06, 2026 at 11:15:50AM -0700, Florian Fainelli wrote:
> On 5/6/26 10:08, Manivannan Sadhasivam wrote:
> > On Wed, May 06, 2026 at 09:45:37AM -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().
> > > 
> > > Whether the 'max-link-speed' property is not specified, or it exceeds
> > > Gen3, resort to the HW defaults.
> > > 
> > > 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>
> > 
> > Since this is a 7.1 material:
> > 
> > Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>
> 
> Thanks!
> 
> > 
> > > Change-Id: Ic5431469dd7a6c8b391f84f27119dad876256880
> > 
> > This Change-Id is irrelevant to upstream.
> 
> Should I resubmit or can it be stripped while applying?

I hope Bjorn can drop it while applying.

- Mani

-- 
மணிவண்ணன் சதாசிவம்