iwlwifi: mvm: move only to an enabled channel
authorMiri Korenblit <miriam.rachel.korenblit@intel.com>
Thu, 10 Feb 2022 16:22:33 +0000 (18:22 +0200)
committerLuca Coelho <luciano.coelho@intel.com>
Fri, 18 Feb 2022 08:40:55 +0000 (10:40 +0200)
During disassociation we're decreasing the phy's ref count.
If the ref count becomes 0, we're configuring the phy ctxt
to the default channel (the lowest channel which the device
can operate on). Currently we're not checking whether the
the default channel is enabled or not. Fix it by configuring
the phy ctxt to the lowest channel which is enabled.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20220210181930.03f281b6a6bc.I5b63d43ec41996d599e6f37ec3f32e878b3e405e@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/phy-ctxt.c

index 24d86ca..a3cefbc 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright (C) 2012-2014, 2018-2021 Intel Corporation
+ * Copyright (C) 2012-2014, 2018-2022 Intel Corporation
  * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
  * Copyright (C) 2017 Intel Deutschland GmbH
  */
@@ -345,18 +345,31 @@ void iwl_mvm_phy_ctxt_unref(struct iwl_mvm *mvm, struct iwl_mvm_phy_ctxt *ctxt)
         * otherwise we might not be able to reuse this phy.
         */
        if (ctxt->ref == 0) {
-               struct ieee80211_channel *chan;
+               struct ieee80211_channel *chan = NULL;
                struct cfg80211_chan_def chandef;
-               struct ieee80211_supported_band *sband = NULL;
-               enum nl80211_band band = NL80211_BAND_2GHZ;
+               struct ieee80211_supported_band *sband;
+               enum nl80211_band band;
+               int channel;
 
-               while (!sband && band < NUM_NL80211_BANDS)
-                       sband = mvm->hw->wiphy->bands[band++];
+               for (band = NL80211_BAND_2GHZ; band < NUM_NL80211_BANDS; band++) {
+                       sband = mvm->hw->wiphy->bands[band];
 
-               if (WARN_ON(!sband))
-                       return;
+                       if (!sband)
+                               continue;
+
+                       for (channel = 0; channel < sband->n_channels; channel++)
+                               if (!(sband->channels[channel].flags &
+                                               IEEE80211_CHAN_DISABLED)) {
+                                       chan = &sband->channels[channel];
+                                       break;
+                               }
 
-               chan = &sband->channels[0];
+                       if (chan)
+                               break;
+               }
+
+               if (WARN_ON(!chan))
+                       return;
 
                cfg80211_chandef_create(&chandef, chan, NL80211_CHAN_NO_HT);
                iwl_mvm_phy_ctxt_changed(mvm, ctxt, &chandef, 1, 1);