1 From f81d97cb646ab8b90fb181d66fccaf9589990de6 Mon Sep 17 00:00:00 2001
2 From: Matthew Hagan <mnhagan88@gmail.com>
3 Date: Sat, 30 Apr 2022 11:00:49 +0100
4 Subject: [PATCH v2] net: sfp: Add tx-fault workaround for Huawei MA5671A SFP
7 As noted elsewhere, various GPON SFP modules exhibit non-standard
8 TX-fault behaviour. In the tested case, the Huawei MA5671A, when used
9 in combination with a Marvell mv88e6085 switch, was found to
10 persistently assert TX-fault, resulting in the module being disabled.
12 This patch adds a quirk to ignore the SFP_F_TX_FAULT state, allowing the
15 Change from v1: removal of erroneous return statment (Andrew Lunn)
17 Signed-off-by: Matthew Hagan <mnhagan88@gmail.com>
18 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
20 drivers/net/phy/sfp.c | 12 +++++++++++-
21 1 file changed, 11 insertions(+), 1 deletion(-)
23 --- a/drivers/net/phy/sfp.c
24 +++ b/drivers/net/phy/sfp.c
25 @@ -249,6 +249,7 @@ struct sfp {
26 struct sfp_eeprom_id id;
27 unsigned int module_power_mW;
28 unsigned int module_t_start_up;
29 + bool tx_fault_ignore;
31 #if IS_ENABLED(CONFIG_HWMON)
33 @@ -1893,6 +1894,12 @@ static int sfp_sm_mod_probe(struct sfp *
35 sfp->module_t_start_up = T_START_UP;
37 + if (!memcmp(id.base.vendor_name, "HUAWEI ", 16) &&
38 + !memcmp(id.base.vendor_pn, "MA5671A ", 16))
39 + sfp->tx_fault_ignore = true;
41 + sfp->tx_fault_ignore = false;
46 @@ -2320,7 +2327,10 @@ static void sfp_check_state(struct sfp *
47 mutex_lock(&sfp->st_mutex);
48 state = sfp_get_state(sfp);
49 changed = state ^ sfp->state;
50 - changed &= SFP_F_PRESENT | SFP_F_LOS | SFP_F_TX_FAULT;
51 + if (sfp->tx_fault_ignore)
52 + changed &= SFP_F_PRESENT | SFP_F_LOS;
54 + changed &= SFP_F_PRESENT | SFP_F_LOS | SFP_F_TX_FAULT;
56 for (i = 0; i < GPIO_MAX; i++)