mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH rtw-next] wifi: rtw88: find an associated station without allocating
@ 2026-11-18 10:47 Mehmet Fide
  2026-11-18 13:10 ` Luka Gejak
  0 siblings, 1 reply; 2+ messages in thread
From: Mehmet Fide @ 2026-11-18 10:47 UTC (permalink / raw)
  To: Ping-Ke Shih
  Cc: Luka Gejak, Po-Hao Huang, Kalle Valo, linux-wireless,
	linux-kernel, mehmet.fide

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-18 13:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 10:47 [PATCH rtw-next] wifi: rtw88: find an associated station without allocating Mehmet Fide
2026-11-18 13:10 ` Luka Gejak

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®