diff mbox series

[net] net: phylink: actually fix ksettings_set() ethtool call

Message ID E1q4eC7-00AyAn-6d@rmk-PC.armlinux.org.uk (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net] net: phylink: actually fix ksettings_set() ethtool call | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 26 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Russell King (Oracle) June 1, 2023, 9:02 a.m. UTC
Raju Lakkaraju reported that the below commit caused a regression
with Lan743x drivers and a 2.5G SFP. Sadly, this is because the commit
was utterly wrong. Let's fix this properly by not moving the
linkmode_and(), but instead copying the link ksettings and then
modifying the advertising mask before passing the modified link
ksettings to phylib.

Fixes: df0acdc59b09 ("net: phylink: fix ksettings_set() ethtool call")
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/phy/phylink.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Comments

Russell King (Oracle) June 1, 2023, 9:05 a.m. UTC | #1
Please ignore this, wrong version of the patch. :/ More coffee needed.

On Thu, Jun 01, 2023 at 10:02:07AM +0100, Russell King (Oracle) wrote:
> Raju Lakkaraju reported that the below commit caused a regression
> with Lan743x drivers and a 2.5G SFP. Sadly, this is because the commit
> was utterly wrong. Let's fix this properly by not moving the
> linkmode_and(), but instead copying the link ksettings and then
> modifying the advertising mask before passing the modified link
> ksettings to phylib.
> 
> Fixes: df0acdc59b09 ("net: phylink: fix ksettings_set() ethtool call")
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
>  drivers/net/phy/phylink.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index e237949deee6..cf4e51e48cdd 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
> @@ -2225,11 +2225,13 @@ int phylink_ethtool_ksettings_set(struct phylink *pl,
>  
>  	ASSERT_RTNL();
>  
> -	/* Mask out unsupported advertisements */
> -	linkmode_and(config.advertising, kset->link_modes.advertising,
> -		     pl->supported);
> -
>  	if (pl->phydev) {
> +		struct ethtool_link_ksettings phy_kset = *kset;
> +
> +		linkmode_and(phy_kset.link_modes.advertising,
> +			     phy_kset.link_modes.advertising,
> +			     pl->supported);
> +
>  		/* We can rely on phylib for this update; we also do not need
>  		 * to update the pl->link_config settings:
>  		 * - the configuration returned via ksettings_get() will come
> @@ -2252,6 +2254,9 @@ int phylink_ethtool_ksettings_set(struct phylink *pl,
>  	}
>  
>  	config = pl->link_config;
> +	/* Mask out unsupported advertisements */
> +	linkmode_and(config.advertising, kset->link_modes.advertising,
> +		     pl->supported);
>  
>  	/* FIXME: should we reject autoneg if phy/mac does not support it? */
>  	switch (kset->base.autoneg) {
> -- 
> 2.30.2
> 
>
diff mbox series

Patch

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index e237949deee6..cf4e51e48cdd 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -2225,11 +2225,13 @@  int phylink_ethtool_ksettings_set(struct phylink *pl,
 
 	ASSERT_RTNL();
 
-	/* Mask out unsupported advertisements */
-	linkmode_and(config.advertising, kset->link_modes.advertising,
-		     pl->supported);
-
 	if (pl->phydev) {
+		struct ethtool_link_ksettings phy_kset = *kset;
+
+		linkmode_and(phy_kset.link_modes.advertising,
+			     phy_kset.link_modes.advertising,
+			     pl->supported);
+
 		/* We can rely on phylib for this update; we also do not need
 		 * to update the pl->link_config settings:
 		 * - the configuration returned via ksettings_get() will come
@@ -2252,6 +2254,9 @@  int phylink_ethtool_ksettings_set(struct phylink *pl,
 	}
 
 	config = pl->link_config;
+	/* Mask out unsupported advertisements */
+	linkmode_and(config.advertising, kset->link_modes.advertising,
+		     pl->supported);
 
 	/* FIXME: should we reject autoneg if phy/mac does not support it? */
 	switch (kset->base.autoneg) {