Skip to contentSkip to conversation

PCI: brcmstb: Restore initial fundamental reset

PATCH Superseded Phil Elwell 5 participants 9 messages Nov 12, 2020

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: brcmstb: Restore initial fundamental reset

Commit 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support") replaced a single reset function with a pointer to one of two implementations, but also removed the call asserting the reset at the start of brcm_pcie_setup. Doing so breaks Raspberry Pis with VL805 XHCI controllers lacking dedicated SPI EEPROMs, which have been used for USB booting but then need to be reset so that the kernel can reconfigure them. The lack of a reset causes the firmware's loading of the EEPROM image to RAM to fail, breaking USB for the kernel.

Fixes commit 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support")
---
 drivers/pci/controller/pcie-brcmstb.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pci/controller/pcie-brcmstb.c +2 -0
index bea86899bd5d..a90d6f69c5a1 100644
@@ -869,6 +869,8 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
 
 	/* Reset the bridge */
 	pcie->bridge_sw_init_set(pcie, 1);
+	pcie->perst_set(pcie, 1);
+
 	usleep_range(100, 200);
 
 	/* Take the bridge out of reset */
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Phil Elwell

Commit 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support") replaced a single reset function with a pointer to one of two implementations, but also removed the call asserting the reset at the start of brcm_pcie_setup. Doing so breaks Raspberry Pis with VL805 XHCI controllers lacking dedicated SPI EEPROMs, which have been used for USB booting but then need to be reset so that the kernel can reconfigure them. The lack of a reset causes the firmware's loading of the EEPROM image to RAM to fail, breaking USB for the kernel.

Quoted 4 lines
Fixes commit 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support")

---

Thanks!

Quoted 16 lines
 drivers/pci/controller/pcie-brcmstb.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pci/controller/pcie-brcmstb.c +2 -0
index bea86899bd5d..a90d6f69c5a1 100644
@@ -869,6 +869,8 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
 
 	/* Reset the bridge */
 	pcie->bridge_sw_init_set(pcie, 1);
+	pcie->perst_set(pcie, 1);
+
 	usleep_range(100, 200);
 
 	/* Take the bridge out of reset */
#2 lore raw
In reply to Phil Elwell

+JimQ,

Quoted 9 lines · Phil Elwell

Commit 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support") replaced a single reset function with a pointer to one of two implementations, but also removed the call asserting the reset at the start of brcm_pcie_setup. Doing so breaks Raspberry Pis with VL805 XHCI controllers lacking dedicated SPI EEPROMs, which have been used for USB booting but then need to be reset so that the kernel can reconfigure them. The lack of a reset causes the firmware's loading of the EEPROM image to RAM to fail, breaking USB for the kernel.

Quoted 3 lines
Fixes commit 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support")

This does indeed seem to have been lost during that commit, I will let JimQ comment on whether this was intentional or not. Please make sure you copy him, always, he wrote the driver after all.

Quoted 18 lines
---
 drivers/pci/controller/pcie-brcmstb.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pci/controller/pcie-brcmstb.c +2 -0
index bea86899bd5d..a90d6f69c5a1 100644
@@ -869,6 +869,8 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
 
 	/* Reset the bridge */
 	pcie->bridge_sw_init_set(pcie, 1);
+	pcie->perst_set(pcie, 1);
+
 	usleep_range(100, 200);
 
 	/* Take the bridge out of reset */
Signature · 1 line
Florian
#3 lore raw
Quoted 13 lines · Florian Fainelli

+JimQ,

Quoted 9 lines · Phil Elwell

Commit 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support") replaced a single reset function with a pointer to one of two implementations, but also removed the call asserting the reset at the start of brcm_pcie_setup. Doing so breaks Raspberry Pis with VL805 XHCI controllers lacking dedicated SPI EEPROMs, which have been used for USB booting but then need to be reset so that the kernel can reconfigure them. The lack of a reset causes the firmware's loading of the EEPROM image to RAM to fail, breaking USB for the kernel.

Quoted 7 lines
Quoted 3 lines
Fixes commit 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support")

This does indeed seem to have been lost during that commit, I will let JimQ comment on whether this was intentional or not. Please make sure you copy him, always, he wrote the driver after all.

Hello,

This wasn't accidentally lost; I intentionally removed it. I was remiss in not mentioning this in comments, sorry.

The reason I took it out is because (a) it breaks certain STB SOCs and
(b) I considered it superfluous (see reason below). At any rate, if you must restore this line please add the following guard so everyone's board will work :-)

        if (pcie->type != BCM7278)
                brcm_pcie_perst_set(pcie, 1);

As for me considering that this line is superfluous -- which apparently it is not : AFAIK PERST# is always asserted from cold start on all Brcm STB SOCs, and I expected the same on the RPi. Asserting PERST# at this point in time should be a no-op. Is this not the case?

Thanks,
Jim Quinlan
Broadcom STB

Quoted 22 lines
Quoted 11 lines
---
 drivers/pci/controller/pcie-brcmstb.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pci/controller/pcie-brcmstb.c +0 -0
index bea86899bd5d..a90d6f69c5a1 100644

drivers/pci/controller/pcie-brcmstb.c static int brcm_pcie_setup(struct brcm_pcie *pcie) · line 876

Quoted 8 lines
drivers/pci/controller/pcie-brcmstb.c +2 -0
@@ -869,6 +869,8 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
 
      /* Reset the bridge */
      pcie->bridge_sw_init_set(pcie, 1);
+     pcie->perst_set(pcie, 1);
+
      usleep_range(100, 200);
 
      /* Take the bridge out of reset */

--
Florian

#4 lore raw

Hi Jim,

Quoted 19 lines · Jim Quinlan
Quoted 17 lines · Florian Fainelli

+JimQ,

Quoted 12 lines · Phil Elwell

Commit 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support") replaced a single reset function with a pointer to one of two implementations, but also removed the call asserting the reset at the start of brcm_pcie_setup. Doing so breaks Raspberry Pis with VL805 XHCI controllers lacking dedicated SPI EEPROMs, which have been used for USB booting but then need to be reset so that the kernel can reconfigure them. The lack of a reset causes the firmware's loading of the EEPROM image to RAM to fail, breaking USB for the kernel.

Fixes commit 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support")
Quoted 7 lines
Quoted 3 lines

This does indeed seem to have been lost during that commit, I will let JimQ comment on whether this was intentional or not. Please make sure you copy him, always, he wrote the driver after all.

Hello,

This wasn't accidentally lost; I intentionally removed it. I was remiss in not mentioning this in comments, sorry.

Yes, a comment would have been helpful.

Quoted 10 lines

The reason I took it out is because (a) it breaks certain STB SOCs and
(b) I considered it superfluous (see reason below). At any rate, if you must restore this line please add the following guard so everyone's board will work :-)

        if (pcie->type != BCM7278)
                brcm_pcie_perst_set(pcie, 1);
Quoted 4 lines

As for me considering that this line is superfluous -- which apparently it is not : AFAIK PERST# is always asserted from cold start on all Brcm STB SOCs, and I expected the same on the RPi. Asserting PERST# at this point in time should be a no-op. Is this not the case?

The reason it isn't superfluous here is that when using USB to boot, the Raspberry Pi BCM2711 firmware will already have configured the PCIe bus once, so another reset is necessary. Since the Linux driver used to always reset everything at start of day, regardless of the power-on reset state, there's no reason for the firmware to also reset it before handing over - and there could be some useful state in there when it comes to debugging.

I'm happy to add a condition - not a BCM7278 sounds reasonable - and a comment, of course.

Phil

#5 lore raw
Quoted 9 lines · Phil Elwell
Quoted 4 lines · Jim Quinlan

As for me considering that this line is superfluous -- which apparently it is not : AFAIK PERST# is always asserted from cold start on all Brcm STB SOCs, and I expected the same on the RPi. Asserting PERST# at this point in time should be a no-op. Is this not the case?

The reason it isn't superfluous here is that when using USB to boot, the Raspberry Pi BCM2711 firmware will already have configured the PCIe bus once, so another reset is necessary.

I think that begs the question why the firmware doesn't reset the PCIe bus before handing over control to the kernel?

Thanks,

Lukas

#6 lore raw
Quoted 8 lines · Lukas Wunner
Quoted 6 lines · Phil Elwell
Quoted 4 lines · Jim Quinlan

As for me considering that this line is superfluous -- which apparently it is not : AFAIK PERST# is always asserted from cold start on all Brcm STB SOCs, and I expected the same on the RPi. Asserting PERST# at this point in time should be a no-op. Is this not the case?

Quoted 6 lines
Quoted 3 lines

The reason it isn't superfluous here is that when using USB to boot, the Raspberry Pi BCM2711 firmware will already have configured the PCIe bus once, so another reset is necessary.

I think that begs the question why the firmware doesn't reset the PCIe bus before handing over control to the kernel?

Are you advocating removing all resets that merely reapply the power-on reset state?

Phil

#7 lore raw
In reply to Phil Elwell
Quoted 50 lines · Phil Elwell

Hi Jim,

Quoted 19 lines · Jim Quinlan
Quoted 17 lines · Florian Fainelli

+JimQ,

Quoted 12 lines · Phil Elwell

Commit 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support") replaced a single reset function with a pointer to one of two implementations, but also removed the call asserting the reset at the start of brcm_pcie_setup. Doing so breaks Raspberry Pis with VL805 XHCI controllers lacking dedicated SPI EEPROMs, which have been used for USB booting but then need to be reset so that the kernel can reconfigure them. The lack of a reset causes the firmware's loading of the EEPROM image to RAM to fail, breaking USB for the kernel.

Fixes commit 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support")
Quoted 7 lines
Quoted 3 lines

This does indeed seem to have been lost during that commit, I will let JimQ comment on whether this was intentional or not. Please make sure you copy him, always, he wrote the driver after all.

Hello,

This wasn't accidentally lost; I intentionally removed it. I was remiss in not mentioning this in comments, sorry.

Yes, a comment would have been helpful.

Quoted 10 lines

The reason I took it out is because (a) it breaks certain STB SOCs and
(b) I considered it superfluous (see reason below). At any rate, if you must restore this line please add the following guard so everyone's board will work :-)

        if (pcie->type != BCM7278)
                brcm_pcie_perst_set(pcie, 1);
Quoted 4 lines

As for me considering that this line is superfluous -- which apparently it is not : AFAIK PERST# is always asserted from cold start on all Brcm STB SOCs, and I expected the same on the RPi. Asserting PERST# at this point in time should be a no-op. Is this not the case?

Quoted 4 lines

The reason it isn't superfluous here is that when using USB to boot, the Raspberry Pi BCM2711 firmware will already have configured the PCIe bus once, so another reset is necessary. Since the Linux driver used to always reset everything at start of day,

Hello,

This is not necessarily true -- this line was added separately with commit 22e21e51ce755399fd42055a3f668ee4af370881. IIRC, at the time we could not find an example where it mattered. My feedback was along the lines that "it cannot hurt" but as it turns out later, it did.

Quoted 4 lines

regardless of the
power-on reset state, there's no reason for the firmware to also reset it before handing over - and there could be some useful state in there when it comes to debugging.

Sure there's a reason -- the PCIe HW should be returned to the pristine state from which it was found, especially if you expect it to be used again. This is what the linux kernel driver does on suspend/remove/power-off.
I think debuggability is not a compelling reason as it can be achieved with a debug-enabled FW image.

Regards,
Jim,

Quoted 5 lines

I'm happy to add a condition - not a BCM7278 sounds reasonable - and a comment, of course.

Phil

#8 lore raw
In reply to Jim Quinlan

Hi Jim,

Quoted 25 lines · Jim Quinlan
Quoted 12 lines · Florian Fainelli

+JimQ,

Quoted 9 lines · Phil Elwell

Commit 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support") replaced a single reset function with a pointer to one of two implementations, but also removed the call asserting the reset at the start of brcm_pcie_setup. Doing so breaks Raspberry Pis with VL805 XHCI controllers lacking dedicated SPI EEPROMs, which have been used for USB booting but then need to be reset so that the kernel can reconfigure them. The lack of a reset causes the firmware's loading of the EEPROM image to RAM to fail, breaking USB for the kernel.

Quoted 7 lines
Quoted 3 lines
Fixes commit 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support")

This does indeed seem to have been lost during that commit, I will let JimQ comment on whether this was intentional or not. Please make sure you copy him, always, he wrote the driver after all.

Hello,

This wasn't accidentally lost; I intentionally removed it. I was remiss in not mentioning this in comments, sorry.

Quoted 7 lines

The reason I took it out is because (a) it breaks certain STB SOCs and
(b) I considered it superfluous (see reason below). At any rate, if you must restore this line please add the following guard so everyone's board will work :-)

        if (pcie->type != BCM7278)
                brcm_pcie_perst_set(pcie, 1);

This seems reasonable to me.

Quoted 4 lines

As for me considering that this line is superfluous -- which apparently it is not : AFAIK PERST# is always asserted from cold start on all Brcm STB SOCs, and I expected the same on the RPi. Asserting PERST# at this point in time should be a no-op. Is this not the case?

I introduced this with 22e21e51ce7 ("PCI: brcmstb: Assert fundamental reset on initialization"). IIRC The story is the following:

- RPI's XHCI chip, which is connected to pcie-brcmstb, depends on a firmware blob. The blob is copied into memory, then the chip can access it anytime through PCIe inbound transfers.

- At any boot stage the pcie-brcmstb might be reconfigured with different inbound windows. This could be in RPi's custom bootloader, U-boot or Linux (or anything else).

- The only way we have to reset the XHCI chip so as for it to catch the new firmware blob addresses is through this PERST# line. Hence the need to toggle it every time the controller has been reconfigured.

Hope it makes some sense. :)

Regards,
Nicolas