kernel: update kernel 4.9 to 4.9.17
[openwrt/openwrt.git] / target / linux / mvebu / patches-4.9 / 404-net-phy-restart-phy-autonegotiation-after-EEE-advert.patch
1 From: Russell King <rmk+kernel@armlinux.org.uk>
2 Date: Thu, 5 Jan 2017 12:21:09 +0000
3 Subject: [PATCH] net: phy: restart phy autonegotiation after EEE
4 advertisment change
5
6 When the EEE advertisment is changed, we should restart autonegotiation
7 to update the link partner with the new EEE settings. Add this trigger
8 but only if the advertisment has changed.
9
10 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
11 ---
12
13 --- a/drivers/net/phy/phy.c
14 +++ b/drivers/net/phy/phy.c
15 @@ -1311,16 +1311,33 @@ EXPORT_SYMBOL(phy_ethtool_get_eee);
16 */
17 int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
18 {
19 - int cap, adv;
20 + int cap, old_adv, adv, ret;
21
22 /* Get Supported EEE */
23 cap = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
24 if (cap < 0)
25 return cap;
26
27 + old_adv = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV);
28 + if (old_adv < 0)
29 + return old_adv;
30 +
31 adv = ethtool_adv_to_mmd_eee_adv_t(data->advertised) & cap;
32
33 - return phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv);
34 + if (old_adv != adv) {
35 + ret = phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv);
36 + if (ret < 0)
37 + return ret;
38 +
39 + /* Restart autonegotiation so the new modes get sent to the
40 + * link partner.
41 + */
42 + ret = phy_restart_aneg(phydev);
43 + if (ret < 0)
44 + return ret;
45 + }
46 +
47 + return 0;
48 }
49 EXPORT_SYMBOL(phy_ethtool_set_eee);
50