linux/drivers/net/pcs
Coia Prant def9a4745e net: pcs: xpcs: fix SGMII state reading
Commit 2a22b7ae2f ("net: pcs: xpcs: adapt Wangxun NICs for SGMII mode")
added a path in xpcs_get_state_c37_sgmii() that reads speed/duplex from
BMCR after AN completes. However, BMCR does not reflect the negotiated
result on the hardware where this has been tested:

- On RK3568 (MAC side SGMII), BMCR returns a fixed hardware reset value
- Wangxun engineer Jiawen Wu confirmed that on their side, "BMCR looks
  like it only wants to be return as 0" [0]

The correct information is available in CL37_ANSGM_STS, which contains
the actual link status and negotiated speed/duplex.

This bug was previously masked by phylink core, which overrides the PCS
link state with the PHY state when a PHY is present:

        /* If we have a phy, the "up" state is the union of both the
         * PHY and the MAC
         */
        if (phy)
                link_state.link &= pl->phy_state.link;

Thus, when the link is down, the PHY's link_down state is applied on top
of whatever the PCS reports, hiding the broken PCS state reading path.

Modify xpcs_get_state_c37_sgmii() to:
1. Read link state from CL37_ANSGM_STS
2. If link is up, report speed/duplex from CL37_ANSGM_STS
3. Remove the broken BMCR reading path entirely

Also properly set state->an_complete to reflect the AN completion status,
and clear CL37_ANCMPLT_INTR when link is down to avoid stale state.

[0] https://lore.kernel.org/all/000c01dd1593$2ac0b0f0$804212d0$@trustnetic.com/

Fixes: 2a22b7ae2f ("net: pcs: xpcs: adapt Wangxun NICs for SGMII mode")
Cc: stable@vger.kernel.org
Tested-by: Jiawen Wu <jiawenwu@trustnetic.com>
Signed-off-by: Coia Prant <coiaprant@gmail.com>
Tested-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/20260717074324.3250043-2-coiaprant@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-07-23 08:22:21 -07:00
..
Kconfig net: pcs: pcs-mtk-lynxi: deprecate "mediatek,pnswap" 2026-01-21 19:46:59 -08:00
Makefile
pcs-lynx.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
pcs-mtk-lynxi.c net: pcs: pcs-mtk-lynxi: fix bpi-r3 serdes configuration 2026-05-28 18:09:03 -07:00
pcs-rzn1-miic.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
pcs-xpcs-nxp.c
pcs-xpcs-plat.c driver core: Replace dev->of_node_reused with dev_of_node_reused() 2026-04-26 23:50:20 +02:00
pcs-xpcs-wx.c
pcs-xpcs.c net: pcs: xpcs: fix SGMII state reading 2026-07-23 08:22:21 -07:00
pcs-xpcs.h net: xpcs: rearrange register definitions 2025-02-17 15:37:27 -08:00