Skip to content

Commit f75abeb

Browse files
Russell Kingdavem330
authored andcommitted
net: phy: restart phy autonegotiation after EEE advertisment change
When the EEE advertisment is changed, we should restart autonegotiation to update the link partner with the new EEE settings. Add this trigger but only if the advertisment has changed. Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 83ea067 commit f75abeb

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

‎drivers/net/phy/phy.c‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ EXPORT_SYMBOL(phy_ethtool_get_eee);
13321332
*/
13331333
int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
13341334
{
1335-
int cap, adv;
1335+
int cap, old_adv, adv, ret;
13361336

13371337
if (!phydev->drv)
13381338
return -EIO;
@@ -1342,12 +1342,29 @@ int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
13421342
if (cap < 0)
13431343
return cap;
13441344

1345+
old_adv = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV);
1346+
if (old_adv < 0)
1347+
return old_adv;
1348+
13451349
adv = ethtool_adv_to_mmd_eee_adv_t(data->advertised) & cap;
13461350

13471351
/* Mask prohibited EEE modes */
13481352
adv &= ~phydev->eee_broken_modes;
13491353

1350-
return phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv);
1354+
if (old_adv != adv) {
1355+
ret = phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv);
1356+
if (ret < 0)
1357+
return ret;
1358+
1359+
/* Restart autonegotiation so the new modes get sent to the
1360+
* link partner.
1361+
*/
1362+
ret = genphy_restart_aneg(phydev);
1363+
if (ret < 0)
1364+
return ret;
1365+
}
1366+
1367+
return 0;
13511368
}
13521369
EXPORT_SYMBOL(phy_ethtool_set_eee);
13531370

0 commit comments

Comments
 (0)