Skip to content

Commit 35c1bbd

Browse files
Miriam-Racheljmberg-intel
authored andcommitted
wifi: iwlwifi: mvm: remove IWL_MVM_STATUS_NEED_FLUSH_P2P
This is set when a P2P ROC ends, and uses as an indication inside iwl_mvm_roc_done_wk that the resources used for this ROC (sta/link) needs to be flushed/deactivated (respectively). But we also have IWL_MVM_STATUS_ROC_RUNNING, which is set whenever P2P ROC starts, and is not even used in iwl_mvm_roc_done_wk. Use IWL_MVM_STATUS_ROC_RUNNING as an indicator, and remove the redundant bit. While at it, add a call to synchronize_net also for the AUX ROC case, which is missing in the existing code. Signed-off-by: Miri Korenblit <[email protected]> Link: https://msgid.link/20240205211151.0494f75de311.Ic4aacacf7581a5c9046c4f1df87cbb67470853e7@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent cd882e2 commit 35c1bbd

File tree

2 files changed

+38
-55
lines changed

2 files changed

+38
-55
lines changed

drivers/net/wireless/intel/iwlwifi/mvm/mvm.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
22
/*
3-
* Copyright (C) 2012-2014, 2018-2023 Intel Corporation
3+
* Copyright (C) 2012-2014, 2018-2024 Intel Corporation
44
* Copyright (C) 2013-2015 Intel Mobile Communications GmbH
55
* Copyright (C) 2016-2017 Intel Deutschland GmbH
66
*/
@@ -1221,7 +1221,6 @@ struct iwl_mvm {
12211221
* @IWL_MVM_STATUS_IN_HW_RESTART: HW restart is active
12221222
* @IWL_MVM_STATUS_ROC_AUX_RUNNING: AUX remain-on-channel is running
12231223
* @IWL_MVM_STATUS_FIRMWARE_RUNNING: firmware is running
1224-
* @IWL_MVM_STATUS_NEED_FLUSH_P2P: need to flush P2P bcast STA
12251224
* @IWL_MVM_STATUS_IN_D3: in D3 (or at least about to go into it)
12261225
* @IWL_MVM_STATUS_SUPPRESS_ERROR_LOG_ONCE: suppress one error log
12271226
* if this is set, when intentionally triggered
@@ -1236,7 +1235,6 @@ enum iwl_mvm_status {
12361235
IWL_MVM_STATUS_IN_HW_RESTART,
12371236
IWL_MVM_STATUS_ROC_AUX_RUNNING,
12381237
IWL_MVM_STATUS_FIRMWARE_RUNNING,
1239-
IWL_MVM_STATUS_NEED_FLUSH_P2P,
12401238
IWL_MVM_STATUS_IN_D3,
12411239
IWL_MVM_STATUS_SUPPRESS_ERROR_LOG_ONCE,
12421240
IWL_MVM_STATUS_STARTING,

drivers/net/wireless/intel/iwlwifi/mvm/time-event.c

Lines changed: 37 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -45,32 +45,24 @@ void iwl_mvm_te_clear_data(struct iwl_mvm *mvm,
4545
te_data->link_id = -1;
4646
}
4747

48-
void iwl_mvm_roc_done_wk(struct work_struct *wk)
48+
static void iwl_mvm_cleanup_roc(struct iwl_mvm *mvm)
4949
{
50-
struct iwl_mvm *mvm = container_of(wk, struct iwl_mvm, roc_done_wk);
51-
5250
/*
5351
* Clear the ROC_RUNNING status bit.
5452
* This will cause the TX path to drop offchannel transmissions.
5553
* That would also be done by mac80211, but it is racy, in particular
56-
* in the case that the time event actually completed in the firmware
57-
* (which is handled in iwl_mvm_te_handle_notif).
58-
*/
59-
clear_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status);
60-
61-
synchronize_net();
62-
63-
/*
64-
* Flush the offchannel queue -- this is called when the time
54+
* in the case that the time event actually completed in the firmware.
55+
*
56+
* Also flush the offchannel queue -- this is called when the time
6557
* event finishes or is canceled, so that frames queued for it
6658
* won't get stuck on the queue and be transmitted in the next
6759
* time event.
6860
*/
69-
70-
mutex_lock(&mvm->mutex);
71-
if (test_and_clear_bit(IWL_MVM_STATUS_NEED_FLUSH_P2P, &mvm->status)) {
61+
if (test_and_clear_bit(IWL_MVM_STATUS_ROC_RUNNING, &mvm->status)) {
7262
struct iwl_mvm_vif *mvmvif;
7363

64+
synchronize_net();
65+
7466
/*
7567
* NB: access to this pointer would be racy, but the flush bit
7668
* can only be set when we had a P2P-Device VIF, and we have a
@@ -105,21 +97,16 @@ void iwl_mvm_roc_done_wk(struct work_struct *wk)
10597
}
10698
}
10799

108-
/*
109-
* Clear the ROC_AUX_RUNNING status bit.
110-
* This will cause the TX path to drop offchannel transmissions.
111-
* That would also be done by mac80211, but it is racy, in particular
112-
* in the case that the time event actually completed in the firmware
113-
* (which is handled in iwl_mvm_te_handle_notif).
114-
*/
100+
/* Do the same for AUX ROC */
115101
if (test_and_clear_bit(IWL_MVM_STATUS_ROC_AUX_RUNNING, &mvm->status)) {
116-
/* do the same in case of hot spot 2.0 */
102+
synchronize_net();
103+
117104
iwl_mvm_flush_sta(mvm, mvm->aux_sta.sta_id,
118105
mvm->aux_sta.tfd_queue_msk);
119106

120107
if (mvm->mld_api_is_used) {
121108
iwl_mvm_mld_rm_aux_sta(mvm);
122-
goto out_unlock;
109+
return;
123110
}
124111

125112
/* In newer version of this command an aux station is added only
@@ -128,8 +115,14 @@ void iwl_mvm_roc_done_wk(struct work_struct *wk)
128115
if (iwl_mvm_has_new_station_api(mvm->fw))
129116
iwl_mvm_rm_aux_sta(mvm);
130117
}
118+
}
131119

132-
out_unlock:
120+
void iwl_mvm_roc_done_wk(struct work_struct *wk)
121+
{
122+
struct iwl_mvm *mvm = container_of(wk, struct iwl_mvm, roc_done_wk);
123+
124+
mutex_lock(&mvm->mutex);
125+
iwl_mvm_cleanup_roc(mvm);
133126
mutex_unlock(&mvm->mutex);
134127
}
135128

@@ -294,18 +287,6 @@ static void iwl_mvm_te_check_trigger(struct iwl_mvm *mvm,
294287
}
295288
}
296289

297-
static void iwl_mvm_p2p_roc_finished(struct iwl_mvm *mvm)
298-
{
299-
/*
300-
* If the IWL_MVM_STATUS_NEED_FLUSH_P2P is already set, then the
301-
* roc_done_wk is already scheduled or running, so don't schedule it
302-
* again to avoid a race where the roc_done_wk clears this bit after
303-
* it is set here, affecting the next run of the roc_done_wk.
304-
*/
305-
if (!test_and_set_bit(IWL_MVM_STATUS_NEED_FLUSH_P2P, &mvm->status))
306-
iwl_mvm_roc_finished(mvm);
307-
}
308-
309290
/*
310291
* Handles a FW notification for an event that is known to the driver.
311292
*
@@ -357,7 +338,7 @@ static void iwl_mvm_te_handle_notif(struct iwl_mvm *mvm,
357338
switch (te_data->vif->type) {
358339
case NL80211_IFTYPE_P2P_DEVICE:
359340
ieee80211_remain_on_channel_expired(mvm->hw);
360-
iwl_mvm_p2p_roc_finished(mvm);
341+
iwl_mvm_roc_finished(mvm);
361342
break;
362343
case NL80211_IFTYPE_STATION:
363344
/*
@@ -782,7 +763,7 @@ static bool __iwl_mvm_remove_time_event(struct iwl_mvm *mvm,
782763
iwl_mvm_cancel_session_protection(mvm, vif, id,
783764
link_id);
784765
if (iftype == NL80211_IFTYPE_P2P_DEVICE) {
785-
iwl_mvm_p2p_roc_finished(mvm);
766+
iwl_mvm_roc_finished(mvm);
786767
}
787768
}
788769
return false;
@@ -972,7 +953,7 @@ void iwl_mvm_rx_session_protect_notif(struct iwl_mvm *mvm,
972953
/* End TE, notify mac80211 */
973954
mvmvif->time_event_data.id = SESSION_PROTECT_CONF_MAX_ID;
974955
mvmvif->time_event_data.link_id = -1;
975-
iwl_mvm_p2p_roc_finished(mvm);
956+
iwl_mvm_roc_finished(mvm);
976957
ieee80211_remain_on_channel_expired(mvm->hw);
977958
} else if (le32_to_cpu(notif->start)) {
978959
if (WARN_ON(mvmvif->time_event_data.id !=
@@ -1244,17 +1225,13 @@ void iwl_mvm_stop_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
12441225
IWL_UCODE_TLV_CAPA_SESSION_PROT_CMD)) {
12451226
mvmvif = iwl_mvm_vif_from_mac80211(vif);
12461227

1247-
if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
1228+
if (vif->type == NL80211_IFTYPE_P2P_DEVICE)
12481229
iwl_mvm_cancel_session_protection(mvm, vif,
12491230
mvmvif->time_event_data.id,
12501231
mvmvif->time_event_data.link_id);
1251-
iwl_mvm_p2p_roc_finished(mvm);
1252-
} else {
1232+
else
12531233
iwl_mvm_roc_station_remove(mvm, mvmvif);
1254-
iwl_mvm_roc_finished(mvm);
1255-
}
1256-
1257-
return;
1234+
goto cleanup_roc;
12581235
}
12591236

12601237
te_data = iwl_mvm_get_roc_te(mvm);
@@ -1265,13 +1242,21 @@ void iwl_mvm_stop_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
12651242

12661243
mvmvif = iwl_mvm_vif_from_mac80211(te_data->vif);
12671244

1268-
if (te_data->vif->type == NL80211_IFTYPE_P2P_DEVICE) {
1245+
if (te_data->vif->type == NL80211_IFTYPE_P2P_DEVICE)
12691246
iwl_mvm_remove_time_event(mvm, mvmvif, te_data);
1270-
iwl_mvm_p2p_roc_finished(mvm);
1271-
} else {
1247+
else
12721248
iwl_mvm_remove_aux_roc_te(mvm, mvmvif, te_data);
1273-
iwl_mvm_roc_finished(mvm);
1274-
}
1249+
1250+
cleanup_roc:
1251+
/*
1252+
* In case we get here before the ROC event started,
1253+
* (so the status bit isn't set) set it here so iwl_mvm_cleanup_roc will
1254+
* cleanup things properly
1255+
*/
1256+
set_bit(vif->type == NL80211_IFTYPE_P2P_DEVICE ?
1257+
IWL_MVM_STATUS_ROC_RUNNING : IWL_MVM_STATUS_ROC_AUX_RUNNING,
1258+
&mvm->status);
1259+
iwl_mvm_cleanup_roc(mvm);
12751260
}
12761261

12771262
void iwl_mvm_remove_csa_period(struct iwl_mvm *mvm,

0 commit comments

Comments
 (0)