1 From e9301af385e7864dea353f5e58cad7339dd6c718 Mon Sep 17 00:00:00 2001
2 From: Marek BehĂșn <kabel@kernel.org>
3 Date: Tue, 19 Dec 2023 17:24:15 +0100
4 Subject: net: sfp: fix PHY discovery for FS SFP-10G-T module
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Commit 2f3ce7a56c6e ("net: sfp: rework the RollBall PHY waiting code")
10 changed the long wait before accessing RollBall / FS modules into
11 probing for PHY every 1 second, and trying 25 times.
13 Wei Lei reports that this does not work correctly on FS modules: when
14 initializing, they may report values different from 0xffff in PHY ID
15 registers for some MMDs, causing get_phy_c45_ids() to find some bogus
18 Fix this by adding the module_t_wait member back, and setting it to 4
19 seconds for FS modules.
21 Fixes: 2f3ce7a56c6e ("net: sfp: rework the RollBall PHY waiting code")
22 Reported-by: Wei Lei <quic_leiwei@quicinc.com>
23 Signed-off-by: Marek BehĂșn <kabel@kernel.org>
24 Tested-by: Lei Wei <quic_leiwei@quicinc.com>
25 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
26 Signed-off-by: David S. Miller <davem@davemloft.net>
28 drivers/net/phy/sfp.c | 17 +++++++++++++----
29 1 file changed, 13 insertions(+), 4 deletions(-)
31 --- a/drivers/net/phy/sfp.c
32 +++ b/drivers/net/phy/sfp.c
33 @@ -273,6 +273,7 @@ struct sfp {
34 struct sfp_eeprom_id id;
35 unsigned int module_power_mW;
36 unsigned int module_t_start_up;
37 + unsigned int module_t_wait;
38 unsigned int phy_t_retry;
40 unsigned int rate_kbd;
41 @@ -373,6 +374,12 @@ static void sfp_fixup_fs_10gt(struct sfp
43 sfp_fixup_10gbaset_30m(sfp);
44 sfp_fixup_rollball(sfp);
46 + /* The RollBall fixup is not enough for FS modules, the AQR chip inside
47 + * them does not return 0xffff for PHY ID registers in all MMDs for the
48 + * while initializing. They need a 4 second wait before accessing PHY.
50 + sfp->module_t_wait = msecs_to_jiffies(4000);
53 static void sfp_fixup_halny_gsfp(struct sfp *sfp)
54 @@ -2317,6 +2324,7 @@ static int sfp_sm_mod_probe(struct sfp *
57 sfp->module_t_start_up = T_START_UP;
58 + sfp->module_t_wait = T_WAIT;
59 sfp->phy_t_retry = T_PHY_RETRY;
61 sfp->tx_fault_ignore = false;
62 @@ -2551,9 +2559,10 @@ static void sfp_sm_main(struct sfp *sfp,
64 /* We need to check the TX_FAULT state, which is not defined
65 * while TX_DISABLE is asserted. The earliest we want to do
66 - * anything (such as probe for a PHY) is 50ms.
67 + * anything (such as probe for a PHY) is 50ms (or more on
68 + * specific modules).
70 - sfp_sm_next(sfp, SFP_S_WAIT, T_WAIT);
71 + sfp_sm_next(sfp, SFP_S_WAIT, sfp->module_t_wait);
75 @@ -2567,8 +2576,8 @@ static void sfp_sm_main(struct sfp *sfp,
78 timeout = sfp->module_t_start_up;
79 - if (timeout > T_WAIT)
81 + if (timeout > sfp->module_t_wait)
82 + timeout -= sfp->module_t_wait;