wifi: iwlwifi: mvm: clarify fw_id_to_link_sta protection
authorJohannes Berg <johannes.berg@intel.com>
Mon, 28 Oct 2024 11:54:46 +0000 (13:54 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 7 Nov 2024 13:42:28 +0000 (14:42 +0100)
This is written only with wiphy and mvm mutexes held, but in
order to actually rely on that document it and add lockdep
assertions to ensure it.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20241028135215.a6c6aa4147cf.If7f1b30a7b92ce5e9226e8972201a20aa9905108@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/fw.c
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
drivers/net/wireless/intel/iwlwifi/mvm/mld-sta.c
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h

index 08546e673cf51ea5dbec8702453fa9c44862e9a0..1b62bb92ee934032b93cb34aba9a579ce71e18df 100644 (file)
@@ -1403,6 +1403,7 @@ int iwl_mvm_up(struct iwl_mvm *mvm)
        int ret, i;
        struct ieee80211_supported_band *sband = NULL;
 
+       lockdep_assert_wiphy(mvm->hw->wiphy);
        lockdep_assert_held(&mvm->mutex);
 
        ret = iwl_trans_start_hw(mvm->trans);
@@ -1622,6 +1623,7 @@ int iwl_mvm_load_d3_fw(struct iwl_mvm *mvm)
 {
        int ret, i;
 
+       lockdep_assert_wiphy(mvm->hw->wiphy);
        lockdep_assert_held(&mvm->mutex);
 
        ret = iwl_trans_start_hw(mvm->trans);
index 4db7c3ee6bf5bf6d36107972a68fdff6372e196c..7c60519905690d67219a4c34a8652a276776963e 100644 (file)
@@ -3516,6 +3516,8 @@ void iwl_mvm_sta_pre_rcu_remove(struct ieee80211_hw *hw,
        struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta);
        unsigned int link_id;
 
+       lockdep_assert_wiphy(mvm->hw->wiphy);
+
        /*
         * This is called before mac80211 does RCU synchronisation,
         * so here we already invalidate our internal RCU-protected
index 99eb1e1db1bb17028e1e1d31a7138ea66bb82c0f..1a096f1b187056cffaa0d17103e2b945ec69da20 100644 (file)
@@ -521,6 +521,9 @@ void iwl_mvm_mld_free_sta_link(struct iwl_mvm *mvm,
                               unsigned int link_id,
                               bool is_in_fw)
 {
+       lockdep_assert_wiphy(mvm->hw->wiphy);
+       lockdep_assert_held(&mvm->mutex);
+
        RCU_INIT_POINTER(mvm->fw_id_to_mac_id[mvm_sta_link->sta_id],
                         is_in_fw ? ERR_PTR(-EINVAL) : NULL);
        RCU_INIT_POINTER(mvm->fw_id_to_link_sta[mvm_sta_link->sta_id], NULL);
@@ -559,6 +562,9 @@ static int iwl_mvm_mld_alloc_sta_link(struct iwl_mvm *mvm,
        u32 sta_id = iwl_mvm_find_free_sta_id(mvm,
                                          ieee80211_vif_type_p2p(vif));
 
+       lockdep_assert_wiphy(mvm->hw->wiphy);
+       lockdep_assert_held(&mvm->mutex);
+
        if (sta_id == IWL_MVM_INVALID_STA)
                return -ENOSPC;
 
@@ -631,6 +637,9 @@ static int iwl_mvm_alloc_sta_after_restart(struct iwl_mvm *mvm,
        int ret = -EINVAL;
        int sta_id;
 
+       lockdep_assert_wiphy(mvm->hw->wiphy);
+       lockdep_assert_held(&mvm->mutex);
+
        /* First add an empty station since allocating a queue requires
         * a valid station. Since we need a link_id to allocate a station,
         * pick up the first valid one.
@@ -858,6 +867,7 @@ int iwl_mvm_mld_rm_sta_id(struct iwl_mvm *mvm, u8 sta_id)
 {
        int ret;
 
+       lockdep_assert_wiphy(mvm->hw->wiphy);
        lockdep_assert_held(&mvm->mutex);
 
        if (WARN_ON(sta_id == IWL_MVM_INVALID_STA))
@@ -1064,6 +1074,7 @@ int iwl_mvm_mld_update_sta_links(struct iwl_mvm *mvm,
        unsigned int link_id;
        int ret;
 
+       lockdep_assert_wiphy(mvm->hw->wiphy);
        lockdep_assert_held(&mvm->mutex);
 
        for_each_set_bit(link_id, &old_links_long,
index 5aa48c77b05456a888b45cf3371523f2cb0fb0d0..5d85661e01f5a22a609e72a6ecf36b049a450fe8 100644 (file)
@@ -1082,6 +1082,7 @@ struct iwl_mvm {
        /* data related to data path */
        struct iwl_rx_phy_info last_phy_info;
        struct ieee80211_sta __rcu *fw_id_to_mac_id[IWL_STATION_COUNT_MAX];
+       /* note: fw_id_to_link_sta must be protected by wiphy and mvm mutexes */
        struct ieee80211_link_sta __rcu *fw_id_to_link_sta[IWL_STATION_COUNT_MAX];
        u8 rx_ba_sessions;