kernel: copy kernel 4.19 code to 5.4
[openwrt/openwrt.git] / target / linux / generic / backport-5.4 / 713-v5.2-net-phylink-avoid-reducing-support-mask.patch
1 From 8ac1d3e5cf7d277769ba3403d99f643fab1e3fae Mon Sep 17 00:00:00 2001
2 From: Russell King <rmk+kernel@armlinux.org.uk>
3 Date: Sat, 23 Nov 2019 14:19:54 +0000
4 Subject: [PATCH 611/660] net: phylink: avoid reducing support mask
5
6 Avoid reducing the support mask as a result of the interface type
7 selected for SFP modules, or when setting the link settings through
8 ethtool - this should only change when the supported link modes of
9 the hardware combination change.
10
11 Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
12 Signed-off-by: David S. Miller <davem@davemloft.net>
13 ---
14 drivers/net/phy/phylink.c | 13 +++++++++----
15 1 file changed, 9 insertions(+), 4 deletions(-)
16
17 --- a/drivers/net/phy/phylink.c
18 +++ b/drivers/net/phy/phylink.c
19 @@ -1137,6 +1137,7 @@ EXPORT_SYMBOL_GPL(phylink_ethtool_ksetti
20 int phylink_ethtool_ksettings_set(struct phylink *pl,
21 const struct ethtool_link_ksettings *kset)
22 {
23 + __ETHTOOL_DECLARE_LINK_MODE_MASK(support);
24 struct ethtool_link_ksettings our_kset;
25 struct phylink_link_state config;
26 int ret;
27 @@ -1147,11 +1148,12 @@ int phylink_ethtool_ksettings_set(struct
28 kset->base.autoneg != AUTONEG_ENABLE)
29 return -EINVAL;
30
31 + linkmode_copy(support, pl->supported);
32 config = pl->link_config;
33
34 /* Mask out unsupported advertisements */
35 linkmode_and(config.advertising, kset->link_modes.advertising,
36 - pl->supported);
37 + support);
38
39 /* FIXME: should we reject autoneg if phy/mac does not support it? */
40 if (kset->base.autoneg == AUTONEG_DISABLE) {
41 @@ -1161,7 +1163,7 @@ int phylink_ethtool_ksettings_set(struct
42 * duplex.
43 */
44 s = phy_lookup_setting(kset->base.speed, kset->base.duplex,
45 - pl->supported,
46 + support,
47 __ETHTOOL_LINK_MODE_MASK_NBITS, false);
48 if (!s)
49 return -EINVAL;
50 @@ -1191,7 +1193,7 @@ int phylink_ethtool_ksettings_set(struct
51 __set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, config.advertising);
52 }
53
54 - if (phylink_validate(pl, pl->supported, &config))
55 + if (phylink_validate(pl, support, &config))
56 return -EINVAL;
57
58 /* If autonegotiation is enabled, we must have an advertisement */
59 @@ -1633,6 +1635,7 @@ static int phylink_sfp_module_insert(voi
60 {
61 struct phylink *pl = upstream;
62 __ETHTOOL_DECLARE_LINK_MODE_MASK(support) = { 0, };
63 + __ETHTOOL_DECLARE_LINK_MODE_MASK(support1);
64 struct phylink_link_state config;
65 phy_interface_t iface;
66 int ret = 0;
67 @@ -1660,6 +1663,8 @@ static int phylink_sfp_module_insert(voi
68 return ret;
69 }
70
71 + linkmode_copy(support1, support);
72 +
73 iface = sfp_select_interface(pl->sfp_bus, id, config.advertising);
74 if (iface == PHY_INTERFACE_MODE_NA) {
75 netdev_err(pl->netdev,
76 @@ -1669,7 +1674,7 @@ static int phylink_sfp_module_insert(voi
77 }
78
79 config.interface = iface;
80 - ret = phylink_validate(pl, support, &config);
81 + ret = phylink_validate(pl, support1, &config);
82 if (ret) {
83 netdev_err(pl->netdev, "validation of %s/%s with support %*pb failed: %d\n",
84 phylink_an_mode_str(MLO_AN_INBAND),