Skip to content

Commit e684ab7

Browse files
committed
Merge tag 'wireless-2023-06-06' of git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless
Kalle Valo says: ==================== wireless fixes for v6.4 Both rtw88 and rtw89 have a 802.11 powersave fix for a regression introduced in v6.0. mt76 fixes a race and a null pointer dereference. iwlwifi fixes an issue where not enough memory was allocated for a firmware event. And finally the stack has several smaller fixes all over. * tag 'wireless-2023-06-06' of git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless: wifi: cfg80211: fix locking in regulatory disconnect wifi: cfg80211: fix locking in sched scan stop work wifi: iwlwifi: mvm: Fix -Warray-bounds bug in iwl_mvm_wait_d3_notif() wifi: mac80211: fix switch count in EMA beacons wifi: mac80211: don't translate beacon/presp addrs wifi: mac80211: mlme: fix non-inheritence element wifi: cfg80211: reject bad AP MLD address wifi: mac80211: use correct iftype HE cap wifi: mt76: mt7996: fix possible NULL pointer dereference in mt7996_mac_write_txwi() wifi: rtw89: remove redundant check of entering LPS wifi: rtw89: correct PS calculation for SUPPORTS_DYNAMIC_PS wifi: rtw88: correct PS calculation for SUPPORTS_DYNAMIC_PS wifi: mt76: mt7615: fix possible race in mt7615_mac_sta_poll ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents accc1bf + f7e6003 commit e684ab7

File tree

18 files changed

+129
-48
lines changed

18 files changed

+129
-48
lines changed

drivers/net/wireless/intel/iwlwifi/mvm/d3.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,17 +2732,13 @@ static bool iwl_mvm_wait_d3_notif(struct iwl_notif_wait_data *notif_wait,
27322732
if (wowlan_info_ver < 2) {
27332733
struct iwl_wowlan_info_notif_v1 *notif_v1 = (void *)pkt->data;
27342734

2735-
notif = kmemdup(notif_v1,
2736-
offsetofend(struct iwl_wowlan_info_notif,
2737-
received_beacons),
2738-
GFP_ATOMIC);
2739-
2735+
notif = kmemdup(notif_v1, sizeof(*notif), GFP_ATOMIC);
27402736
if (!notif)
27412737
return false;
27422738

27432739
notif->tid_tear_down = notif_v1->tid_tear_down;
27442740
notif->station_id = notif_v1->station_id;
2745-
2741+
memset_after(notif, 0, station_id);
27462742
} else {
27472743
notif = (void *)pkt->data;
27482744
}

drivers/net/wireless/mediatek/mt76/mt7615/mac.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,10 @@ void mt7615_mac_sta_poll(struct mt7615_dev *dev)
914914

915915
msta = list_first_entry(&sta_poll_list, struct mt7615_sta,
916916
poll_list);
917+
918+
spin_lock_bh(&dev->sta_poll_lock);
917919
list_del_init(&msta->poll_list);
920+
spin_unlock_bh(&dev->sta_poll_lock);
918921

919922
addr = mt7615_mac_wtbl_addr(dev, msta->wcid.idx) + 19 * 4;
920923

drivers/net/wireless/mediatek/mt76/mt7996/mac.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,18 +1004,19 @@ void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi,
10041004
{
10051005
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
10061006
struct ieee80211_vif *vif = info->control.vif;
1007-
struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
10081007
u8 band_idx = (info->hw_queue & MT_TX_HW_QUEUE_PHY) >> 2;
10091008
u8 p_fmt, q_idx, omac_idx = 0, wmm_idx = 0;
10101009
bool is_8023 = info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP;
1010+
struct mt7996_vif *mvif;
10111011
u16 tx_count = 15;
10121012
u32 val;
10131013
bool beacon = !!(changed & (BSS_CHANGED_BEACON |
10141014
BSS_CHANGED_BEACON_ENABLED));
10151015
bool inband_disc = !!(changed & (BSS_CHANGED_UNSOL_BCAST_PROBE_RESP |
10161016
BSS_CHANGED_FILS_DISCOVERY));
10171017

1018-
if (vif) {
1018+
mvif = vif ? (struct mt7996_vif *)vif->drv_priv : NULL;
1019+
if (mvif) {
10191020
omac_idx = mvif->mt76.omac_idx;
10201021
wmm_idx = mvif->mt76.wmm_idx;
10211022
band_idx = mvif->mt76.band_idx;
@@ -1081,12 +1082,16 @@ void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi,
10811082
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
10821083
bool mcast = ieee80211_is_data(hdr->frame_control) &&
10831084
is_multicast_ether_addr(hdr->addr1);
1084-
u8 idx = mvif->basic_rates_idx;
1085+
u8 idx = MT7996_BASIC_RATES_TBL;
10851086

1086-
if (mcast && mvif->mcast_rates_idx)
1087-
idx = mvif->mcast_rates_idx;
1088-
else if (beacon && mvif->beacon_rates_idx)
1089-
idx = mvif->beacon_rates_idx;
1087+
if (mvif) {
1088+
if (mcast && mvif->mcast_rates_idx)
1089+
idx = mvif->mcast_rates_idx;
1090+
else if (beacon && mvif->beacon_rates_idx)
1091+
idx = mvif->beacon_rates_idx;
1092+
else
1093+
idx = mvif->basic_rates_idx;
1094+
}
10901095

10911096
txwi[6] |= cpu_to_le32(FIELD_PREP(MT_TXD6_TX_RATE, idx));
10921097
txwi[3] |= cpu_to_le32(MT_TXD3_BA_DISABLE);

drivers/net/wireless/realtek/rtw88/mac80211.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,6 @@ static int rtw_ops_config(struct ieee80211_hw *hw, u32 changed)
8888
}
8989
}
9090

91-
if (changed & IEEE80211_CONF_CHANGE_PS) {
92-
if (hw->conf.flags & IEEE80211_CONF_PS) {
93-
rtwdev->ps_enabled = true;
94-
} else {
95-
rtwdev->ps_enabled = false;
96-
rtw_leave_lps(rtwdev);
97-
}
98-
}
99-
10091
if (changed & IEEE80211_CONF_CHANGE_CHANNEL)
10192
rtw_set_channel(rtwdev);
10293

@@ -213,6 +204,7 @@ static int rtw_ops_add_interface(struct ieee80211_hw *hw,
213204
config |= PORT_SET_BCN_CTRL;
214205
rtw_vif_port_config(rtwdev, rtwvif, config);
215206
rtw_core_port_switch(rtwdev, vif);
207+
rtw_recalc_lps(rtwdev, vif);
216208

217209
mutex_unlock(&rtwdev->mutex);
218210

@@ -244,6 +236,7 @@ static void rtw_ops_remove_interface(struct ieee80211_hw *hw,
244236
config |= PORT_SET_BCN_CTRL;
245237
rtw_vif_port_config(rtwdev, rtwvif, config);
246238
clear_bit(rtwvif->port, rtwdev->hw_port);
239+
rtw_recalc_lps(rtwdev, NULL);
247240

248241
mutex_unlock(&rtwdev->mutex);
249242
}
@@ -438,6 +431,9 @@ static void rtw_ops_bss_info_changed(struct ieee80211_hw *hw,
438431
if (changed & BSS_CHANGED_ERP_SLOT)
439432
rtw_conf_tx(rtwdev, rtwvif);
440433

434+
if (changed & BSS_CHANGED_PS)
435+
rtw_recalc_lps(rtwdev, NULL);
436+
441437
rtw_vif_port_config(rtwdev, rtwvif, config);
442438

443439
mutex_unlock(&rtwdev->mutex);

drivers/net/wireless/realtek/rtw88/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ static void rtw_watch_dog_work(struct work_struct *work)
271271
* more than two stations associated to the AP, then we can not enter
272272
* lps, because fw does not handle the overlapped beacon interval
273273
*
274-
* mac80211 should iterate vifs and determine if driver can enter
275-
* ps by passing IEEE80211_CONF_PS to us, all we need to do is to
274+
* rtw_recalc_lps() iterate vifs and determine if driver can enter
275+
* ps by vif->type and vif->cfg.ps, all we need to do here is to
276276
* get that vif and check if device is having traffic more than the
277277
* threshold.
278278
*/

drivers/net/wireless/realtek/rtw88/ps.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,46 @@ void rtw_leave_lps_deep(struct rtw_dev *rtwdev)
299299

300300
__rtw_leave_lps_deep(rtwdev);
301301
}
302+
303+
struct rtw_vif_recalc_lps_iter_data {
304+
struct rtw_dev *rtwdev;
305+
struct ieee80211_vif *found_vif;
306+
int count;
307+
};
308+
309+
static void __rtw_vif_recalc_lps(struct rtw_vif_recalc_lps_iter_data *data,
310+
struct ieee80211_vif *vif)
311+
{
312+
if (data->count < 0)
313+
return;
314+
315+
if (vif->type != NL80211_IFTYPE_STATION) {
316+
data->count = -1;
317+
return;
318+
}
319+
320+
data->count++;
321+
data->found_vif = vif;
322+
}
323+
324+
static void rtw_vif_recalc_lps_iter(void *data, u8 *mac,
325+
struct ieee80211_vif *vif)
326+
{
327+
__rtw_vif_recalc_lps(data, vif);
328+
}
329+
330+
void rtw_recalc_lps(struct rtw_dev *rtwdev, struct ieee80211_vif *new_vif)
331+
{
332+
struct rtw_vif_recalc_lps_iter_data data = { .rtwdev = rtwdev };
333+
334+
if (new_vif)
335+
__rtw_vif_recalc_lps(&data, new_vif);
336+
rtw_iterate_vifs(rtwdev, rtw_vif_recalc_lps_iter, &data);
337+
338+
if (data.count == 1 && data.found_vif->cfg.ps) {
339+
rtwdev->ps_enabled = true;
340+
} else {
341+
rtwdev->ps_enabled = false;
342+
rtw_leave_lps(rtwdev);
343+
}
344+
}

drivers/net/wireless/realtek/rtw88/ps.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ void rtw_enter_lps(struct rtw_dev *rtwdev, u8 port_id);
2323
void rtw_leave_lps(struct rtw_dev *rtwdev);
2424
void rtw_leave_lps_deep(struct rtw_dev *rtwdev);
2525
enum rtw_lps_deep_mode rtw_get_lps_deep_mode(struct rtw_dev *rtwdev);
26+
void rtw_recalc_lps(struct rtw_dev *rtwdev, struct ieee80211_vif *new_vif);
27+
2628
#endif

drivers/net/wireless/realtek/rtw89/core.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2531,9 +2531,6 @@ static void rtw89_vif_enter_lps(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwv
25312531
rtwvif->tdls_peer)
25322532
return;
25332533

2534-
if (rtwdev->total_sta_assoc > 1)
2535-
return;
2536-
25372534
if (rtwvif->offchan)
25382535
return;
25392536

drivers/net/wireless/realtek/rtw89/mac80211.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,6 @@ static int rtw89_ops_config(struct ieee80211_hw *hw, u32 changed)
8989
!(hw->conf.flags & IEEE80211_CONF_IDLE))
9090
rtw89_leave_ips(rtwdev);
9191

92-
if (changed & IEEE80211_CONF_CHANGE_PS) {
93-
if (hw->conf.flags & IEEE80211_CONF_PS) {
94-
rtwdev->lps_enabled = true;
95-
} else {
96-
rtw89_leave_lps(rtwdev);
97-
rtwdev->lps_enabled = false;
98-
}
99-
}
100-
10192
if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
10293
rtw89_config_entity_chandef(rtwdev, RTW89_SUB_ENTITY_0,
10394
&hw->conf.chandef);
@@ -168,6 +159,8 @@ static int rtw89_ops_add_interface(struct ieee80211_hw *hw,
168159
rtw89_core_txq_init(rtwdev, vif->txq);
169160

170161
rtw89_btc_ntfy_role_info(rtwdev, rtwvif, NULL, BTC_ROLE_START);
162+
163+
rtw89_recalc_lps(rtwdev);
171164
out:
172165
mutex_unlock(&rtwdev->mutex);
173166

@@ -192,6 +185,7 @@ static void rtw89_ops_remove_interface(struct ieee80211_hw *hw,
192185
rtw89_mac_remove_vif(rtwdev, rtwvif);
193186
rtw89_core_release_bit_map(rtwdev->hw_port, rtwvif->port);
194187
list_del_init(&rtwvif->list);
188+
rtw89_recalc_lps(rtwdev);
195189
rtw89_enter_ips_by_hwflags(rtwdev);
196190

197191
mutex_unlock(&rtwdev->mutex);
@@ -451,6 +445,9 @@ static void rtw89_ops_bss_info_changed(struct ieee80211_hw *hw,
451445
if (changed & BSS_CHANGED_CQM)
452446
rtw89_fw_h2c_set_bcn_fltr_cfg(rtwdev, vif, true);
453447

448+
if (changed & BSS_CHANGED_PS)
449+
rtw89_recalc_lps(rtwdev);
450+
454451
mutex_unlock(&rtwdev->mutex);
455452
}
456453

drivers/net/wireless/realtek/rtw89/ps.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,29 @@ void rtw89_process_p2p_ps(struct rtw89_dev *rtwdev, struct ieee80211_vif *vif)
252252
rtw89_p2p_disable_all_noa(rtwdev, vif);
253253
rtw89_p2p_update_noa(rtwdev, vif);
254254
}
255+
256+
void rtw89_recalc_lps(struct rtw89_dev *rtwdev)
257+
{
258+
struct ieee80211_vif *vif, *found_vif = NULL;
259+
struct rtw89_vif *rtwvif;
260+
int count = 0;
261+
262+
rtw89_for_each_rtwvif(rtwdev, rtwvif) {
263+
vif = rtwvif_to_vif(rtwvif);
264+
265+
if (vif->type != NL80211_IFTYPE_STATION) {
266+
count = 0;
267+
break;
268+
}
269+
270+
count++;
271+
found_vif = vif;
272+
}
273+
274+
if (count == 1 && found_vif->cfg.ps) {
275+
rtwdev->lps_enabled = true;
276+
} else {
277+
rtw89_leave_lps(rtwdev);
278+
rtwdev->lps_enabled = false;
279+
}
280+
}

0 commit comments

Comments
 (0)