Commit 0bcc2155 authored by Johannes Berg's avatar Johannes Berg

wifi: iwlwifi: mvm: init vif works only once

It's dangerous to re-initialize works repeatedly, especially
delayed ones that have an associated timer, and even more so
if they're not necessarily canceled inbetween. This can be
the case for these workers here during FW restart scenarios,
so make sure to initialize it only once.

While at it, also ensure it is cancelled correctly.

Fixes: f6780614 ("iwlwifi: mvm: disconnect in case of bad channel switch parameters")
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarMiri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240416134215.ddf8eece5eac.I4164f5c9c444b64a9abbaab14c23858713778e35@changeidSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 6cf7df9f
...@@ -1612,6 +1612,17 @@ static int iwl_mvm_alloc_bcast_mcast_sta(struct iwl_mvm *mvm, ...@@ -1612,6 +1612,17 @@ static int iwl_mvm_alloc_bcast_mcast_sta(struct iwl_mvm *mvm,
IWL_STA_MULTICAST); IWL_STA_MULTICAST);
} }
void iwl_mvm_mac_init_mvmvif(struct iwl_mvm *mvm, struct iwl_mvm_vif *mvmvif)
{
lockdep_assert_held(&mvm->mutex);
if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
return;
INIT_DELAYED_WORK(&mvmvif->csa_work,
iwl_mvm_channel_switch_disconnect_wk);
}
static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,
struct ieee80211_vif *vif) struct ieee80211_vif *vif)
{ {
...@@ -1622,6 +1633,8 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, ...@@ -1622,6 +1633,8 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,
mutex_lock(&mvm->mutex); mutex_lock(&mvm->mutex);
iwl_mvm_mac_init_mvmvif(mvm, mvmvif);
mvmvif->mvm = mvm; mvmvif->mvm = mvm;
/* the first link always points to the default one */ /* the first link always points to the default one */
...@@ -1703,8 +1716,6 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, ...@@ -1703,8 +1716,6 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,
mvm->p2p_device_vif = vif; mvm->p2p_device_vif = vif;
iwl_mvm_tcm_add_vif(mvm, vif); iwl_mvm_tcm_add_vif(mvm, vif);
INIT_DELAYED_WORK(&mvmvif->csa_work,
iwl_mvm_channel_switch_disconnect_wk);
if (vif->type == NL80211_IFTYPE_MONITOR) { if (vif->type == NL80211_IFTYPE_MONITOR) {
mvm->monitor_on = true; mvm->monitor_on = true;
...@@ -1742,6 +1753,8 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw, ...@@ -1742,6 +1753,8 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,
void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm, void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm,
struct ieee80211_vif *vif) struct ieee80211_vif *vif)
{ {
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
/* /*
* Flush the ROC worker which will flush the OFFCHANNEL queue. * Flush the ROC worker which will flush the OFFCHANNEL queue.
...@@ -1750,6 +1763,8 @@ void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm, ...@@ -1750,6 +1763,8 @@ void iwl_mvm_prepare_mac_removal(struct iwl_mvm *mvm,
*/ */
flush_work(&mvm->roc_done_wk); flush_work(&mvm->roc_done_wk);
} }
cancel_delayed_work_sync(&mvmvif->csa_work);
} }
/* This function is doing the common part of removing the interface for /* This function is doing the common part of removing the interface for
......
...@@ -14,6 +14,8 @@ static int iwl_mvm_mld_mac_add_interface(struct ieee80211_hw *hw, ...@@ -14,6 +14,8 @@ static int iwl_mvm_mld_mac_add_interface(struct ieee80211_hw *hw,
mutex_lock(&mvm->mutex); mutex_lock(&mvm->mutex);
iwl_mvm_mac_init_mvmvif(mvm, mvmvif);
mvmvif->mvm = mvm; mvmvif->mvm = mvm;
/* Not much to do here. The stack will not allow interface /* Not much to do here. The stack will not allow interface
......
...@@ -1805,6 +1805,8 @@ int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm); ...@@ -1805,6 +1805,8 @@ int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm);
int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm); int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm);
void iwl_mvm_mac_init_mvmvif(struct iwl_mvm *mvm, struct iwl_mvm_vif *mvmvif);
/* /*
* FW notifications / CMD responses handlers * FW notifications / CMD responses handlers
* Convention: iwl_mvm_rx_<NAME OF THE CMD> * Convention: iwl_mvm_rx_<NAME OF THE CMD>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment