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

net: phy: fix duplex out of sync problem while changing settings

As reported by Zhang there's a small issue if in forced mode the duplex
mode changes with the link staying up [0]. In this case the MAC isn't
notified about the change.

The proposed patch relies on the phylib state machine and ignores the
fact that there are drivers that uses phylib but not the phylib state
machine. So let's don't change the behavior for such drivers and fix
it w/o re-adding state PHY_FORCING for the case that phylib state
machine is used.

[0] https://lore.kernel.org/netdev/a5c26ffd-4ee4-a5e6-4103-873208ce0dc5@huawei.com/T/

Fixes: 2bd229df5e2e ("net: phy: remove state PHY_FORCING")
Reported-by: Zhang Changzhong <zhangchangzhong@huawei.com>
Tested-by: Zhang Changzhong <zhangchangzhong@huawei.com>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/7b8b9456-a93f-abbc-1dc5-a2c2542f932c@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Heiner Kallweit and committed by
Jakub Kicinski
a4db9055 96d0c9be

+6 -1
+6 -1
drivers/net/phy/phy.c
··· 815 815 phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl; 816 816 817 817 /* Restart the PHY */ 818 - _phy_start_aneg(phydev); 818 + if (phy_is_started(phydev)) { 819 + phydev->state = PHY_UP; 820 + phy_trigger_machine(phydev); 821 + } else { 822 + _phy_start_aneg(phydev); 823 + } 819 824 820 825 mutex_unlock(&phydev->lock); 821 826 return 0;