wifi: iwlwifi: mvm: fix active link counting during recovery
authorBenjamin Berg <benjamin.berg@intel.com>
Wed, 20 Mar 2024 21:26:25 +0000 (23:26 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 25 Mar 2024 14:39:54 +0000 (15:39 +0100)
During recovery, the chanctx_conf in mac80211 is still non-NULL even
though the channel context has not yet been assigned again. In that
case, the real count is actually lower.

Switch to instead count the phy_ctx assignment and ensure that the
assignment is cleared at the start of recovery.

Fixes: 12bacfc2c065 ("wifi: iwlwifi: handle eSR transitions")
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://msgid.link/20240320232419.55f37339e7d1.I57006568a90ffb7a1232def1b2f3264dea711ba6@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/mld-mac80211.c

index 084314bf6f369ad29e9222a6549d548b4e094731..d18304ac126cda98466d38eb3f1a0b6fee4b6928 100644 (file)
@@ -189,17 +189,13 @@ static void iwl_mvm_mld_mac_remove_interface(struct ieee80211_hw *hw,
        mutex_unlock(&mvm->mutex);
 }
 
-static unsigned int iwl_mvm_mld_count_active_links(struct ieee80211_vif *vif)
+static unsigned int iwl_mvm_mld_count_active_links(struct iwl_mvm_vif *mvmvif)
 {
        unsigned int n_active = 0;
        int i;
 
        for (i = 0; i < IEEE80211_MLD_MAX_NUM_LINKS; i++) {
-               struct ieee80211_bss_conf *link_conf;
-
-               link_conf = link_conf_dereference_protected(vif, i);
-               if (link_conf &&
-                   rcu_access_pointer(link_conf->chanctx_conf))
+               if (mvmvif->link[i] && mvmvif->link[i]->phy_ctxt)
                        n_active++;
        }
 
@@ -245,18 +241,18 @@ __iwl_mvm_mld_assign_vif_chanctx(struct iwl_mvm *mvm,
 {
        u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
        struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
-       unsigned int n_active = iwl_mvm_mld_count_active_links(vif);
        struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
+       unsigned int n_active = iwl_mvm_mld_count_active_links(mvmvif);
        unsigned int link_id = link_conf->link_id;
        int ret;
 
-       /* if the assigned one was not counted yet, count it now */
-       if (!rcu_access_pointer(link_conf->chanctx_conf))
-               n_active++;
-
        if (WARN_ON_ONCE(!mvmvif->link[link_id]))
                return -EINVAL;
 
+       /* if the assigned one was not counted yet, count it now */
+       if (!mvmvif->link[link_id]->phy_ctxt)
+               n_active++;
+
        /* mac parameters such as HE support can change at this stage
         * For sta, need first to configure correct state from drv_sta_state
         * and only after that update mac config.
@@ -416,7 +412,7 @@ __iwl_mvm_mld_unassign_vif_chanctx(struct iwl_mvm *mvm,
 
 {
        struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
-       unsigned int n_active = iwl_mvm_mld_count_active_links(vif);
+       unsigned int n_active = iwl_mvm_mld_count_active_links(mvmvif);
        unsigned int link_id = link_conf->link_id;
 
        /* shouldn't happen, but verify link_id is valid before accessing */