On Monday, 11 December 2023 12:29:01 CET Salvatore Bonaccorso wrote:
> I cannot test for the regression explicitly myself, but 6.1.67 was
> released with just db46c77f3d51 ("Revert "wifi: cfg80211: fix CQM for
> non-range use""). Would you be in the position of do a test build with
> that commit (or with 6.1.67 upstream) to verify your issue goes away?

On Monday, 11 December 2023 12:37:44 CET Salvatore Bonaccorso wrote:
> I'm right now curious to find out if we see the same as
> #1057969 and if the upstream commit db46c77f3d51 ("Revert "wifi:
> cfg80211: fix CQM for non-range use"") in 6.1.67 upstream fixes the
> issue.

https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html#id-1.6.6.4
describes an easy way to test it and the patch you should use is attached.
From db46c77f3d51d24402731ea181b2a591e7dd1ac3 Mon Sep 17 00:00:00 2001
From: Greg Kroah-Hartman <gre...@linuxfoundation.org>
Date: Mon, 11 Dec 2023 10:16:15 +0100
Subject: [PATCH] Revert "wifi: cfg80211: fix CQM for non-range use"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit 307a6525c82a5a1bc5364711ece92c2d2487e1ad which is
commit 7e7efdda6adb385fbdfd6f819d76bc68c923c394 upstream.

It needed to have commit 076fc8775daf ("wifi: cfg80211: remove wdev
mutex") applied to properly work, otherwise regressions happen.

Link: https://lore.kernel.org/r/e374bb16-5b13-44cc-b11a-2f4eefb1e...@manjaro.org
Link: https://lore.kernel.org/r/87sf4belmm....@turtle.gmx.de
Link: https://lore.kernel.org/r/20231210213930.61378-1-...@leolam.fr
Reported-by: L??o Lam <l...@leolam.fr>
Reported-by: Sven Joachim <svenj...@gmx.de>
Reported-by: Philip M??ller <ph...@manjaro.org>
Cc: Johannes Berg <johannes.b...@intel.com>
Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org>
---
 net/wireless/core.h    |  1 -
 net/wireless/nl80211.c | 50 ++++++++++++++++--------------------------
 2 files changed, 19 insertions(+), 32 deletions(-)

diff --git a/net/wireless/core.h b/net/wireless/core.h
index ee980965a7cf..e1accacc6f23 100644
--- a/net/wireless/core.h
+++ b/net/wireless/core.h
@@ -297,7 +297,6 @@ struct cfg80211_cqm_config {
 	u32 rssi_hyst;
 	s32 last_rssi_event_value;
 	enum nl80211_cqm_rssi_threshold_event last_rssi_event_type;
-	bool use_range_api;
 	int n_rssi_thresholds;
 	s32 rssi_thresholds[];
 };
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 42c858219b34..b19b5acfaf3a 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -12574,6 +12574,10 @@ static int cfg80211_cqm_rssi_update(struct cfg80211_registered_device *rdev,
 	int i, n, low_index;
 	int err;
 
+	/* RSSI reporting disabled? */
+	if (!cqm_config)
+		return rdev_set_cqm_rssi_range_config(rdev, dev, 0, 0);
+
 	/*
 	 * Obtain current RSSI value if possible, if not and no RSSI threshold
 	 * event has been received yet, we should receive an event after a
@@ -12648,6 +12652,18 @@ static int nl80211_set_cqm_rssi(struct genl_info *info,
 	    wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)
 		return -EOPNOTSUPP;
 
+	if (n_thresholds <= 1 && rdev->ops->set_cqm_rssi_config) {
+		if (n_thresholds == 0 || thresholds[0] == 0) /* Disabling */
+			return rdev_set_cqm_rssi_config(rdev, dev, 0, 0);
+
+		return rdev_set_cqm_rssi_config(rdev, dev,
+						thresholds[0], hysteresis);
+	}
+
+	if (!wiphy_ext_feature_isset(&rdev->wiphy,
+				     NL80211_EXT_FEATURE_CQM_RSSI_LIST))
+		return -EOPNOTSUPP;
+
 	if (n_thresholds == 1 && thresholds[0] == 0) /* Disabling */
 		n_thresholds = 0;
 
@@ -12655,20 +12671,6 @@ static int nl80211_set_cqm_rssi(struct genl_info *info,
 	old = rcu_dereference_protected(wdev->cqm_config,
 					lockdep_is_held(&wdev->mtx));
 
-	/* if already disabled just succeed */
-	if (!n_thresholds && !old)
-		return 0;
-
-	if (n_thresholds > 1) {
-		if (!wiphy_ext_feature_isset(&rdev->wiphy,
-					     NL80211_EXT_FEATURE_CQM_RSSI_LIST) ||
-		    !rdev->ops->set_cqm_rssi_range_config)
-			return -EOPNOTSUPP;
-	} else {
-		if (!rdev->ops->set_cqm_rssi_config)
-			return -EOPNOTSUPP;
-	}
-
 	if (n_thresholds) {
 		cqm_config = kzalloc(struct_size(cqm_config, rssi_thresholds,
 						 n_thresholds),
@@ -12683,26 +12685,13 @@ static int nl80211_set_cqm_rssi(struct genl_info *info,
 		memcpy(cqm_config->rssi_thresholds, thresholds,
 		       flex_array_size(cqm_config, rssi_thresholds,
 				       n_thresholds));
-		cqm_config->use_range_api = n_thresholds > 1 ||
-					    !rdev->ops->set_cqm_rssi_config;
 
 		rcu_assign_pointer(wdev->cqm_config, cqm_config);
-
-		if (cqm_config->use_range_api)
-			err = cfg80211_cqm_rssi_update(rdev, dev, cqm_config);
-		else
-			err = rdev_set_cqm_rssi_config(rdev, dev,
-						       thresholds[0],
-						       hysteresis);
 	} else {
 		RCU_INIT_POINTER(wdev->cqm_config, NULL);
-		/* if enabled as range also disable via range */
-		if (old->use_range_api)
-			err = rdev_set_cqm_rssi_range_config(rdev, dev, 0, 0);
-		else
-			err = rdev_set_cqm_rssi_config(rdev, dev, 0, 0);
 	}
 
+	err = cfg80211_cqm_rssi_update(rdev, dev, cqm_config);
 	if (err) {
 		rcu_assign_pointer(wdev->cqm_config, old);
 		kfree_rcu(cqm_config, rcu_head);
@@ -18769,11 +18758,10 @@ void cfg80211_cqm_rssi_notify_work(struct wiphy *wiphy, struct wiphy_work *work)
 	wdev_lock(wdev);
 	cqm_config = rcu_dereference_protected(wdev->cqm_config,
 					       lockdep_is_held(&wdev->mtx));
-	if (!cqm_config)
+	if (!wdev->cqm_config)
 		goto unlock;
 
-	if (cqm_config->use_range_api)
-		cfg80211_cqm_rssi_update(rdev, wdev->netdev, cqm_config);
+	cfg80211_cqm_rssi_update(rdev, wdev->netdev, cqm_config);
 
 	rssi_level = cqm_config->last_rssi_event_value;
 	rssi_event = cqm_config->last_rssi_event_type;
-- 
2.43.0

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to