[PATCH net] net: phy: Keep PHY timing role
From: Tobias Güntner
Date: Thu Jul 23 2026 - 07:19:58 EST
Some tools leave master_slave_cfg at its default value (0 or
MASTER_SLAVE_CFG_UNSUPPORTED). Depending on the PHY and its driver,
a PHY may fall back to its default (bootstrap) timing role, which
can prevent it from establishing a link.
For example, consider a system with an Automotive Ethernet PHY DP83TG720.
Let's assume that the PHY timing role is bootstrapped to "slave" mode,
but was changed to "master" mode via ethtool or device tree overlay.
Assume further that the timing role of the other peer is "slave" mode.
When trying to (re-)establish a link (e.g., after unplugging the cable),
management services (such as NetworkManager) may change auto-negotiation
settings and inadvertently reset the timing role if this setting is
unsupported. Now both peers have the same "slave" timing role and cannot
establish a link again until the timing role is changed back to "master"
on one side.
Keeping the most recently assigned timing role avoids this problem.
Signed-off-by: Tobias Güntner <guentner@xxxxxxxxxxxxxxxxx>
---
drivers/net/phy/phy.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index b6fae9299b36..daff4f6827e4 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -1200,7 +1200,9 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev,
linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
phydev->advertising, autoneg == AUTONEG_ENABLE);
- phydev->master_slave_set = cmd->base.master_slave_cfg;
+ if (cmd->base.master_slave_cfg != MASTER_SLAVE_CFG_UNSUPPORTED)
+ phydev->master_slave_set = cmd->base.master_slave_cfg;
+
phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl;
/* Restart the PHY */
--
2.53.0