715-23-v6.4-net-phylink-actually-fix-ksettings_set-ethtool-call.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. From 11933aa76865621d8e82553c8f3bc07796a5aaa2 Mon Sep 17 00:00:00 2001
  2. From: "Russell King (Oracle)" <[email protected]>
  3. Date: Thu, 1 Jun 2023 10:12:06 +0100
  4. Subject: [PATCH 20/21] net: phylink: actually fix ksettings_set() ethtool call
  5. Raju Lakkaraju reported that the below commit caused a regression
  6. with Lan743x drivers and a 2.5G SFP. Sadly, this is because the commit
  7. was utterly wrong. Let's fix this properly by not moving the
  8. linkmode_and(), but instead copying the link ksettings and then
  9. modifying the advertising mask before passing the modified link
  10. ksettings to phylib.
  11. Fixes: df0acdc59b09 ("net: phylink: fix ksettings_set() ethtool call")
  12. Signed-off-by: Russell King (Oracle) <[email protected]>
  13. Link: https://lore.kernel.org/r/[email protected]
  14. Signed-off-by: Jakub Kicinski <[email protected]>
  15. ---
  16. drivers/net/phy/phylink.c | 15 ++++++++++-----
  17. 1 file changed, 10 insertions(+), 5 deletions(-)
  18. --- a/drivers/net/phy/phylink.c
  19. +++ b/drivers/net/phy/phylink.c
  20. @@ -2259,11 +2259,13 @@ int phylink_ethtool_ksettings_set(struct
  21. ASSERT_RTNL();
  22. - /* Mask out unsupported advertisements */
  23. - linkmode_and(config.advertising, kset->link_modes.advertising,
  24. - pl->supported);
  25. -
  26. if (pl->phydev) {
  27. + struct ethtool_link_ksettings phy_kset = *kset;
  28. +
  29. + linkmode_and(phy_kset.link_modes.advertising,
  30. + phy_kset.link_modes.advertising,
  31. + pl->supported);
  32. +
  33. /* We can rely on phylib for this update; we also do not need
  34. * to update the pl->link_config settings:
  35. * - the configuration returned via ksettings_get() will come
  36. @@ -2282,10 +2284,13 @@ int phylink_ethtool_ksettings_set(struct
  37. * the presence of a PHY, this should not be changed as that
  38. * should be determined from the media side advertisement.
  39. */
  40. - return phy_ethtool_ksettings_set(pl->phydev, kset);
  41. + return phy_ethtool_ksettings_set(pl->phydev, &phy_kset);
  42. }
  43. config = pl->link_config;
  44. + /* Mask out unsupported advertisements */
  45. + linkmode_and(config.advertising, kset->link_modes.advertising,
  46. + pl->supported);
  47. /* FIXME: should we reject autoneg if phy/mac does not support it? */
  48. switch (kset->base.autoneg) {