aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/backport-4.19/736-v5.5-net-sfp-allow-modules-with-slow-diagnostics-to-probe.patch
diff options
context:
space:
mode:
Diffstat
From 92f08923793d755a2eb1bf4724c6b6764cfba071 Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.com>
Date: Wed, 11 Nov 2020 17:08:33 +0000
Subject: [PATCH] PCI: brcmstb: Restore initial fundamental reset

[1] 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.

See: https://www.raspberrypi.org/forums/viewtopic.php?p=1758157#p1758157

Fixes: 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support")

[1] 04356ac30771 ("PCI: brcmstb: Add bcm7278 PERST# support")

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
 drivers/pci/controller/pcie-brcmstb.c | 2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/pci/controller/pcie-brcmstb.c
+++ b/drivers/pci/controller/pcie-brcmstb.c
@@ -871,6 +871,8 @@ static int brcm_pcie_setup(struct brcm_p
 
 	/* 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 */
fp *sfp)
++{
++ if (sfp->id.ext.sff8472_compliance == SFP_SFF8472_COMPLIANCE_NONE)
++ return 0;
++
++ if (!(sfp->id.ext.diagmon & SFP_DIAGMON_DDM))
++ return 0;
++
++ if (sfp->id.ext.diagmon & SFP_DIAGMON_ADDRMODE)
++ /* This driver in general does not support address
++ * change.
++ */
++ return 0;
++
++ mod_delayed_work(system_wq, &sfp->hwmon_probe, 1);
++ sfp->hwmon_tries = R_PROBE_RETRY_SLOW;
+
+- return PTR_ERR_OR_ZERO(sfp->hwmon_dev);
++ return 0;
+ }
+
+ static void sfp_hwmon_remove(struct sfp *sfp)
+ {
++ cancel_delayed_work_sync(&sfp->hwmon_probe);
+ if (!IS_ERR_OR_NULL(sfp->hwmon_dev)) {
+ hwmon_device_unregister(sfp->hwmon_dev);
+ sfp->hwmon_dev = NULL;
+ kfree(sfp->hwmon_name);
+ }
+ }
++
++static int sfp_hwmon_init(struct sfp *sfp)
++{
++ INIT_DELAYED_WORK(&sfp->hwmon_probe, sfp_hwmon_probe);
++
++ return 0;
++}
++
++static void sfp_hwmon_exit(struct sfp *sfp)
++{
++ cancel_delayed_work_sync(&sfp->hwmon_probe);
++}
+ #else
+ static int sfp_hwmon_insert(struct sfp *sfp)
+ {
+@@ -1147,6 +1181,15 @@ static int sfp_hwmon_insert(struct sfp *
+ static void sfp_hwmon_remove(struct sfp *sfp)
+ {
+ }
++
++static int sfp_hwmon_init(struct sfp *sfp)
++{
++ return 0;
++}
++
++static void sfp_hwmon_exit(struct sfp *sfp)
++{
++}
+ #endif
+
+ /* Helpers */
+@@ -1483,10 +1526,6 @@ static int sfp_sm_mod_probe(struct sfp *
+ if (ret < 0)
+ return ret;
+
+- ret = sfp_hwmon_insert(sfp);
+- if (ret < 0)
+- return ret;
+-
+ return 0;
+ }
+
+@@ -1635,6 +1674,15 @@ static void sfp_sm_module(struct sfp *sf
+ case SFP_MOD_ERROR:
+ break;
+ }
++
++#if IS_ENABLED(CONFIG_HWMON)
++ if (sfp->sm_mod_state >= SFP_MOD_WAITDEV &&
++ IS_ERR_OR_NULL(sfp->hwmon_dev)) {
++ err = sfp_hwmon_insert(sfp);
++ if (err)
++ dev_warn(sfp->dev, "hwmon probe failed: %d\n", err);
++ }
++#endif
+ }
+
+ static void sfp_sm_main(struct sfp *sfp, unsigned int event)
+@@ -1936,6 +1984,8 @@ static struct sfp *sfp_alloc(struct devi
+ INIT_DELAYED_WORK(&sfp->poll, sfp_poll);
+ INIT_DELAYED_WORK(&sfp->timeout, sfp_timeout);
+
++ sfp_hwmon_init(sfp);
++
+ return sfp;
+ }
+
+@@ -1943,6 +1993,8 @@ static void sfp_cleanup(void *data)
+ {
+ struct sfp *sfp = data;
+
++ sfp_hwmon_exit(sfp);
++
+ cancel_delayed_work_sync(&sfp->poll);
+ cancel_delayed_work_sync(&sfp->timeout);
+ if (sfp->i2c_mii) {