2
0

792-01-v6.0-net-phylink-disable-PCS-polling-over-major-configura.patch 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. From bfac8c490d605bea03b1f1927582b6f396462164 Mon Sep 17 00:00:00 2001
  2. From: "Russell King (Oracle)" <[email protected]>
  3. Date: Mon, 27 Jun 2022 12:44:43 +0100
  4. Subject: [PATCH] net: phylink: disable PCS polling over major configuration
  5. While we are performing a major configuration, there is no point having
  6. the PCS polling timer running. Stop it before we begin preparing for
  7. the configuration change, and restart it only once we've successfully
  8. completed the change.
  9. Reviewed-by: Andrew Lunn <[email protected]>
  10. Signed-off-by: Russell King (Oracle) <[email protected]>
  11. Signed-off-by: Jakub Kicinski <[email protected]>
  12. ---
  13. drivers/net/phy/phylink.c | 30 ++++++++++++++++++++----------
  14. 1 file changed, 20 insertions(+), 10 deletions(-)
  15. --- a/drivers/net/phy/phylink.c
  16. +++ b/drivers/net/phy/phylink.c
  17. @@ -756,6 +756,18 @@ static void phylink_resolve_flow(struct
  18. }
  19. }
  20. +static void phylink_pcs_poll_stop(struct phylink *pl)
  21. +{
  22. + if (pl->cfg_link_an_mode == MLO_AN_INBAND)
  23. + del_timer(&pl->link_poll);
  24. +}
  25. +
  26. +static void phylink_pcs_poll_start(struct phylink *pl)
  27. +{
  28. + if (pl->pcs->poll && pl->cfg_link_an_mode == MLO_AN_INBAND)
  29. + mod_timer(&pl->link_poll, jiffies + HZ);
  30. +}
  31. +
  32. static void phylink_mac_config(struct phylink *pl,
  33. const struct phylink_link_state *state)
  34. {
  35. @@ -787,6 +799,7 @@ static void phylink_major_config(struct
  36. const struct phylink_link_state *state)
  37. {
  38. struct phylink_pcs *pcs = NULL;
  39. + bool pcs_changed = false;
  40. int err;
  41. phylink_dbg(pl, "major config %s\n", phy_modes(state->interface));
  42. @@ -799,8 +812,12 @@ static void phylink_major_config(struct
  43. pcs);
  44. return;
  45. }
  46. +
  47. + pcs_changed = pcs && pl->pcs != pcs;
  48. }
  49. + phylink_pcs_poll_stop(pl);
  50. +
  51. if (pl->mac_ops->mac_prepare) {
  52. err = pl->mac_ops->mac_prepare(pl->config, pl->cur_link_an_mode,
  53. state->interface);
  54. @@ -814,8 +831,10 @@ static void phylink_major_config(struct
  55. /* If we have a new PCS, switch to the new PCS after preparing the MAC
  56. * for the change.
  57. */
  58. - if (pcs)
  59. - phylink_set_pcs(pl, pcs);
  60. + if (pcs_changed) {
  61. + pl->pcs = pcs;
  62. + pl->pcs_ops = pcs->ops;
  63. + }
  64. phylink_mac_config(pl, state);
  65. @@ -841,6 +860,8 @@ static void phylink_major_config(struct
  66. phylink_err(pl, "mac_finish failed: %pe\n",
  67. ERR_PTR(err));
  68. }
  69. +
  70. + phylink_pcs_poll_start(pl);
  71. }
  72. /*