forked from Openwrt-EcoNet/openwrt
Changelog: https://cdn.kernel.org/pub/linux/kernel/v6.x/ChangeLog-6.6.88 Manually rebased: - bcm27xx/patches-6.6/950-0327-media-i2c-ov7251-Make-the-enable-GPIO-optional.patch[1] - bcm27xx/patches-6.6/950-0521-PCI-brcmstb-Add-BCM2712-support.patch[2] - generic/hack-6.6/610-net-page_pool-try-to-free-deferred-skbs-while-waitin.patch[3] - generic/pending-6.6/734-net-ethernet-mediatek-enlarge-DMA-reserve-buffer.patch[4] All other patches automatically rebased. 1. https://web.git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.6.88&id=f249c05416ea0bef24c9dbed0e653d2fad87b127 2. https://web.git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.6.88&id=1fea7726276e5d6526ecd4e7ccb4c91a6135deb5 3. https://web.git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.6.88&id=95f17738b86fd198924d874a5639bcdc49c7e5b8 4. https://web.git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.6.88&id=a2874f0dff63829d1f540003e2d83adb610ee64a Signed-off-by: Mieczyslaw Nalewaj <namiltd@yahoo.com> Link: https://github.com/openwrt/openwrt/pull/18607 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
135 lines
4.3 KiB
Diff
135 lines
4.3 KiB
Diff
From 2f3ce7a56c6e02bc0b258507f3a82b7511f62f9e Mon Sep 17 00:00:00 2001
|
|
From: Marek Behún <kabel@kernel.org>
|
|
Date: Tue, 21 Nov 2023 18:20:24 +0100
|
|
Subject: net: sfp: rework the RollBall PHY waiting code
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
RollBall SFP modules allow the access to PHY registers only after a
|
|
certain time has passed. Until then, the registers read 0xffff.
|
|
|
|
Currently we have quirks for modules where we need to wait either 25
|
|
seconds or 4 seconds, but recently I got hands on another module where
|
|
the wait is even shorter.
|
|
|
|
Instead of hardcoding different wait times, lets rework the code:
|
|
- increase the PHY retry count to 25
|
|
- when RollBall module is detected, increase the PHY retry time from
|
|
50ms to 1s
|
|
|
|
Signed-off-by: Marek Behún <kabel@kernel.org>
|
|
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
---
|
|
drivers/net/phy/sfp.c | 41 +++++++++++++++++++++--------------------
|
|
1 file changed, 21 insertions(+), 20 deletions(-)
|
|
|
|
--- a/drivers/net/phy/sfp.c
|
|
+++ b/drivers/net/phy/sfp.c
|
|
@@ -191,7 +191,7 @@ static const enum gpiod_flags gpio_flags
|
|
* R_PHY_RETRY is the number of attempts.
|
|
*/
|
|
#define T_PHY_RETRY msecs_to_jiffies(50)
|
|
-#define R_PHY_RETRY 12
|
|
+#define R_PHY_RETRY 25
|
|
|
|
/* SFP module presence detection is poor: the three MOD DEF signals are
|
|
* the same length on the PCB, which means it's possible for MOD DEF 0 to
|
|
@@ -274,7 +274,7 @@ struct sfp {
|
|
struct sfp_eeprom_id id;
|
|
unsigned int module_power_mW;
|
|
unsigned int module_t_start_up;
|
|
- unsigned int module_t_wait;
|
|
+ unsigned int phy_t_retry;
|
|
|
|
unsigned int rate_kbd;
|
|
unsigned int rs_threshold_kbd;
|
|
@@ -357,18 +357,22 @@ static void sfp_fixup_10gbaset_30m(struc
|
|
sfp->id.base.extended_cc = SFF8024_ECC_10GBASE_T_SR;
|
|
}
|
|
|
|
-static void sfp_fixup_rollball_proto(struct sfp *sfp, unsigned int secs)
|
|
+static void sfp_fixup_rollball(struct sfp *sfp)
|
|
{
|
|
sfp->mdio_protocol = MDIO_I2C_ROLLBALL;
|
|
- sfp->module_t_wait = msecs_to_jiffies(secs * 1000);
|
|
+
|
|
+ /* RollBall modules may disallow access to PHY registers for up to 25
|
|
+ * seconds, and the reads return 0xffff before that. Increase the time
|
|
+ * between PHY probe retries from 50ms to 1s so that we will wait for
|
|
+ * the PHY for a sufficient amount of time.
|
|
+ */
|
|
+ sfp->phy_t_retry = msecs_to_jiffies(1000);
|
|
}
|
|
|
|
static void sfp_fixup_fs_10gt(struct sfp *sfp)
|
|
{
|
|
sfp_fixup_10gbaset_30m(sfp);
|
|
-
|
|
- // These SFPs need 4 seconds before the PHY can be accessed
|
|
- sfp_fixup_rollball_proto(sfp, 4);
|
|
+ sfp_fixup_rollball(sfp);
|
|
}
|
|
|
|
static void sfp_fixup_halny_gsfp(struct sfp *sfp)
|
|
@@ -380,12 +384,6 @@ static void sfp_fixup_halny_gsfp(struct
|
|
sfp->state_hw_mask &= ~(SFP_F_TX_FAULT | SFP_F_LOS);
|
|
}
|
|
|
|
-static void sfp_fixup_rollball(struct sfp *sfp)
|
|
-{
|
|
- // Rollball SFPs need 25 seconds before the PHY can be accessed
|
|
- sfp_fixup_rollball_proto(sfp, 25);
|
|
-}
|
|
-
|
|
static void sfp_fixup_rollball_cc(struct sfp *sfp)
|
|
{
|
|
sfp_fixup_rollball(sfp);
|
|
@@ -2322,7 +2320,7 @@ static int sfp_sm_mod_probe(struct sfp *
|
|
mask |= SFP_F_RS1;
|
|
|
|
sfp->module_t_start_up = T_START_UP;
|
|
- sfp->module_t_wait = T_WAIT;
|
|
+ sfp->phy_t_retry = T_PHY_RETRY;
|
|
|
|
sfp->state_ignore_mask = 0;
|
|
|
|
@@ -2558,10 +2556,9 @@ static void sfp_sm_main(struct sfp *sfp,
|
|
|
|
/* We need to check the TX_FAULT state, which is not defined
|
|
* while TX_DISABLE is asserted. The earliest we want to do
|
|
- * anything (such as probe for a PHY) is 50ms (or more on
|
|
- * specific modules).
|
|
+ * anything (such as probe for a PHY) is 50ms.
|
|
*/
|
|
- sfp_sm_next(sfp, SFP_S_WAIT, sfp->module_t_wait);
|
|
+ sfp_sm_next(sfp, SFP_S_WAIT, T_WAIT);
|
|
break;
|
|
|
|
case SFP_S_WAIT:
|
|
@@ -2575,8 +2572,8 @@ static void sfp_sm_main(struct sfp *sfp,
|
|
* deasserting.
|
|
*/
|
|
timeout = sfp->module_t_start_up;
|
|
- if (timeout > sfp->module_t_wait)
|
|
- timeout -= sfp->module_t_wait;
|
|
+ if (timeout > T_WAIT)
|
|
+ timeout -= T_WAIT;
|
|
else
|
|
timeout = 1;
|
|
|
|
@@ -2619,7 +2616,11 @@ static void sfp_sm_main(struct sfp *sfp,
|
|
ret = sfp_sm_probe_for_phy(sfp);
|
|
if (ret == -ENODEV) {
|
|
if (--sfp->sm_phy_retries) {
|
|
- sfp_sm_next(sfp, SFP_S_INIT_PHY, T_PHY_RETRY);
|
|
+ sfp_sm_next(sfp, SFP_S_INIT_PHY,
|
|
+ sfp->phy_t_retry);
|
|
+ dev_dbg(sfp->dev,
|
|
+ "no PHY detected, %u tries left\n",
|
|
+ sfp->sm_phy_retries);
|
|
break;
|
|
} else {
|
|
dev_info(sfp->dev, "no PHY detected\n");
|