Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: phy: clear link parameters on admin link down

When a PHY is halted (e.g. `ip link set dev lan2 down`), several
fields in struct phy_device may still reflect the last active
connection. This leads to ethtool showing stale values even though
the link is down.

Reset selected fields in _phy_state_machine() when transitioning
to PHY_HALTED and the link was previously up:

- speed/duplex -> UNKNOWN, but only in autoneg mode (in forced mode
these fields carry configuration, not status)
- master_slave_state -> UNKNOWN if previously supported
- mdix -> INVALID (state only, same meaning as "unknown")
- lp_advertising -> always cleared

The cleanup is skipped if the PHY is in PHY_ERROR state, so the
last values remain available for diagnostics.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20250917094751.2101285-1-o.rempel@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Oleksij Rempel and committed by
Jakub Kicinski
60f887b1 97248adb

+13
+13
drivers/net/phy/phy.c
··· 1548 1548 } 1549 1549 break; 1550 1550 case PHY_HALTED: 1551 + if (phydev->link) { 1552 + if (phydev->autoneg == AUTONEG_ENABLE) { 1553 + phydev->speed = SPEED_UNKNOWN; 1554 + phydev->duplex = DUPLEX_UNKNOWN; 1555 + } 1556 + if (phydev->master_slave_state != 1557 + MASTER_SLAVE_STATE_UNSUPPORTED) 1558 + phydev->master_slave_state = 1559 + MASTER_SLAVE_STATE_UNKNOWN; 1560 + phydev->mdix = ETH_TP_MDI_INVALID; 1561 + linkmode_zero(phydev->lp_advertising); 1562 + } 1563 + fallthrough; 1551 1564 case PHY_ERROR: 1552 1565 if (phydev->link) { 1553 1566 phydev->link = 0;