kernel: backport phylink changes from mainline Linux
[openwrt/staging/wigyori.git] / target / linux / generic / backport-6.1 / 715-15-v6.4-net-phylink-fix-ksettings_set-ethtool-call.patch
1 From cc73de0411f7d3cdd157564a78f7a39058420ff8 Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
3 Date: Sat, 13 May 2023 22:03:45 +0100
4 Subject: [PATCH 13/21] net: phylink: fix ksettings_set() ethtool call
5
6 While testing a Fiberstore SFP-10G-T module (which uses 10GBASE-R with
7 rate adaption) in a Clearfog platform (which can't do that) it was
8 found that the PHYs advertisement was not limited according to the
9 hosts capabilities when using ethtool to change it.
10
11 Fix this by ensuring that we mask the advertisement with the computed
12 support mask as the very first thing we do.
13
14 Fixes: cbc1bb1e4689 ("net: phylink: simplify phy case for ksettings_set method")
15 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
16 Signed-off-by: David S. Miller <davem@davemloft.net>
17 ---
18 drivers/net/phy/phylink.c | 8 ++++----
19 1 file changed, 4 insertions(+), 4 deletions(-)
20
21 --- a/drivers/net/phy/phylink.c
22 +++ b/drivers/net/phy/phylink.c
23 @@ -2226,6 +2226,10 @@ int phylink_ethtool_ksettings_set(struct
24
25 ASSERT_RTNL();
26
27 + /* Mask out unsupported advertisements */
28 + linkmode_and(config.advertising, kset->link_modes.advertising,
29 + pl->supported);
30 +
31 if (pl->phydev) {
32 /* We can rely on phylib for this update; we also do not need
33 * to update the pl->link_config settings:
34 @@ -2250,10 +2254,6 @@ int phylink_ethtool_ksettings_set(struct
35
36 config = pl->link_config;
37
38 - /* Mask out unsupported advertisements */
39 - linkmode_and(config.advertising, kset->link_modes.advertising,
40 - pl->supported);
41 -
42 /* FIXME: should we reject autoneg if phy/mac does not support it? */
43 switch (kset->base.autoneg) {
44 case AUTONEG_DISABLE: