Skip to contentSkip to conversation

amd-xgbe: fix MAC_AUTO_SW handling in CL37 AN

PATCH Applied Prashanth Kumar KR 3 participants 4 messages Jul 9 – Jul 21

Subsystems (4)
lore
Share & tools
lore

Prashanth Kumar KR

author maintainer
#0 lore raw

PATCH 1/1 amd-xgbe: fix MAC_AUTO_SW handling in CL37 AN

From: Prashanth Kumar KR <[email protected]>

MAC_AUTO_SW (VR_MII_DIG_CTRL1 bit 9) enables automatic XPCS speed mode switching after CL37 auto-negotiation and is only meaningful in SGMII MAC mode. The original code unconditionally set this bit on every call to xgbe_an37_set(), including when called from xgbe_an37_disable() with enable=false. This left MAC_AUTO_SW=1 after AN was disabled, causing the XPCS to autonomously switch speed from stale AN state during subsequent mode changes, breaking SGMII speed negotiation on 1G copper SFP modules.

---
 drivers/net/ethernet/amd/xgbe/xgbe-mdio.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c +8 -3
index fa0df6181207..12770af031eb 100644
@@ -267,9 +267,14 @@ static void xgbe_an37_set(struct xgbe_prv_data *pdata, bool enable,
 
 	XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_CTRL1, reg);
 
-	reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_PCS_DIG_CTRL);
-	reg |= XGBE_VEND2_MAC_AUTO_SW;
-	XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_PCS_DIG_CTRL, reg);
+	if (pdata->an_mode == XGBE_AN_MODE_CL37_SGMII) {
+		reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_PCS_DIG_CTRL);
+		if (enable)
+			reg |= XGBE_VEND2_MAC_AUTO_SW;
+		else
+			reg &= ~XGBE_VEND2_MAC_AUTO_SW;
+		XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_PCS_DIG_CTRL, reg);
+	}
 }
 
 static void xgbe_an37_restart(struct xgbe_prv_data *pdata)
Signature · 1 line
2.34.1
#1 lore raw

Hi Prashanth,

thank you for addressing the bug. I will test your patch on our hardware next week.

Quoted 11 lines · Prashanth Kumar KR

From: Prashanth Kumar KR <[email protected]>

MAC_AUTO_SW (VR_MII_DIG_CTRL1 bit 9) enables automatic XPCS speed mode switching after CL37 auto-negotiation and is only meaningful in SGMII MAC mode. The original code unconditionally set this bit on every call to xgbe_an37_set(), including when called from xgbe_an37_disable() with enable=false. This left MAC_AUTO_SW=1 after AN was disabled, causing the XPCS to autonomously switch speed from stale AN state during subsequent mode changes, breaking SGMII speed negotiation on 1G copper SFP modules.

In my testing this was breaking negotiation for all 1G SFP modules, not just copper modules.

Patrick

Quoted 33 lines
---
 drivers/net/ethernet/amd/xgbe/xgbe-mdio.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c +8 -4
index fa0df6181207..12770af031eb 100644
@@ -267,9 +267,14 @@ static void xgbe_an37_set(struct xgbe_prv_data *pdata, bool enable,
 
        XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_CTRL1, reg);
 
-       reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_PCS_DIG_CTRL);
-       reg |= XGBE_VEND2_MAC_AUTO_SW;
-       XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_PCS_DIG_CTRL, reg);
+       if (pdata->an_mode == XGBE_AN_MODE_CL37_SGMII) {
+               reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_PCS_DIG_CTRL);
+               if (enable)
+                       reg |= XGBE_VEND2_MAC_AUTO_SW;
+               else
+                       reg &= ~XGBE_VEND2_MAC_AUTO_SW;
+               XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_PCS_DIG_CTRL, reg);
+       }
 }
 
 static void xgbe_an37_restart(struct xgbe_prv_data *pdata)
--

2.34.1

#2 lore raw
Quoted 5 lines · Patrick Oppenlander

Hi Prashanth,

thank you for addressing the bug. I will test your patch on our hardware next week.

Tested working on 7.0.1 with your patch applied. Thank you.

Patrick

Quoted 14 lines
Quoted 11 lines · Prashanth Kumar KR

From: Prashanth Kumar KR <[email protected]>

MAC_AUTO_SW (VR_MII_DIG_CTRL1 bit 9) enables automatic XPCS speed mode switching after CL37 auto-negotiation and is only meaningful in SGMII MAC mode. The original code unconditionally set this bit on every call to xgbe_an37_set(), including when called from xgbe_an37_disable() with enable=false. This left MAC_AUTO_SW=1 after AN was disabled, causing the XPCS to autonomously switch speed from stale AN state during subsequent mode changes, breaking SGMII speed negotiation on 1G copper SFP modules.

Quoted 9 lines

In my testing this was breaking negotiation for all 1G SFP modules, not just copper modules.

Patrick

Quoted 4 lines
Quoted 29 lines
Quoted 29 lines
---
 drivers/net/ethernet/amd/xgbe/xgbe-mdio.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-mdio.c +8 -4
index fa0df6181207..12770af031eb 100644
@@ -267,9 +267,14 @@ static void xgbe_an37_set(struct xgbe_prv_data *pdata, bool enable,
 
        XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_CTRL1, reg);
 
-       reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_PCS_DIG_CTRL);
-       reg |= XGBE_VEND2_MAC_AUTO_SW;
-       XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_PCS_DIG_CTRL, reg);
+       if (pdata->an_mode == XGBE_AN_MODE_CL37_SGMII) {
+               reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_PCS_DIG_CTRL);
+               if (enable)
+                       reg |= XGBE_VEND2_MAC_AUTO_SW;
+               else
+                       reg &= ~XGBE_VEND2_MAC_AUTO_SW;
+               XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_PCS_DIG_CTRL, reg);
+       }
 }
 
 static void xgbe_an37_restart(struct xgbe_prv_data *pdata)
--

2.34.1

#3 lore raw
In reply to Prashanth Kumar KR
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Thu, 9 Jul 2026 15:20:06 +0530 you wrote:

From: Prashanth Kumar KR <[email protected]>

MAC_AUTO_SW (VR_MII_DIG_CTRL1 bit 9) enables automatic XPCS speed mode switching after CL37 auto-negotiation and is only meaningful in SGMII MAC mode. The original code unconditionally set this bit on every call to xgbe_an37_set(), including when called from xgbe_an37_disable() with enable=false. This left MAC_AUTO_SW=1 after AN was disabled, causing the XPCS to autonomously switch speed from stale AN state during subsequent mode changes, breaking SGMII speed negotiation on 1G copper SFP modules.

Quoted 1 line

[...]

Here is the summary with links:
- [net] amd-xgbe: fix MAC_AUTO_SW handling in CL37 AN

    https://git.kernel.org/netdev/net/c/4bf22afe53a1

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html