Skip to contentSkip to conversation

wifi: rtw88: find an associated station without allocating

PATCH In review Mehmet Fide 3 participants 6 messages Nov 18 – Nov 22 Realtek wireless driver (rtw88)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: rtw88: find an associated station without allocating

From: Mehmet Fide <[email protected]>

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")

---

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(-)
drivers/net/wireless/realtek/rtw88/main.c +14 -16
index 2a38a6828e3a..826e1bc37243 100644
@@ -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

Signature · 1 line
2.56.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Mehmet Fide

From: Mehmet Fide <[email protected]>

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.

Quoted 7 lines
Fixes 96fbb84de4ff ("wifi: rtw88: handle station mode concurrent scan with AP mode")

---

Looks good to me,

Best regards,
Luka Gejak

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Mehmet Fide
Quoted 10 lines · Mehmet Fide

From: Mehmet Fide <[email protected]>

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.

Quoted 4 lines

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")

I'd remove this Fixes, as my comment in Closes link.

Quoted 4 lines
#3 lore raw
Quoted 3 lines · Ping-Ke Shih
Quoted 1 line
Fixes 96fbb84de4ff ("wifi: rtw88: handle station mode concurrent scan with AP mode")

I'd remove this Fixes, as my comment in Closes link.

OK. Could you drop it when applying, or should I send a v2 without it?

Mehmet

maintainer
#4 lore raw
Quoted 6 lines · Mehmet Fide
Quoted 3 lines · Ping-Ke Shih
Quoted 1 line
Fixes 96fbb84de4ff ("wifi: rtw88: handle station mode concurrent scan with AP mode")

I'd remove this Fixes, as my comment in Closes link.

OK. Could you drop it when applying, or should I send a v2 without it?

No need v2. I will drop it when applying.

maintainer
#5 lore raw
In reply to Mehmet Fide
Quoted 13 lines · Mehmet Fide

From: Mehmet Fide <[email protected]>

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.

Quoted 7 lines
Fixes 96fbb84de4ff ("wifi: rtw88: handle station mode concurrent scan with AP mode")

1 patch(es) applied to rtw-next branch of rtw.git, thanks.

2edf54bca623 wifi: rtw88: find an associated station without allocating

---
https://github.com/pkshih/rtw.git