Commit 3f312651 authored by Johannes Berg's avatar Johannes Berg

wifi: iwlwifi: mvm: add mvm-specific guard

Add and use an mvm-specific guard for the mvm mutex.
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/20240512152312.7391425b3af2.I1b109f56753dd3f35602dd2c5cf6e1e35aee313d@changeidSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 9d42be9b
...@@ -12,7 +12,7 @@ static int iwl_mvm_mld_mac_add_interface(struct ieee80211_hw *hw, ...@@ -12,7 +12,7 @@ static int iwl_mvm_mld_mac_add_interface(struct ieee80211_hw *hw,
int ret; int ret;
int i; int i;
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
iwl_mvm_mac_init_mvmvif(mvm, mvmvif); iwl_mvm_mac_init_mvmvif(mvm, mvmvif);
...@@ -32,7 +32,7 @@ static int iwl_mvm_mld_mac_add_interface(struct ieee80211_hw *hw, ...@@ -32,7 +32,7 @@ static int iwl_mvm_mld_mac_add_interface(struct ieee80211_hw *hw,
/* Allocate resources for the MAC context, and add it to the fw */ /* Allocate resources for the MAC context, and add it to the fw */
ret = iwl_mvm_mac_ctxt_init(mvm, vif); ret = iwl_mvm_mac_ctxt_init(mvm, vif);
if (ret) if (ret)
goto out_unlock; return ret;
rcu_assign_pointer(mvm->vif_id_to_mac[mvmvif->id], vif); rcu_assign_pointer(mvm->vif_id_to_mac[mvmvif->id], vif);
...@@ -46,7 +46,7 @@ static int iwl_mvm_mld_mac_add_interface(struct ieee80211_hw *hw, ...@@ -46,7 +46,7 @@ static int iwl_mvm_mld_mac_add_interface(struct ieee80211_hw *hw,
ret = iwl_mvm_mld_mac_ctxt_add(mvm, vif); ret = iwl_mvm_mld_mac_ctxt_add(mvm, vif);
if (ret) if (ret)
goto out_unlock; return ret;
/* beacon filtering */ /* beacon filtering */
ret = iwl_mvm_disable_beacon_filter(mvm, vif); ret = iwl_mvm_disable_beacon_filter(mvm, vif);
...@@ -97,7 +97,7 @@ static int iwl_mvm_mld_mac_add_interface(struct ieee80211_hw *hw, ...@@ -97,7 +97,7 @@ static int iwl_mvm_mld_mac_add_interface(struct ieee80211_hw *hw,
if (vif->p2p || iwl_fw_lookup_cmd_ver(mvm->fw, PHY_CONTEXT_CMD, 1) < 5) if (vif->p2p || iwl_fw_lookup_cmd_ver(mvm->fw, PHY_CONTEXT_CMD, 1) < 5)
vif->driver_flags |= IEEE80211_VIF_IGNORE_OFDMA_WIDER_BW; vif->driver_flags |= IEEE80211_VIF_IGNORE_OFDMA_WIDER_BW;
goto out_unlock; return 0;
out_free_bf: out_free_bf:
if (mvm->bf_allowed_vif == mvmvif) { if (mvm->bf_allowed_vif == mvmvif) {
...@@ -108,9 +108,6 @@ static int iwl_mvm_mld_mac_add_interface(struct ieee80211_hw *hw, ...@@ -108,9 +108,6 @@ static int iwl_mvm_mld_mac_add_interface(struct ieee80211_hw *hw,
out_remove_mac: out_remove_mac:
mvmvif->link[0] = NULL; mvmvif->link[0] = NULL;
iwl_mvm_mld_mac_ctxt_remove(mvm, vif); iwl_mvm_mld_mac_ctxt_remove(mvm, vif);
out_unlock:
mutex_unlock(&mvm->mutex);
return ret; return ret;
} }
...@@ -127,7 +124,7 @@ static void iwl_mvm_mld_mac_remove_interface(struct ieee80211_hw *hw, ...@@ -127,7 +124,7 @@ static void iwl_mvm_mld_mac_remove_interface(struct ieee80211_hw *hw,
vif->type == NL80211_IFTYPE_ADHOC)) vif->type == NL80211_IFTYPE_ADHOC))
iwl_mvm_tcm_rm_vif(mvm, vif); iwl_mvm_tcm_rm_vif(mvm, vif);
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
if (vif == mvm->csme_vif) { if (vif == mvm->csme_vif) {
iwl_mei_set_netdev(NULL); iwl_mei_set_netdev(NULL);
...@@ -190,8 +187,6 @@ static void iwl_mvm_mld_mac_remove_interface(struct ieee80211_hw *hw, ...@@ -190,8 +187,6 @@ static void iwl_mvm_mld_mac_remove_interface(struct ieee80211_hw *hw,
mvm->monitor_on = false; mvm->monitor_on = false;
__clear_bit(IEEE80211_HW_RX_INCLUDES_FCS, mvm->hw->flags); __clear_bit(IEEE80211_HW_RX_INCLUDES_FCS, mvm->hw->flags);
} }
mutex_unlock(&mvm->mutex);
} }
static unsigned int iwl_mvm_mld_count_active_links(struct iwl_mvm_vif *mvmvif) static unsigned int iwl_mvm_mld_count_active_links(struct iwl_mvm_vif *mvmvif)
...@@ -389,10 +384,11 @@ static int iwl_mvm_mld_assign_vif_chanctx(struct ieee80211_hw *hw, ...@@ -389,10 +384,11 @@ static int iwl_mvm_mld_assign_vif_chanctx(struct ieee80211_hw *hw,
struct ieee80211_chanctx_conf *ctx) struct ieee80211_chanctx_conf *ctx)
{ {
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
int ret;
/* update EMLSR mode */ /* update EMLSR mode */
if (ieee80211_vif_type_p2p(vif) != NL80211_IFTYPE_STATION) { if (ieee80211_vif_type_p2p(vif) != NL80211_IFTYPE_STATION) {
int ret;
ret = iwl_mvm_esr_non_bss_link(mvm, vif, link_conf->link_id, ret = iwl_mvm_esr_non_bss_link(mvm, vif, link_conf->link_id,
true); true);
/* /*
...@@ -403,11 +399,8 @@ static int iwl_mvm_mld_assign_vif_chanctx(struct ieee80211_hw *hw, ...@@ -403,11 +399,8 @@ static int iwl_mvm_mld_assign_vif_chanctx(struct ieee80211_hw *hw,
return ret; return ret;
} }
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
ret = __iwl_mvm_mld_assign_vif_chanctx(mvm, vif, link_conf, ctx, false); return __iwl_mvm_mld_assign_vif_chanctx(mvm, vif, link_conf, ctx, false);
mutex_unlock(&mvm->mutex);
return ret;
} }
static int iwl_mvm_esr_mode_inactive(struct iwl_mvm *mvm, static int iwl_mvm_esr_mode_inactive(struct iwl_mvm *mvm,
...@@ -586,7 +579,7 @@ static int iwl_mvm_mld_start_ap_ibss(struct ieee80211_hw *hw, ...@@ -586,7 +579,7 @@ static int iwl_mvm_mld_start_ap_ibss(struct ieee80211_hw *hw,
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
int ret; int ret;
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
if (vif->type == NL80211_IFTYPE_AP) if (vif->type == NL80211_IFTYPE_AP)
iwl_mvm_send_ap_tx_power_constraint_cmd(mvm, vif, link_conf); iwl_mvm_send_ap_tx_power_constraint_cmd(mvm, vif, link_conf);
...@@ -594,7 +587,7 @@ static int iwl_mvm_mld_start_ap_ibss(struct ieee80211_hw *hw, ...@@ -594,7 +587,7 @@ static int iwl_mvm_mld_start_ap_ibss(struct ieee80211_hw *hw,
/* Send the beacon template */ /* Send the beacon template */
ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif, link_conf); ret = iwl_mvm_mac_ctxt_beacon_changed(mvm, vif, link_conf);
if (ret) if (ret)
goto out_unlock; return ret;
/* the link should be already activated when assigning chan context */ /* the link should be already activated when assigning chan context */
ret = iwl_mvm_link_changed(mvm, vif, link_conf, ret = iwl_mvm_link_changed(mvm, vif, link_conf,
...@@ -602,11 +595,11 @@ static int iwl_mvm_mld_start_ap_ibss(struct ieee80211_hw *hw, ...@@ -602,11 +595,11 @@ static int iwl_mvm_mld_start_ap_ibss(struct ieee80211_hw *hw,
~LINK_CONTEXT_MODIFY_ACTIVE, ~LINK_CONTEXT_MODIFY_ACTIVE,
true); true);
if (ret) if (ret)
goto out_unlock; return ret;
ret = iwl_mvm_mld_add_mcast_sta(mvm, vif, link_conf); ret = iwl_mvm_mld_add_mcast_sta(mvm, vif, link_conf);
if (ret) if (ret)
goto out_unlock; return ret;
/* Send the bcast station. At this stage the TBTT and DTIM time /* Send the bcast station. At this stage the TBTT and DTIM time
* events are added and applied to the scheduler * events are added and applied to the scheduler
...@@ -630,7 +623,7 @@ static int iwl_mvm_mld_start_ap_ibss(struct ieee80211_hw *hw, ...@@ -630,7 +623,7 @@ static int iwl_mvm_mld_start_ap_ibss(struct ieee80211_hw *hw,
iwl_mvm_ftm_restart_responder(mvm, vif, link_conf); iwl_mvm_ftm_restart_responder(mvm, vif, link_conf);
goto out_unlock; return 0;
out_failed: out_failed:
iwl_mvm_power_update_mac(mvm); iwl_mvm_power_update_mac(mvm);
...@@ -638,8 +631,6 @@ static int iwl_mvm_mld_start_ap_ibss(struct ieee80211_hw *hw, ...@@ -638,8 +631,6 @@ static int iwl_mvm_mld_start_ap_ibss(struct ieee80211_hw *hw,
iwl_mvm_mld_rm_bcast_sta(mvm, vif, link_conf); iwl_mvm_mld_rm_bcast_sta(mvm, vif, link_conf);
out_rm_mcast: out_rm_mcast:
iwl_mvm_mld_rm_mcast_sta(mvm, vif, link_conf); iwl_mvm_mld_rm_mcast_sta(mvm, vif, link_conf);
out_unlock:
mutex_unlock(&mvm->mutex);
return ret; return ret;
} }
...@@ -662,7 +653,7 @@ static void iwl_mvm_mld_stop_ap_ibss(struct ieee80211_hw *hw, ...@@ -662,7 +653,7 @@ static void iwl_mvm_mld_stop_ap_ibss(struct ieee80211_hw *hw,
{ {
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
iwl_mvm_stop_ap_ibss_common(mvm, vif); iwl_mvm_stop_ap_ibss_common(mvm, vif);
...@@ -676,7 +667,6 @@ static void iwl_mvm_mld_stop_ap_ibss(struct ieee80211_hw *hw, ...@@ -676,7 +667,6 @@ static void iwl_mvm_mld_stop_ap_ibss(struct ieee80211_hw *hw,
iwl_mvm_mld_rm_mcast_sta(mvm, vif, link_conf); iwl_mvm_mld_rm_mcast_sta(mvm, vif, link_conf);
iwl_mvm_power_update_mac(mvm); iwl_mvm_power_update_mac(mvm);
mutex_unlock(&mvm->mutex);
} }
static void iwl_mvm_mld_stop_ap(struct ieee80211_hw *hw, static void iwl_mvm_mld_stop_ap(struct ieee80211_hw *hw,
...@@ -979,7 +969,7 @@ static void iwl_mvm_mld_link_info_changed(struct ieee80211_hw *hw, ...@@ -979,7 +969,7 @@ static void iwl_mvm_mld_link_info_changed(struct ieee80211_hw *hw,
{ {
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
switch (vif->type) { switch (vif->type) {
case NL80211_IFTYPE_STATION: case NL80211_IFTYPE_STATION:
...@@ -1005,8 +995,6 @@ static void iwl_mvm_mld_link_info_changed(struct ieee80211_hw *hw, ...@@ -1005,8 +995,6 @@ static void iwl_mvm_mld_link_info_changed(struct ieee80211_hw *hw,
link_conf->txpower); link_conf->txpower);
iwl_mvm_set_tx_power(mvm, vif, link_conf->txpower); iwl_mvm_set_tx_power(mvm, vif, link_conf->txpower);
} }
mutex_unlock(&mvm->mutex);
} }
static void iwl_mvm_mld_vif_cfg_changed(struct ieee80211_hw *hw, static void iwl_mvm_mld_vif_cfg_changed(struct ieee80211_hw *hw,
...@@ -1015,15 +1003,13 @@ static void iwl_mvm_mld_vif_cfg_changed(struct ieee80211_hw *hw, ...@@ -1015,15 +1003,13 @@ static void iwl_mvm_mld_vif_cfg_changed(struct ieee80211_hw *hw,
{ {
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
if (changes & BSS_CHANGED_IDLE && !vif->cfg.idle) if (changes & BSS_CHANGED_IDLE && !vif->cfg.idle)
iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_SCHED, true); iwl_mvm_scan_stop(mvm, IWL_MVM_SCAN_SCHED, true);
if (vif->type == NL80211_IFTYPE_STATION) if (vif->type == NL80211_IFTYPE_STATION)
iwl_mvm_mld_vif_cfg_changed_station(mvm, vif, changes); iwl_mvm_mld_vif_cfg_changed_station(mvm, vif, changes);
mutex_unlock(&mvm->mutex);
} }
static int static int
...@@ -1056,9 +1042,8 @@ static void iwl_mvm_mld_config_iface_filter(struct ieee80211_hw *hw, ...@@ -1056,9 +1042,8 @@ static void iwl_mvm_mld_config_iface_filter(struct ieee80211_hw *hw,
!vif->p2p) !vif->p2p)
return; return;
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
iwl_mvm_mld_mac_ctxt_changed(mvm, vif, false); iwl_mvm_mld_mac_ctxt_changed(mvm, vif, false);
mutex_unlock(&mvm->mutex);
} }
static int static int
...@@ -1080,14 +1065,10 @@ iwl_mvm_mld_mac_conf_tx(struct ieee80211_hw *hw, ...@@ -1080,14 +1065,10 @@ iwl_mvm_mld_mac_conf_tx(struct ieee80211_hw *hw,
* The exception is P2P_DEVICE interface which needs immediate update. * The exception is P2P_DEVICE interface which needs immediate update.
*/ */
if (vif->type == NL80211_IFTYPE_P2P_DEVICE) { if (vif->type == NL80211_IFTYPE_P2P_DEVICE) {
int ret; guard(mvm)(mvm);
return iwl_mvm_link_changed(mvm, vif, &vif->bss_conf,
mutex_lock(&mvm->mutex);
ret = iwl_mvm_link_changed(mvm, vif, &vif->bss_conf,
LINK_CONTEXT_MODIFY_QOS_PARAMS, LINK_CONTEXT_MODIFY_QOS_PARAMS,
true); true);
mutex_unlock(&mvm->mutex);
return ret;
} }
return 0; return 0;
} }
...@@ -1232,13 +1213,9 @@ iwl_mvm_mld_change_sta_links(struct ieee80211_hw *hw, ...@@ -1232,13 +1213,9 @@ iwl_mvm_mld_change_sta_links(struct ieee80211_hw *hw,
u16 old_links, u16 new_links) u16 old_links, u16 new_links)
{ {
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
int ret;
mutex_lock(&mvm->mutex);
ret = iwl_mvm_mld_update_sta_links(mvm, vif, sta, old_links, new_links);
mutex_unlock(&mvm->mutex);
return ret; guard(mvm)(mvm);
return iwl_mvm_mld_update_sta_links(mvm, vif, sta, old_links, new_links);
} }
bool iwl_mvm_vif_has_esr_cap(struct iwl_mvm *mvm, struct ieee80211_vif *vif) bool iwl_mvm_vif_has_esr_cap(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
...@@ -1266,26 +1243,19 @@ static bool iwl_mvm_mld_can_activate_links(struct ieee80211_hw *hw, ...@@ -1266,26 +1243,19 @@ static bool iwl_mvm_mld_can_activate_links(struct ieee80211_hw *hw,
{ {
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
int n_links = hweight16(desired_links); int n_links = hweight16(desired_links);
bool ret = true;
if (n_links <= 1) if (n_links <= 1)
return true; return true;
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
/* Check if HW supports the wanted number of links */ /* Check if HW supports the wanted number of links */
if (n_links > iwl_mvm_max_active_links(mvm, vif)) { if (n_links > iwl_mvm_max_active_links(mvm, vif))
ret = false; return false;
goto unlock;
}
/* If it is an eSR device, check that we can enter eSR */ /* If it is an eSR device, check that we can enter eSR */
ret = iwl_mvm_is_esr_supported(mvm->fwrt.trans) && return iwl_mvm_is_esr_supported(mvm->fwrt.trans) &&
iwl_mvm_vif_has_esr_cap(mvm, vif); iwl_mvm_vif_has_esr_cap(mvm, vif);
unlock:
mutex_unlock(&mvm->mutex);
return ret;
} }
static enum ieee80211_neg_ttlm_res static enum ieee80211_neg_ttlm_res
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/cleanup.h>
#include <linux/leds.h> #include <linux/leds.h>
#include <linux/in6.h> #include <linux/in6.h>
...@@ -1332,6 +1333,8 @@ struct iwl_mvm { ...@@ -1332,6 +1333,8 @@ struct iwl_mvm {
#define IWL_MAC80211_GET_MVM(_hw) \ #define IWL_MAC80211_GET_MVM(_hw) \
IWL_OP_MODE_GET_MVM((struct iwl_op_mode *)((_hw)->priv)) IWL_OP_MODE_GET_MVM((struct iwl_op_mode *)((_hw)->priv))
DEFINE_GUARD(mvm, struct iwl_mvm *, mutex_lock(&_T->mutex), mutex_unlock(&_T->mutex))
/** /**
* enum iwl_mvm_status - MVM status bits * enum iwl_mvm_status - MVM status bits
* @IWL_MVM_STATUS_HW_RFKILL: HW RF-kill is asserted * @IWL_MVM_STATUS_HW_RFKILL: HW RF-kill is asserted
......
...@@ -765,20 +765,18 @@ static void iwl_mvm_tx_unblock_dwork(struct work_struct *work) ...@@ -765,20 +765,18 @@ static void iwl_mvm_tx_unblock_dwork(struct work_struct *work)
struct ieee80211_vif *tx_blocked_vif; struct ieee80211_vif *tx_blocked_vif;
struct iwl_mvm_vif *mvmvif; struct iwl_mvm_vif *mvmvif;
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
tx_blocked_vif = tx_blocked_vif =
rcu_dereference_protected(mvm->csa_tx_blocked_vif, rcu_dereference_protected(mvm->csa_tx_blocked_vif,
lockdep_is_held(&mvm->mutex)); lockdep_is_held(&mvm->mutex));
if (!tx_blocked_vif) if (!tx_blocked_vif)
goto unlock; return;
mvmvif = iwl_mvm_vif_from_mac80211(tx_blocked_vif); mvmvif = iwl_mvm_vif_from_mac80211(tx_blocked_vif);
iwl_mvm_modify_all_sta_disable_tx(mvm, mvmvif, false); iwl_mvm_modify_all_sta_disable_tx(mvm, mvmvif, false);
RCU_INIT_POINTER(mvm->csa_tx_blocked_vif, NULL); RCU_INIT_POINTER(mvm->csa_tx_blocked_vif, NULL);
unlock:
mutex_unlock(&mvm->mutex);
} }
static void iwl_mvm_fwrt_dump_start(void *ctx) static void iwl_mvm_fwrt_dump_start(void *ctx)
...@@ -798,13 +796,9 @@ static void iwl_mvm_fwrt_dump_end(void *ctx) ...@@ -798,13 +796,9 @@ static void iwl_mvm_fwrt_dump_end(void *ctx)
static int iwl_mvm_fwrt_send_hcmd(void *ctx, struct iwl_host_cmd *host_cmd) static int iwl_mvm_fwrt_send_hcmd(void *ctx, struct iwl_host_cmd *host_cmd)
{ {
struct iwl_mvm *mvm = (struct iwl_mvm *)ctx; struct iwl_mvm *mvm = (struct iwl_mvm *)ctx;
int ret;
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
ret = iwl_mvm_send_cmd(mvm, host_cmd); return iwl_mvm_send_cmd(mvm, host_cmd);
mutex_unlock(&mvm->mutex);
return ret;
} }
static bool iwl_mvm_d3_debug_enable(void *ctx) static bool iwl_mvm_d3_debug_enable(void *ctx)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* /*
* Copyright (C) 2014 Intel Mobile Communications GmbH * Copyright (C) 2014 Intel Mobile Communications GmbH
* Copyright (C) 2017 Intel Deutschland GmbH * Copyright (C) 2017 Intel Deutschland GmbH
* Copyright (C) 2018-2020, 2022-2023 Intel Corporation * Copyright (C) 2018-2020, 2022-2024 Intel Corporation
*/ */
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include "mvm.h" #include "mvm.h"
...@@ -151,7 +151,7 @@ void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw, ...@@ -151,7 +151,7 @@ void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw,
u32 duration = 2 * vif->bss_conf.dtim_period * vif->bss_conf.beacon_int; u32 duration = 2 * vif->bss_conf.dtim_period * vif->bss_conf.beacon_int;
/* Protect the session to hear the TDLS setup response on the channel */ /* Protect the session to hear the TDLS setup response on the channel */
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
if (fw_has_capa(&mvm->fw->ucode_capa, if (fw_has_capa(&mvm->fw->ucode_capa,
IWL_UCODE_TLV_CAPA_SESSION_PROT_CMD)) IWL_UCODE_TLV_CAPA_SESSION_PROT_CMD))
iwl_mvm_schedule_session_protection(mvm, vif, duration, iwl_mvm_schedule_session_protection(mvm, vif, duration,
...@@ -159,7 +159,6 @@ void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw, ...@@ -159,7 +159,6 @@ void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw,
else else
iwl_mvm_protect_session(mvm, vif, duration, iwl_mvm_protect_session(mvm, vif, duration,
duration, 100, true); duration, 100, true);
mutex_unlock(&mvm->mutex);
} }
static const char * static const char *
...@@ -460,21 +459,21 @@ void iwl_mvm_tdls_ch_switch_work(struct work_struct *work) ...@@ -460,21 +459,21 @@ void iwl_mvm_tdls_ch_switch_work(struct work_struct *work)
int ret; int ret;
mvm = container_of(work, struct iwl_mvm, tdls_cs.dwork.work); mvm = container_of(work, struct iwl_mvm, tdls_cs.dwork.work);
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
/* called after an active channel switch has finished or timed-out */ /* called after an active channel switch has finished or timed-out */
iwl_mvm_tdls_update_cs_state(mvm, IWL_MVM_TDLS_SW_IDLE); iwl_mvm_tdls_update_cs_state(mvm, IWL_MVM_TDLS_SW_IDLE);
/* station might be gone, in that case do nothing */ /* station might be gone, in that case do nothing */
if (mvm->tdls_cs.peer.sta_id == IWL_MVM_INVALID_STA) if (mvm->tdls_cs.peer.sta_id == IWL_MVM_INVALID_STA)
goto out; return;
sta = rcu_dereference_protected( sta = rcu_dereference_protected(
mvm->fw_id_to_mac_id[mvm->tdls_cs.peer.sta_id], mvm->fw_id_to_mac_id[mvm->tdls_cs.peer.sta_id],
lockdep_is_held(&mvm->mutex)); lockdep_is_held(&mvm->mutex));
/* the station may not be here, but if it is, it must be a TDLS peer */ /* the station may not be here, but if it is, it must be a TDLS peer */
if (!sta || IS_ERR(sta) || WARN_ON(!sta->tdls)) if (!sta || IS_ERR(sta) || WARN_ON(!sta->tdls))
goto out; return;
mvmsta = iwl_mvm_sta_from_mac80211(sta); mvmsta = iwl_mvm_sta_from_mac80211(sta);
vif = mvmsta->vif; vif = mvmsta->vif;
...@@ -493,8 +492,6 @@ void iwl_mvm_tdls_ch_switch_work(struct work_struct *work) ...@@ -493,8 +492,6 @@ void iwl_mvm_tdls_ch_switch_work(struct work_struct *work)
/* retry after a DTIM if we failed sending now */ /* retry after a DTIM if we failed sending now */
delay = TU_TO_MS(vif->bss_conf.dtim_period * vif->bss_conf.beacon_int); delay = TU_TO_MS(vif->bss_conf.dtim_period * vif->bss_conf.beacon_int);
schedule_delayed_work(&mvm->tdls_cs.dwork, msecs_to_jiffies(delay)); schedule_delayed_work(&mvm->tdls_cs.dwork, msecs_to_jiffies(delay));
out:
mutex_unlock(&mvm->mutex);
} }
int int
...@@ -509,7 +506,7 @@ iwl_mvm_tdls_channel_switch(struct ieee80211_hw *hw, ...@@ -509,7 +506,7 @@ iwl_mvm_tdls_channel_switch(struct ieee80211_hw *hw,
unsigned int delay; unsigned int delay;
int ret; int ret;
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
IWL_DEBUG_TDLS(mvm, "TDLS channel switch with %pM ch %d width %d\n", IWL_DEBUG_TDLS(mvm, "TDLS channel switch with %pM ch %d width %d\n",
sta->addr, chandef->chan->center_freq, chandef->width); sta->addr, chandef->chan->center_freq, chandef->width);
...@@ -519,8 +516,7 @@ iwl_mvm_tdls_channel_switch(struct ieee80211_hw *hw, ...@@ -519,8 +516,7 @@ iwl_mvm_tdls_channel_switch(struct ieee80211_hw *hw,
IWL_DEBUG_TDLS(mvm, IWL_DEBUG_TDLS(mvm,
"Existing peer. Can't start switch with %pM\n", "Existing peer. Can't start switch with %pM\n",
sta->addr); sta->addr);
ret = -EBUSY; return -EBUSY;
goto out;
} }
ret = iwl_mvm_tdls_config_channel_switch(mvm, vif, ret = iwl_mvm_tdls_config_channel_switch(mvm, vif,
...@@ -529,17 +525,15 @@ iwl_mvm_tdls_channel_switch(struct ieee80211_hw *hw, ...@@ -529,17 +525,15 @@ iwl_mvm_tdls_channel_switch(struct ieee80211_hw *hw,
oper_class, chandef, 0, 0, 0, oper_class, chandef, 0, 0, 0,
tmpl_skb, ch_sw_tm_ie); tmpl_skb, ch_sw_tm_ie);
if (ret) if (ret)
goto out; return ret;
/* /*
* Mark the peer as "in tdls switch" for this vif. We only allow a * Mark the peer as "in tdls switch" for this vif. We only allow a
* single such peer per vif. * single such peer per vif.
*/ */
mvm->tdls_cs.peer.skb = skb_copy(tmpl_skb, GFP_KERNEL); mvm->tdls_cs.peer.skb = skb_copy(tmpl_skb, GFP_KERNEL);
if (!mvm->tdls_cs.peer.skb) { if (!mvm->tdls_cs.peer.skb)
ret = -ENOMEM; return -ENOMEM;
goto out;
}
mvmsta = iwl_mvm_sta_from_mac80211(sta); mvmsta = iwl_mvm_sta_from_mac80211(sta);
mvm->tdls_cs.peer.sta_id = mvmsta->deflink.sta_id; mvm->tdls_cs.peer.sta_id = mvmsta->deflink.sta_id;
...@@ -556,10 +550,7 @@ iwl_mvm_tdls_channel_switch(struct ieee80211_hw *hw, ...@@ -556,10 +550,7 @@ iwl_mvm_tdls_channel_switch(struct ieee80211_hw *hw,
vif->bss_conf.beacon_int); vif->bss_conf.beacon_int);
mod_delayed_work(system_wq, &mvm->tdls_cs.dwork, mod_delayed_work(system_wq, &mvm->tdls_cs.dwork,
msecs_to_jiffies(delay)); msecs_to_jiffies(delay));
return 0;
out:
mutex_unlock(&mvm->mutex);
return ret;
} }
void iwl_mvm_tdls_cancel_channel_switch(struct ieee80211_hw *hw, void iwl_mvm_tdls_cancel_channel_switch(struct ieee80211_hw *hw,
...@@ -626,7 +617,7 @@ iwl_mvm_tdls_recv_channel_switch(struct ieee80211_hw *hw, ...@@ -626,7 +617,7 @@ iwl_mvm_tdls_recv_channel_switch(struct ieee80211_hw *hw,
params->action_code == WLAN_TDLS_CHANNEL_SWITCH_REQUEST ? params->action_code == WLAN_TDLS_CHANNEL_SWITCH_REQUEST ?
"REQ" : "RESP"; "REQ" : "RESP";
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
IWL_DEBUG_TDLS(mvm, IWL_DEBUG_TDLS(mvm,
"Received TDLS ch switch action %s from %pM status %d\n", "Received TDLS ch switch action %s from %pM status %d\n",
...@@ -670,5 +661,4 @@ iwl_mvm_tdls_recv_channel_switch(struct ieee80211_hw *hw, ...@@ -670,5 +661,4 @@ iwl_mvm_tdls_recv_channel_switch(struct ieee80211_hw *hw,
1024 / 1000; 1024 / 1000;
mod_delayed_work(system_wq, &mvm->tdls_cs.dwork, mod_delayed_work(system_wq, &mvm->tdls_cs.dwork,
msecs_to_jiffies(delay)); msecs_to_jiffies(delay));
mutex_unlock(&mvm->mutex);
} }
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/* /*
* Copyright (C) 2012-2014, 2019-2022 Intel Corporation * Copyright (C) 2012-2014, 2019-2022, 2024 Intel Corporation
* Copyright (C) 2013-2014 Intel Mobile Communications GmbH * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
* Copyright (C) 2015-2016 Intel Deutschland GmbH * Copyright (C) 2015-2016 Intel Deutschland GmbH
*/ */
...@@ -618,48 +618,35 @@ static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device, ...@@ -618,48 +618,35 @@ static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,
int ret; int ret;
int temp; int temp;
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
if (!iwl_mvm_firmware_running(mvm) || if (!iwl_mvm_firmware_running(mvm) ||
mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) { mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
ret = -ENODATA; return -ENODATA;
goto out;
}
ret = iwl_mvm_get_temp(mvm, &temp); ret = iwl_mvm_get_temp(mvm, &temp);
if (ret) if (ret)
goto out; return ret;
*temperature = temp * 1000; *temperature = temp * 1000;
return 0;
out:
mutex_unlock(&mvm->mutex);
return ret;
} }
static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device, static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,
int trip, int temp) int trip, int temp)
{ {
struct iwl_mvm *mvm = thermal_zone_device_priv(device); struct iwl_mvm *mvm = thermal_zone_device_priv(device);
int ret;
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
if (!iwl_mvm_firmware_running(mvm) || if (!iwl_mvm_firmware_running(mvm) ||
mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) { mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
ret = -EIO; return -EIO;
goto out;
}
if ((temp / 1000) > S16_MAX) { if ((temp / 1000) > S16_MAX)
ret = -EINVAL; return -EINVAL;
goto out;
}
ret = iwl_mvm_send_temp_report_ths_cmd(mvm); return iwl_mvm_send_temp_report_ths_cmd(mvm);
out:
mutex_unlock(&mvm->mutex);
return ret;
} }
static struct thermal_zone_device_ops tzone_ops = { static struct thermal_zone_device_ops tzone_ops = {
...@@ -733,27 +720,18 @@ static int iwl_mvm_tcool_set_cur_state(struct thermal_cooling_device *cdev, ...@@ -733,27 +720,18 @@ static int iwl_mvm_tcool_set_cur_state(struct thermal_cooling_device *cdev,
unsigned long new_state) unsigned long new_state)
{ {
struct iwl_mvm *mvm = (struct iwl_mvm *)(cdev->devdata); struct iwl_mvm *mvm = (struct iwl_mvm *)(cdev->devdata);
int ret;
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
if (!iwl_mvm_firmware_running(mvm) || if (!iwl_mvm_firmware_running(mvm) ||
mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) { mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
ret = -EIO; return -EIO;
goto unlock;
}
if (new_state >= ARRAY_SIZE(iwl_mvm_cdev_budgets)) { if (new_state >= ARRAY_SIZE(iwl_mvm_cdev_budgets))
ret = -EINVAL; return -EINVAL;
goto unlock;
}
ret = iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_START, return iwl_mvm_ctdp_command(mvm, CTDP_CMD_OPERATION_START,
new_state); new_state);
unlock:
mutex_unlock(&mvm->mutex);
return ret;
} }
static const struct thermal_cooling_device_ops tcooling_ops = { static const struct thermal_cooling_device_ops tcooling_ops = {
......
...@@ -892,7 +892,7 @@ static void iwl_mvm_tcm_iter(void *_data, u8 *mac, struct ieee80211_vif *vif) ...@@ -892,7 +892,7 @@ static void iwl_mvm_tcm_iter(void *_data, u8 *mac, struct ieee80211_vif *vif)
static void iwl_mvm_tcm_results(struct iwl_mvm *mvm) static void iwl_mvm_tcm_results(struct iwl_mvm *mvm)
{ {
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
ieee80211_iterate_active_interfaces( ieee80211_iterate_active_interfaces(
mvm->hw, IEEE80211_IFACE_ITER_NORMAL, mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
...@@ -900,8 +900,6 @@ static void iwl_mvm_tcm_results(struct iwl_mvm *mvm) ...@@ -900,8 +900,6 @@ static void iwl_mvm_tcm_results(struct iwl_mvm *mvm)
if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN)) if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_UMAC_SCAN))
iwl_mvm_config_scan(mvm); iwl_mvm_config_scan(mvm);
mutex_unlock(&mvm->mutex);
} }
static void iwl_mvm_tcm_uapsd_nonagg_detected_wk(struct work_struct *wk) static void iwl_mvm_tcm_uapsd_nonagg_detected_wk(struct work_struct *wk)
...@@ -1130,10 +1128,9 @@ void iwl_mvm_recalc_tcm(struct iwl_mvm *mvm) ...@@ -1130,10 +1128,9 @@ void iwl_mvm_recalc_tcm(struct iwl_mvm *mvm)
spin_unlock(&mvm->tcm.lock); spin_unlock(&mvm->tcm.lock);
if (handle_uapsd && iwl_mvm_has_new_rx_api(mvm)) { if (handle_uapsd && iwl_mvm_has_new_rx_api(mvm)) {
mutex_lock(&mvm->mutex); guard(mvm)(mvm);
if (iwl_mvm_request_statistics(mvm, true)) if (iwl_mvm_request_statistics(mvm, true))
handle_uapsd = false; handle_uapsd = false;
mutex_unlock(&mvm->mutex);
} }
spin_lock(&mvm->tcm.lock); spin_lock(&mvm->tcm.lock);
......
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