Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit acf0610a authored by Guangbin Huang's avatar Guangbin Huang Committed by Greg Kroah-Hartman
Browse files

net: phy: fix save wrong speed and duplex problem if autoneg is on



[ Upstream commit d9032dba5a2b2bbf0fdce67c8795300ec9923b43 ]

If phy uses generic driver and autoneg is on, enter command
"ethtool -s eth0 speed 50" will not change phy speed actually, but
command "ethtool eth0" shows speed is 50Mb/s because phydev->speed
has been set to 50 and no update later.

And duplex setting has same problem too.

However, if autoneg is on, phy only changes speed and duplex according to
phydev->advertising, but not phydev->speed and phydev->duplex. So in this
case, phydev->speed and phydev->duplex don't need to be set in function
phy_ethtool_ksettings_set() if autoneg is on.

Fixes: 51e2a384 ("PHY: Avoid unnecessary aneg restarts")
Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 6264d03c
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -335,7 +335,10 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev,

	phydev->autoneg = autoneg;

	if (autoneg == AUTONEG_DISABLE) {
		phydev->speed = speed;
		phydev->duplex = duplex;
	}

	phydev->advertising = advertising;

@@ -344,8 +347,6 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev,
	else
		phydev->advertising &= ~ADVERTISED_Autoneg;

	phydev->duplex = duplex;

	phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl;

	/* Restart the PHY */