x86: image: drop unused ROOTDELAY variable
[oweals/openwrt.git] / target / linux / mvebu / patches-4.9 / 403-net-phy-avoid-setting-unsupported-EEE-advertisments.patch
1 From: Russell King <rmk+kernel@armlinux.org.uk>
2 Date: Wed, 4 Jan 2017 21:00:51 +0000
3 Subject: [PATCH] net: phy: avoid setting unsupported EEE advertisments
4
5 We currently allow userspace to set any EEE advertisments it desires,
6 whether or not the PHY supports them.  For example:
7
8  # ethtool --set-eee eth1 advertise 0xffffffff
9  # ethtool --show-eee eth1
10  EEE Settings for eth1:
11         EEE status: disabled
12         Tx LPI: disabled
13         Supported EEE link modes:  100baseT/Full
14                                    1000baseT/Full
15                                    10000baseT/Full
16         Advertised EEE link modes:  100baseT/Full
17                                     1000baseT/Full
18                                     1000baseKX/Full
19                                     10000baseT/Full
20                                     10000baseKX4/Full
21                                     10000baseKR/Full
22
23 Clearly, this is not sane, we should only allow link modes that are
24 supported to be advertised (as we do elsewhere.)  Ensure that we mask
25 the MDIO_AN_EEE_ADV value with the capabilities retrieved from the
26 MDIO_PCS_EEE_ABLE register.
27
28 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
29 ---
30
31 --- a/drivers/net/phy/phy.c
32 +++ b/drivers/net/phy/phy.c
33 @@ -1307,11 +1307,16 @@ EXPORT_SYMBOL(phy_ethtool_get_eee);
34   */
35  int phy_ethtool_set_eee(struct phy_device *phydev, struct ethtool_eee *data)
36  {
37 -       int val = ethtool_adv_to_mmd_eee_adv_t(data->advertised);
38 +       int cap, adv;
39  
40 -       phy_write_mmd_indirect(phydev, MDIO_AN_EEE_ADV, MDIO_MMD_AN, val);
41 +       /* Get Supported EEE */
42 +       cap = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE);
43 +       if (cap < 0)
44 +               return cap;
45  
46 -       return 0;
47 +       adv = ethtool_adv_to_mmd_eee_adv_t(data->advertised) & cap;
48 +
49 +       return phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, adv);
50  }
51  EXPORT_SYMBOL(phy_ethtool_set_eee);
52