0004-Revert-wifi-cfg80211-fix-CQM-for-non-range-use.patch 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. From cd906594e5fdf1065975f2a89ce45c066c9f02a3 Mon Sep 17 00:00:00 2001
  2. From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  3. Date: Mon, 11 Dec 2023 10:16:15 +0100
  4. Subject: [PATCH 4/5] Revert "wifi: cfg80211: fix CQM for non-range use"
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. This reverts commit 4a7e92551618f3737b305f62451353ee05662f57 which is
  9. commit 7e7efdda6adb385fbdfd6f819d76bc68c923c394 upstream.
  10. It needed to have commit 076fc8775daf ("wifi: cfg80211: remove wdev
  11. mutex") applied to properly work, otherwise regressions happen.
  12. Link: https://lore.kernel.org/r/e374bb16-5b13-44cc-b11a-2f4eefb1ecf5@manjaro.org
  13. Link: https://lore.kernel.org/r/87sf4belmm.fsf@turtle.gmx.de
  14. Link: https://lore.kernel.org/r/20231210213930.61378-1-leo@leolam.fr
  15. Reported-by: Léo Lam <leo@leolam.fr>
  16. Reported-by: Sven Joachim <svenjoac@gmx.de>
  17. Reported-by: Philip Müller <philm@manjaro.org>
  18. Cc: Johannes Berg <johannes.berg@intel.com>
  19. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  20. Cherry-picked-for: https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/issues/17
  21. ---
  22. net/wireless/core.h | 1 -
  23. net/wireless/nl80211.c | 50 ++++++++++++++++--------------------------
  24. 2 files changed, 19 insertions(+), 32 deletions(-)
  25. diff --git a/net/wireless/core.h b/net/wireless/core.h
  26. index f0a3a2317638..e536c0b615a0 100644
  27. --- a/net/wireless/core.h
  28. +++ b/net/wireless/core.h
  29. @@ -299,7 +299,6 @@ struct cfg80211_cqm_config {
  30. u32 rssi_hyst;
  31. s32 last_rssi_event_value;
  32. enum nl80211_cqm_rssi_threshold_event last_rssi_event_type;
  33. - bool use_range_api;
  34. int n_rssi_thresholds;
  35. s32 rssi_thresholds[] __counted_by(n_rssi_thresholds);
  36. };
  37. diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
  38. index 6a82dd876f27..931a03f4549c 100644
  39. --- a/net/wireless/nl80211.c
  40. +++ b/net/wireless/nl80211.c
  41. @@ -12824,6 +12824,10 @@ static int cfg80211_cqm_rssi_update(struct cfg80211_registered_device *rdev,
  42. int i, n, low_index;
  43. int err;
  44. + /* RSSI reporting disabled? */
  45. + if (!cqm_config)
  46. + return rdev_set_cqm_rssi_range_config(rdev, dev, 0, 0);
  47. +
  48. /*
  49. * Obtain current RSSI value if possible, if not and no RSSI threshold
  50. * event has been received yet, we should receive an event after a
  51. @@ -12898,6 +12902,18 @@ static int nl80211_set_cqm_rssi(struct genl_info *info,
  52. wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)
  53. return -EOPNOTSUPP;
  54. + if (n_thresholds <= 1 && rdev->ops->set_cqm_rssi_config) {
  55. + if (n_thresholds == 0 || thresholds[0] == 0) /* Disabling */
  56. + return rdev_set_cqm_rssi_config(rdev, dev, 0, 0);
  57. +
  58. + return rdev_set_cqm_rssi_config(rdev, dev,
  59. + thresholds[0], hysteresis);
  60. + }
  61. +
  62. + if (!wiphy_ext_feature_isset(&rdev->wiphy,
  63. + NL80211_EXT_FEATURE_CQM_RSSI_LIST))
  64. + return -EOPNOTSUPP;
  65. +
  66. if (n_thresholds == 1 && thresholds[0] == 0) /* Disabling */
  67. n_thresholds = 0;
  68. @@ -12905,20 +12921,6 @@ static int nl80211_set_cqm_rssi(struct genl_info *info,
  69. old = rcu_dereference_protected(wdev->cqm_config,
  70. lockdep_is_held(&wdev->mtx));
  71. - /* if already disabled just succeed */
  72. - if (!n_thresholds && !old)
  73. - return 0;
  74. -
  75. - if (n_thresholds > 1) {
  76. - if (!wiphy_ext_feature_isset(&rdev->wiphy,
  77. - NL80211_EXT_FEATURE_CQM_RSSI_LIST) ||
  78. - !rdev->ops->set_cqm_rssi_range_config)
  79. - return -EOPNOTSUPP;
  80. - } else {
  81. - if (!rdev->ops->set_cqm_rssi_config)
  82. - return -EOPNOTSUPP;
  83. - }
  84. -
  85. if (n_thresholds) {
  86. cqm_config = kzalloc(struct_size(cqm_config, rssi_thresholds,
  87. n_thresholds),
  88. @@ -12933,26 +12935,13 @@ static int nl80211_set_cqm_rssi(struct genl_info *info,
  89. memcpy(cqm_config->rssi_thresholds, thresholds,
  90. flex_array_size(cqm_config, rssi_thresholds,
  91. n_thresholds));
  92. - cqm_config->use_range_api = n_thresholds > 1 ||
  93. - !rdev->ops->set_cqm_rssi_config;
  94. rcu_assign_pointer(wdev->cqm_config, cqm_config);
  95. -
  96. - if (cqm_config->use_range_api)
  97. - err = cfg80211_cqm_rssi_update(rdev, dev, cqm_config);
  98. - else
  99. - err = rdev_set_cqm_rssi_config(rdev, dev,
  100. - thresholds[0],
  101. - hysteresis);
  102. } else {
  103. RCU_INIT_POINTER(wdev->cqm_config, NULL);
  104. - /* if enabled as range also disable via range */
  105. - if (old->use_range_api)
  106. - err = rdev_set_cqm_rssi_range_config(rdev, dev, 0, 0);
  107. - else
  108. - err = rdev_set_cqm_rssi_config(rdev, dev, 0, 0);
  109. }
  110. + err = cfg80211_cqm_rssi_update(rdev, dev, cqm_config);
  111. if (err) {
  112. rcu_assign_pointer(wdev->cqm_config, old);
  113. kfree_rcu(cqm_config, rcu_head);
  114. @@ -19142,11 +19131,10 @@ void cfg80211_cqm_rssi_notify_work(struct wiphy *wiphy, struct wiphy_work *work)
  115. wdev_lock(wdev);
  116. cqm_config = rcu_dereference_protected(wdev->cqm_config,
  117. lockdep_is_held(&wdev->mtx));
  118. - if (!cqm_config)
  119. + if (!wdev->cqm_config)
  120. goto unlock;
  121. - if (cqm_config->use_range_api)
  122. - cfg80211_cqm_rssi_update(rdev, wdev->netdev, cqm_config);
  123. + cfg80211_cqm_rssi_update(rdev, wdev->netdev, cqm_config);
  124. rssi_level = cqm_config->last_rssi_event_value;
  125. rssi_event = cqm_config->last_rssi_event_type;
  126. --
  127. 2.43.0