<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From 7cc39a6bedbd85f3ff7e16845f310e4ce8d9833f Mon Sep 17 00:00:00 2001
From: Daniel Golle &lt;daniel@makrotopia.org&gt;
Date: Tue, 6 Sep 2022 00:31:19 +0100
Subject: [PATCH] net: sfp: add quirk for ATS SFP-GE-T 1000Base-TX module
To: netdev@vger.kernel.org,
    linux-kernel@vger.kernel.org,
    Russell King &lt;linux@armlinux.org.uk&gt;,
    Andrew Lunn &lt;andrew@lunn.ch&gt;,
    Heiner Kallweit &lt;hkallweit1@gmail.com&gt;
Cc: David S. Miller &lt;davem@davemloft.net&gt;,
    Eric Dumazet &lt;edumazet@google.com&gt;,
    Jakub Kicinski &lt;kuba@kernel.org&gt;,
    Paolo Abeni &lt;pabeni@redhat.com&gt;,
    Josef Schlehofer &lt;pepe.schlehofer@gmail.com&gt;

This copper module comes with broken TX_FAULT indicator which must be
ignored for it to work. Implement ignoring TX_FAULT state bit also
during reset/insertion and mute the warning telling the user that the
module indicates TX_FAULT.

Co-authored-by: Josef Schlehofer &lt;pepe.schlehofer@gmail.com&gt;
Signed-off-by: Daniel Golle &lt;daniel@makrotopia.org&gt;
---
 drivers/net/phy/sfp.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -471,6 +471,9 @@ static const struct sfp_quirk sfp_quirks
 	// FS 2.5G Base-T
 	SFP_QUIRK_M("FS", "SFP-2.5G-T", sfp_quirk_oem_2_5g),
 
+	// OEM SFP-GE-T is 1000Base-T module
+	SFP_QUIRK_F("OEM", "SFP-GE-T", sfp_fixup_ignore_tx_fault),
+
 	// Lantech 8330-262D-E can operate at 2500base-X, but incorrectly report
 	// 2500MBd NRZ in their EEPROM
 	SFP_QUIRK_M("Lantech", "8330-262D-E", sfp_quirk_2500basex),
@@ -2587,7 +2590,8 @@ static void sfp_sm_main(struct sfp *sfp,
 			 * or t_start_up, so assume there is a fault.
 			 */
 			sfp_sm_fault(sfp, SFP_S_INIT_TX_FAULT,
-				     sfp-&gt;sm_fault_retries == N_FAULT_INIT);
+				     !sfp-&gt;tx_fault_ignore &amp;&amp;
+				     (sfp-&gt;sm_fault_retries == N_FAULT_INIT));
 		} else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) {
 	init_done:
 			/* Create mdiobus and start trying for PHY */
@@ -2841,10 +2845,12 @@ static void sfp_check_state(struct sfp *
 	mutex_lock(&amp;sfp-&gt;st_mutex);
 	state = sfp_get_state(sfp);
 	changed = state ^ sfp-&gt;state;
-	if (sfp-&gt;tx_fault_ignore)
+	if (sfp-&gt;tx_fault_ignore) {
 		changed &amp;= SFP_F_PRESENT | SFP_F_LOS;
-	else
+		state &amp;= ~SFP_F_TX_FAULT;
+	} else {
 		changed &amp;= SFP_F_PRESENT | SFP_F_LOS | SFP_F_TX_FAULT;
+	}
 
 	for (i = 0; i &lt; GPIO_MAX; i++)
 		if (changed &amp; BIT(i))
</pre></body></html>