PCI: brcmstb: Assign pcie->gen from pcie_get_link_speed()
Subsystems (5)
Florian Fainelli
maintainerPATCH 1/1 PCI: brcmstb: Assign pcie->gen from pcie_get_link_speed()
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().
--- drivers/pci/controller/pcie-brcmstb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pci/controller/pcie-brcmstb.c +1 -2
@@ -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); pcie->ssc =of_property_read_bool (np,"brcm,enable-ssc" );
Signature · 1 line
2.43.0
Bjorn Helgaas
AppliedQuoted 10 lines · Florian Fainelli
After commit
03f920936977("PCI: controller: Validate max-link-speed"),pcie->genstopped being assigned and as a result the established PCIe link would stop supporting Gen3 speeds on 2712 sincepcie->genis used to populate LnkCntl2 and LnkCap inbrcm_pcie_set_gen().Reported-by Dom Cobley <[email protected]>Reported-by Phil Elwell <[email protected]>Fixes 03f920936977 ("PCI: controller: Validate max-link-speed")Signed-off-by Florian Fainelli <[email protected]>
Applied to pci/for-linus for v7.1, thanks, and sorry for the breakage.
Quoted 21 lines
--- drivers/pci/controller/pcie-brcmstb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/pci/controller/pcie-brcmstb.c +1
-2@@ -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); pcie->ssc =of_property_read_bool (np,"brcm,enable-ssc" );Signature · 1 line
2.43.0
Florian Fainelli
maintainerQuoted 6 lines · Bjorn Helgaas
Quoted 5 lines · Florian Fainelli
After commit
03f920936977("PCI: controller: Validate max-link-speed"),pcie->genstopped being assigned and as a result the established PCIe link would stop supporting Gen3 speeds on 2712 sincepcie->genis used to populate LnkCntl2 and LnkCap inbrcm_pcie_set_gen().
Quoted 7 lines
Quoted 5 lines
Reported-by Dom Cobley <[email protected]>Reported-by Phil Elwell <[email protected]>Fixes 03f920936977 ("PCI: controller: Validate max-link-speed")Signed-off-by Florian Fainelli <[email protected]>Applied to pci/for-linus for v7.1, thanks, and sorry for the breakage.
I reviewed the original change and completely missed that, so no worries, the fault is mine to have missed it in the first place. Thanks for fast tracking this!
Signature · 1 line
Florian
Quoted 19 lines · Florian Fainelli
After commit
03f920936977("PCI: controller: Validate max-link-speed"),pcie->genstopped being assigned and as a result the established PCIe link would stop supporting Gen3 speeds on 2712 sincepcie->genis used to populate LnkCntl2 and LnkCap inbrcm_pcie_set_gen().Reported-by Dom Cobley <[email protected]>Reported-by Phil Elwell <[email protected]>Fixes 03f920936977 ("PCI: controller: Validate max-link-speed")Signed-off-by Florian Fainelli <[email protected]>--- drivers/pci/controller/pcie-brcmstb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/pci/controller/pcie-brcmstb.c +0
-0
drivers/pci/controller/pcie-brcmstb.c static int brcm_pcie_probe(struct platform_device *pdev) · line 2075
Quoted 6 lines
drivers/pci/controller/pcie-brcmstb.c +1
-2@@ -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.
Quoted 5 lines
drivers/pci/controller/pcie-brcmstb.c +0
-0pcie->ssc =of_property_read_bool (np,"brcm,enable-ssc" );Signature · 1 line
2.43.0
Florian Fainelli
maintainerQuoted 29 lines · Bjorn Helgaas
Quoted 19 lines · Florian Fainelli
After commit
03f920936977("PCI: controller: Validate max-link-speed"),pcie->genstopped being assigned and as a result the established PCIe link would stop supporting Gen3 speeds on 2712 sincepcie->genis used to populate LnkCntl2 and LnkCap inbrcm_pcie_set_gen().Reported-by Dom Cobley <[email protected]>Reported-by Phil Elwell <[email protected]>Fixes 03f920936977 ("PCI: controller: Validate max-link-speed")Signed-off-by Florian Fainelli <[email protected]>--- drivers/pci/controller/pcie-brcmstb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/pci/controller/pcie-brcmstb.c +0
-0drivers/pci/controller/pcie-brcmstb.c static int brcm_pcie_probe(struct platform_device *pdev) · line 2075
Quoted 6 lines
drivers/pci/controller/pcie-brcmstb.c +1
-2@@ -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
Quoted 5 lines
The notes at https://github.com/raspberrypi/linux/issues/7343 assumed
PCI_SPEED_UNKNOWNwas 0, but in fact it is0xff, 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.
Signature · 1 line
Florian
Quoted 30 lines · Florian Fainelli
Quoted 29 lines · Bjorn Helgaas
Quoted 19 lines · Florian Fainelli
After commit
03f920936977("PCI: controller: Validate max-link-speed"),pcie->genstopped being assigned and as a result the established PCIe link would stop supporting Gen3 speeds on 2712 sincepcie->genis used to populate LnkCntl2 and LnkCap inbrcm_pcie_set_gen().Reported-by Dom Cobley <[email protected]>Reported-by Phil Elwell <[email protected]>Fixes 03f920936977 ("PCI: controller: Validate max-link-speed")Signed-off-by Florian Fainelli <[email protected]>---
drivers/pci/controller/pcie-brcmstb.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)drivers/pci/controller/pcie-brcmstb.c +0
-0drivers/pci/controller/pcie-brcmstb.c static int brcm_pcie_probe(struct · line 2075
Quoted 6 lines
drivers/pci/controller/pcie-brcmstb.c +1
-2@@ -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
Quoted 7 lines
Quoted 5 lines
The notes at https://github.com/raspberrypi/linux/issues/7343 assumed
PCI_SPEED_UNKNOWNwas 0, but in fact it is0xff, 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.
commit 03f920936977 ("PCI: controller: Validate max-link-speed")
drivers/pci/controller/pcie-brcmstb.c +3 -2
@@ -1442,7 +1442,7 @@ static int brcm_pcie_start_link(struct brcm_pcie *pcie) cls =FIELD_GET (PCI_EXP_LNKSTA_CLS , lnksta); nlw =FIELD_GET (PCI_EXP_LNKSTA_NLW , lnksta);dev_info (dev,"link up, %s x%u %s\n" , -pci_speed_string (pcie_link_speed[cls]), nlw, +pci_speed_string (pcie_get_link_speed (cls)), nlw, ssc_good ?"(SSC)" :"(!SSC)" );return 0 ;
@@ -2072,7 +2072,8 @@ static int brcm_pcie_probe(struct platform_device *pdev)return PTR_ERR (pcie->clk); ret =of_pci_get_max_link_speed (np); - pcie->gen = (ret <0 ) ?0 : ret; +if (pcie_get_link_speed (ret) ==PCI_SPEED_UNKNOWN ) + pcie->gen =0 ;
Sorry, it's my fault. Should it be changed to the following? Florian, what do you think?
drivers/pci/controller/pcie-brcmstb.c +2 -0
@@ -2074,6 +2074,8 @@ static int brcm_pcie_probe(struct platform_device *pdev) ret =of_pci_get_max_link_speed (np);if (pcie_get_link_speed (ret) ==PCI_SPEED_UNKNOWN ) pcie->gen =0 ; +else + pcie->gen = ret; pcie->ssc =of_property_read_bool (np,"brcm,enable-ssc" );
or
drivers/pci/controller/pcie-brcmstb.c +1 -2
@@ -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 = (ret <0 ) ?0 : ret;
Best regards,
Hans
Florian Fainelli
maintainerQuoted 37 lines · Hans Zhang
Quoted 34 lines · Florian Fainelli
Quoted 33 lines · Bjorn Helgaas
Quoted 19 lines · Florian Fainelli
After commit
03f920936977("PCI: controller: Validate max-link-speed"),pcie->genstopped being assigned and as a result the established PCIe link would stop supporting Gen3 speeds on 2712 sincepcie->genis used to populate LnkCntl2 and LnkCap inbrcm_pcie_set_gen().Reported-by Dom Cobley <[email protected]>Reported-by Phil Elwell <[email protected]>Fixes 03f920936977 ("PCI: controller: Validate max-link-speed")Signed-off-by Florian Fainelli <[email protected]>---
drivers/pci/controller/pcie-brcmstb.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)drivers/pci/controller/pcie-brcmstb.c +0
-0drivers/pci/controller/pcie-brcmstb.c static int brcm_pcie_probe(struct · line 2075
Quoted 6 lines
drivers/pci/controller/pcie-brcmstb.c +1
-2@@ -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_UNKNOWNwas 0, but in fact it is0xff, which means you might want the more defensive patch instead.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
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_speedfunction is designed to prevent other Root Port drivers from accessing the arraypcie_link_speedout 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!
Signature · 1 line
Florian
Quoted 46 lines · Florian Fainelli
Quoted 37 lines · Hans Zhang
Quoted 34 lines · Florian Fainelli
Quoted 33 lines · Bjorn Helgaas
Quoted 19 lines · Florian Fainelli
After commit
03f920936977("PCI: controller: Validate max-link- speed"),pcie->genstopped being assigned and as a result the established PCIe link would stop supporting Gen3 speeds on 2712 sincepcie->genis used to populate LnkCntl2 and LnkCap inbrcm_pcie_set_gen().Reported-by Dom Cobley <[email protected]>Reported-by Phil Elwell <[email protected]>Fixes 03f920936977 ("PCI: controller: Validate max-link-speed")Signed-off-by Florian Fainelli <[email protected]>---
drivers/pci/controller/pcie-brcmstb.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)drivers/pci/controller/pcie-brcmstb.c +0
-0drivers/pci/controller/pcie-brcmstb.c static int brcm_pcie_probe(struct · line 2075
Quoted 6 lines
drivers/pci/controller/pcie-brcmstb.c +1
-2@@ -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_UNKNOWNwas 0, but in fact it is0xff, which means you might want the more defensive patch instead.Quoted 7 lines
Quoted 3 lines
Quoted 1 line
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_speedfunction is designed to prevent other Root Port drivers from accessing the arraypcie_link_speedout of bounds.
Quoted 9 lines
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-
Quoted 1 line
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;
Hi Bjorn,
Please replace the pci/for-linus branch with the above modifications. Or do you need me to create a new patch again?
Best regards,
Hans
Quoted 1 line
Thank you for stepping in!
Quoted 52 lines · Florian Fainelli
Quoted 38 lines · Hans Zhang
Quoted 37 lines · Florian Fainelli
Quoted 36 lines · Bjorn Helgaas
Quoted 20 lines · Florian Fainelli
After commit
03f920936977("PCI: controller: Validate max-link-speed"),pcie->genstopped being assigned and as a result the established PCIe link would stop supporting Gen3 speeds on 2712 sincepcie->genis used to populate LnkCntl2 and LnkCap inbrcm_pcie_set_gen().Reported-by Dom Cobley <[email protected]>Reported-by Phil Elwell <[email protected]>Fixes 03f920936977 ("PCI: controller: Validate max-link-speed")Signed-off-by Florian Fainelli <[email protected]>---
drivers/pci/controller/pcie-brcmstb.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)(quoted diff) +0
-0b/drivers/pci/
controller/pcie-brcmstb.c
index714bcab97b60..6138fc4bc064100644drivers/pci/controller/pcie-brcmstb.c static int brcm_pcie_probe(struct · line 2075
Quoted 6 lines
drivers/pci/controller/pcie-brcmstb.c +1
-2@@ -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.comThe notes at https://github.com/raspberrypi/linux/issues/7343 assumed
PCI_SPEED_UNKNOWNwas 0, but in fact it is0xff, which means you might want the more defensive patch instead.Quoted 7 lines
Quoted 4 lines
Quoted 1 line
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_speedfunction is designed to prevent other Root Port drivers from accessing the arraypcie_link_speedout 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->genin our case, so I would prefer the second option:
Quoted 4 lines
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.
Florian Fainelli
maintainerQuoted 61 lines · Bjorn Helgaas
Quoted 52 lines · Florian Fainelli
Quoted 38 lines · Hans Zhang
Quoted 37 lines · Florian Fainelli
Quoted 36 lines · Bjorn Helgaas
Quoted 20 lines · Florian Fainelli
After commit
03f920936977("PCI: controller: Validate max-link-speed"),pcie->genstopped being assigned and as a result the established PCIe link would stop supporting Gen3 speeds on 2712 sincepcie->genis used to populate LnkCntl2 and LnkCap inbrcm_pcie_set_gen().Reported-by Dom Cobley <[email protected]>Reported-by Phil Elwell <[email protected]>Fixes 03f920936977 ("PCI: controller: Validate max-link-speed")Signed-off-by Florian Fainelli <[email protected]>--- drivers/pci/controller/pcie-brcmstb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)(quoted diff) +0
-0b/drivers/pci/
controller/pcie-brcmstb.c
index714bcab97b60..6138fc4bc064100644drivers/pci/controller/pcie-brcmstb.c static int brcm_pcie_probe(struct · line 2075
Quoted 6 lines
drivers/pci/controller/pcie-brcmstb.c +1
-2@@ -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.comThe notes at https://github.com/raspberrypi/linux/issues/7343 assumed
PCI_SPEED_UNKNOWNwas 0, but in fact it is0xff, which means you might want the more defensive patch instead.Quoted 7 lines
Quoted 4 lines
Quoted 1 line
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_speedfunction is designed to prevent other Root Port drivers from accessing the arraypcie_link_speedout 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->genin our case, so I would prefer the second option:Quoted 4 lines
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.
Quoted 8 lines
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()orrockchip_pcie_parse_dt()do. Ifof_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.
There is also another aspect we have ignored which is that don't currently support anything beyond Gen3 at this point, but this is not enforced. Let me cook another patch.
Signature · 1 line
Florian
Quoted 71 lines · Florian Fainelli
Quoted 61 lines · Bjorn Helgaas
Quoted 52 lines · Florian Fainelli
Quoted 38 lines · Hans Zhang
Quoted 37 lines · Florian Fainelli
Quoted 36 lines · Bjorn Helgaas
Quoted 20 lines · Florian Fainelli
After commit
03f920936977("PCI: controller: Validate max-link-speed"),pcie->genstopped being assigned and as a result the established PCIe link would stop supporting Gen3 speeds on 2712 sincepcie->genis used to populate LnkCntl2 and LnkCap inbrcm_pcie_set_gen().Reported-by Dom Cobley <[email protected]>Reported-by Phil Elwell <[email protected]>Fixes 03f920936977 ("PCI: controller: Validate max-link-speed")Signed-off-by Florian Fainelli <[email protected]>--- drivers/pci/controller/pcie-brcmstb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)(quoted diff) +0
-0b/drivers/pci/
controller/pcie-brcmstb.c
index714bcab97b60..6138fc4bc064100644drivers/pci/controller/pcie-brcmstb.c static int brcm_pcie_probe(struct · line 2075
Quoted 6 lines
drivers/pci/controller/pcie-brcmstb.c +1
-2@@ -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.comThe notes at https://github.com/raspberrypi/linux/issues/7343 assumed
PCI_SPEED_UNKNOWNwas 0, but in fact it is0xff, which means you might want the more defensive patch instead.Quoted 7 lines
Quoted 4 lines
Quoted 1 line
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_speedfunction is designed to prevent other Root Port drivers from accessing the arraypcie_link_speedout 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->genin our case, so I would prefer the second option:Quoted 4 lines
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.
Quoted 8 lines
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()orrockchip_pcie_parse_dt()do. Ifof_pci_get_max_link_speed()fails or returns something not supported by the hardware, they default to the fastest speed known to be supported.
Quoted 4 lines
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.