public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] pci: pcie-brcmstb: bring over some robustness improvements from Linux
@ 2023-08-14 22:34 Sam Edwards
  2023-08-31 16:26 ` Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Sam Edwards @ 2023-08-14 22:34 UTC (permalink / raw)
  To: u-boot, Nicolas Saenz Julienne; +Cc: Pali Rohár, Sam Edwards

Since the initial U-Boot driver was ported here from Linux, the latter
has had a few changes for robustness/stability. This patch brings over
two of them:
- Do not attempt to access the configuration space of a PCIe device if
  the link has gone down, as that will result in an asynchronous SError
  interrupt which will crash U-Boot.
- Wait for the recommended 100ms after PERST# is deasserted.

I sent this patch while debugging a crash involving PCIe, but these
are unrelated improvements. I do not believe that this patch fixes any
real-world bug.

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
---
 drivers/pci/pcie_brcmstb.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/pci/pcie_brcmstb.c b/drivers/pci/pcie_brcmstb.c
index 1de2802113..a159952822 100644
--- a/drivers/pci/pcie_brcmstb.c
+++ b/drivers/pci/pcie_brcmstb.c
@@ -223,6 +223,10 @@ static int brcm_pcie_config_address(const struct udevice *dev, pci_dev_t bdf,
 		return 0;
 	}
 
+	/* An access to our HW w/o link-up will cause a CPU Abort */
+	if (!brcm_pcie_link_up(pcie))
+		return -EINVAL;
+
 	/* For devices, write to the config space index register */
 	idx = PCIE_ECAM_OFFSET(pci_bus, pci_dev, pci_func, 0);
 
@@ -505,6 +509,12 @@ static int brcm_pcie_probe(struct udevice *dev)
 	clrbits_le32(pcie->base + PCIE_RGR1_SW_INIT_1,
 		     RGR1_SW_INIT_1_PERST_MASK);
 
+	/*
+	 * Wait for 100ms after PERST# deassertion; see PCIe CEM specification
+	 * sections 2.2, PCIe r5.0, 6.6.1.
+	 */
+	mdelay(100);
+
 	/* Give the RC/EP time to wake up, before trying to configure RC.
 	 * Intermittently check status for link-up, up to a total of 100ms.
 	 */
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] pci: pcie-brcmstb: bring over some robustness improvements from Linux
  2023-08-14 22:34 [PATCH] pci: pcie-brcmstb: bring over some robustness improvements from Linux Sam Edwards
@ 2023-08-31 16:26 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2023-08-31 16:26 UTC (permalink / raw)
  To: Sam Edwards; +Cc: u-boot, Nicolas Saenz Julienne, Pali Rohár

[-- Attachment #1: Type: text/plain, Size: 751 bytes --]

On Mon, Aug 14, 2023 at 04:34:13PM -0600, Sam Edwards wrote:

> Since the initial U-Boot driver was ported here from Linux, the latter
> has had a few changes for robustness/stability. This patch brings over
> two of them:
> - Do not attempt to access the configuration space of a PCIe device if
>   the link has gone down, as that will result in an asynchronous SError
>   interrupt which will crash U-Boot.
> - Wait for the recommended 100ms after PERST# is deasserted.
> 
> I sent this patch while debugging a crash involving PCIe, but these
> are unrelated improvements. I do not believe that this patch fixes any
> real-world bug.
> 
> Signed-off-by: Sam Edwards <CFSworks@gmail.com>

Applied to u-boot/next, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-31 16:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-14 22:34 [PATCH] pci: pcie-brcmstb: bring over some robustness improvements from Linux Sam Edwards
2023-08-31 16:26 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox