Skip to contentSkip to conversation

net: phy: skip EEE advertisement write when autoneg is disabled

PATCH Superseded Nerijus Bendžiūnas 2 participants 3 messages May 16

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: phy: skip EEE advertisement write when autoneg is disabled

genphy_c45_an_config_eee_aneg() writes the EEE advertisement to the auto-negotiation device's MMD register space (MDIO_MMD_AN, register MDIO_AN_EEE_ADV). These registers are only consumed by the link partner during auto-negotiation, so writing them while autoneg is disabled is semantically a no-op.

On at least the Broadcom BCM54213PE PHY, however, the indirect MMD write triggered from this path while the link is currently forced (autoneg off) disturbs the receive datapath: the kernel still reports the link as UP at the configured speed/duplex, but no frames are received until the link is renegotiated. Concretely, running

ethtool -s eth0 speed 100 duplex full autoneg off ethtool --set-eee eth0 eee off

leaves eth0 with TX working and RX completely silent on a Raspberry Pi 4 / CM4 board (bcmgenet + BCM54213PE in rgmii-rxid). Switching back to autoneg recovers the link.

Prior to commit f26a29a038ee ("net: phy: ensure that genphy_c45_an_config_eee_aneg() sees new value of phydev->eee_cfg.eee_enabled"), the disable path was effectively a no-op because the helper read
the stale eee_cfg.eee_enabled, so the underlying PHY behavior never
surfaced.

Bisected on rpi-6.12.y between commits 83943264 (good) and effcbc88 (bad) to f26a29a038ee.

Fixes f26a29a038ee ("net: phy: ensure that genphy_c45_an_config_eee_aneg() sees new value of phydev->eee_cfg.eee_enabled")
---
 drivers/net/phy/phy-c45.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/phy/phy-c45.c +4 -0
index d48aa7231b37..65de6a5fa204 100644
@@ -940,6 +940,10 @@ EXPORT_SYMBOL_GPL(genphy_c45_read_eee_abilities);
  */
 int genphy_c45_an_config_eee_aneg(struct phy_device *phydev)
 {
+	/* MMD AN advertisements are only consumed during autoneg. */
+	if (phydev->autoneg == AUTONEG_DISABLE)
+		return 0;
+
 	if (!phydev->eee_cfg.eee_enabled) {
 		__ETHTOOL_DECLARE_LINK_MODE_MASK(adv) = {};
 
Signature · 1 line
2.54.0
maintainer
#1 lore raw

drivers/net/phy/phy-c45.c EXPORT_SYMBOL_GPL(genphy_c45_read_eee_abilities); · line 945

Quoted 8 lines

On at least the Broadcom BCM54213PE PHY, however, the indirect MMD write triggered from this path while the link is currently forced (autoneg off) disturbs the receive datapath

drivers/net/phy/phy-c45.c +3 -0
+	/* MMD AN advertisements are only consumed during autoneg. */
+	if (phydev->autoneg == AUTONEG_DISABLE)
+		return 0;

You are not adding this condition because it is not consumed, but because it is consumed and then bad things happen. Please could you make the comment accurate.

Andrew

---
pw-bot: cr

#2 lore raw

PATCH v2 1/1 net: phy: skip EEE advertisement write when autoneg is disabled

In reply to Nerijus Bendžiūnas

genphy_c45_an_config_eee_aneg() writes the EEE advertisement to the auto-negotiation device's MMD register space (MDIO_MMD_AN, register MDIO_AN_EEE_ADV). These registers are read by the link partner only during auto-negotiation, so writing them while autoneg is disabled cannot influence the link. On some PHYs (e.g. Broadcom BCM54213PE) the write nevertheless reaches the chip and disturbs the receive datapath.

Concretely, running

ethtool -s eth0 speed 100 duplex full autoneg off ethtool --set-eee eth0 eee off

leaves eth0 with TX working and RX completely silent on a Raspberry Pi 4 / CM4 board (bcmgenet + BCM54213PE in rgmii-rxid). Switching back to autoneg recovers the link.

Prior to commit f26a29a038ee ("net: phy: ensure that genphy_c45_an_config_eee_aneg() sees new value of phydev->eee_cfg.eee_enabled"), the disable path was effectively a no-op because the helper read
the stale eee_cfg.eee_enabled, so the underlying PHY behavior never
surfaced.

Bisected on rpi-6.12.y between commits 83943264 (good) and effcbc88 (bad) to f26a29a038ee.

Fixes f26a29a038ee ("net: phy: ensure that genphy_c45_an_config_eee_aneg() sees new value of phydev->eee_cfg.eee_enabled")

---
Changes since v1:
- Reworded the inline comment and commit message: the MMD AN write is read by the chip with side-effects, not silently ignored. Suggested by Andrew Lunn.
- Tightened the reproducer paragraph (was repeating paragraph 1).

v1: https://lore.kernel.org/netdev/[email protected]/

 drivers/net/phy/phy-c45.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/phy/phy-c45.c +8 -0
index d48aa7231b37..126951741428 100644
@@ -940,6 +940,14 @@ EXPORT_SYMBOL_GPL(genphy_c45_read_eee_abilities);
  */
 int genphy_c45_an_config_eee_aneg(struct phy_device *phydev)
 {
+	/* Writing MMD AN advertisements while autoneg is disabled has no
+	 * effect on link-partner negotiation, but on some PHYs (e.g. the
+	 * Broadcom BCM54213PE) the write itself disturbs the receive
+	 * datapath. Skip it.
+	 */
+	if (phydev->autoneg == AUTONEG_DISABLE)
+		return 0;
+
 	if (!phydev->eee_cfg.eee_enabled) {
 		__ETHTOOL_DECLARE_LINK_MODE_MASK(adv) = {};
 
Signature · 1 line
2.54.0