mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mehmet Fide <mehmet.fide@gmail.com>
To: Ping-Ke Shih <pkshih@realtek.com>
Cc: Luka Gejak <luka.gejak@linux.dev>,
	Po-Hao Huang <phhuang@realtek.com>, Kalle Valo <kvalo@kernel.org>,
	linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	mehmet.fide@screeningeagle.com
Subject: [PATCH rtw-next] wifi: rtw88: find an associated station without allocating
Date: Wed, 18 Nov 2026 11:47:38 +0100	[thread overview]
Message-ID: <20261118104738.2020747-1-mehmet.fide@gmail.com> (raw)

From: Mehmet Fide <mehmet.fide@screeningeagle.com>

rtw_core_check_sta_active() collects the interfaces with
rtw_iterate_vifs(), which allocates an entry per interface with
GFP_ATOMIC and skips the interface when that fails. A station skipped
this way counts as not active: on BSS_CHANGED_BSSID and in
rtw_ops_stop_ap() rtw_clear_op_chan() then drops the operating channel
saved for it, and a later hardware scan no longer goes back to that
channel between the channels it scans.

Both callers hold the wiphy mutex. Walk the active interfaces with
for_each_active_interface(), which does not allocate.

Fixes: 96fbb84de4ff ("wifi: rtw88: handle station mode concurrent scan with AP mode")
Reported-by: Luka Gejak <luka.gejak@linux.dev>
Closes: https://lore.kernel.org/linux-wireless/9BC4FC13-5723-4711-9798-11E3C285C7F1@linux.dev/
Suggested-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
---

Notes:
    Tested on rtw-next with a test build that fails one entry allocation of
    rtw_iterate_vifs() inside rtw_core_check_sta_active(): on an RTL8822CE
    and an RTL8822CU with a station interface associated and an AP started
    next to it and stopped, the saved operating channel was cleared in 6 of
    6 stops without the patch and in none of 6 with it. AP, association,
    firmware recovery and scan on an RTL8822BU and the RTL8822CE on 2.4 and
    5 GHz gave no lockdep report.

 drivers/net/wireless/realtek/rtw88/main.c | 30 +++++++++++------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
index 2a38a6828e3a..826e1bc37243 100644
--- a/drivers/net/wireless/realtek/rtw88/main.c
+++ b/drivers/net/wireless/realtek/rtw88/main.c
@@ -2448,28 +2448,26 @@ void rtw_core_port_switch(struct rtw_dev *rtwdev, struct ieee80211_vif *vif)
 	rtw_iterate_vifs(rtwdev, rtw_port_switch_iter, &iter_data);
 }
 
-static void rtw_check_sta_active_iter(void *data, struct ieee80211_vif *vif)
+bool rtw_core_check_sta_active(struct rtw_dev *rtwdev)
 {
-	struct rtw_vif *rtwvif = (struct rtw_vif *)vif->drv_priv;
-	bool *active = data;
-
-	if (*active)
-		return;
+	struct ieee80211_vif *vif;
+	struct rtw_vif *rtwvif;
 
-	if (vif->type != NL80211_IFTYPE_STATION)
-		return;
+	lockdep_assert_wiphy(rtwdev->hw->wiphy);
 
-	if (vif->cfg.assoc || !is_zero_ether_addr(rtwvif->bssid))
-		*active = true;
-}
+	if (rtwdev->ap_active)
+		return true;
 
-bool rtw_core_check_sta_active(struct rtw_dev *rtwdev)
-{
-	bool sta_active = false;
+	for_each_active_interface(vif, rtwdev->hw) {
+		if (vif->type != NL80211_IFTYPE_STATION)
+			continue;
 
-	rtw_iterate_vifs(rtwdev, rtw_check_sta_active_iter, &sta_active);
+		rtwvif = (struct rtw_vif *)vif->drv_priv;
+		if (vif->cfg.assoc || !is_zero_ether_addr(rtwvif->bssid))
+			return true;
+	}
 
-	return rtwdev->ap_active || sta_active;
+	return false;
 }
 
 void rtw_core_enable_beacon(struct rtw_dev *rtwdev, bool enable)

base-commit: 0bdc579dbfc251a6b6838ee9459b6771b948c617
-- 
2.56.0


                 reply	other threads:[~2026-11-18 10:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261118104738.2020747-1-mehmet.fide@gmail.com \
    --to=mehmet.fide@gmail.com \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luka.gejak@linux.dev \
    --cc=mehmet.fide@screeningeagle.com \
    --cc=phhuang@realtek.com \
    --cc=pkshih@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®