iwlwifi: mvm: load regdomain at INIT stage
authorMiri Korenblit <miriam.rachel.korenblit@intel.com>
Thu, 5 Aug 2021 11:21:57 +0000 (14:21 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Thu, 26 Aug 2021 20:36:10 +0000 (23:36 +0300)
We used to load the regdomain only in the load stage,
this caused the 'iw phy phy0 reg get' command to fail if we
booted a machine with wifi off.
Therefor we should load it in INIT stage already.

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.20210805141826.a6077801d7d5.I7d8d5c895bc467efbf81ea055dde366ea01cced1@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
drivers/net/wireless/intel/iwlwifi/mvm/ops.c

index 2fbb7cd..03387a5 100644 (file)
@@ -1381,6 +1381,25 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
                reg_query_regdb_wmm(regd->alpha2, center_freq, rule);
        }
 
+       /*
+        * Certain firmware versions might report no valid channels
+        * if booted in RF-kill, i.e. not all calibrations etc. are
+        * running. We'll get out of this situation later when the
+        * rfkill is removed and we update the regdomain again, but
+        * since cfg80211 doesn't accept an empty regdomain, add a
+        * dummy (unusable) rule here in this case so we can init.
+        */
+       if (!valid_rules) {
+               valid_rules = 1;
+               rule = &regd->reg_rules[valid_rules - 1];
+               rule->freq_range.start_freq_khz = MHZ_TO_KHZ(2412);
+               rule->freq_range.end_freq_khz = MHZ_TO_KHZ(2413);
+               rule->freq_range.max_bandwidth_khz = MHZ_TO_KHZ(1);
+               rule->power_rule.max_antenna_gain = DBI_TO_MBI(6);
+               rule->power_rule.max_eirp =
+                       DBM_TO_MBM(IWL_DEFAULT_MAX_TX_POWER);
+       }
+
        regd->n_reg_rules = valid_rules;
 
        /*
index 7fb4e61..da705fc 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright (C) 2012-2014, 2018-2019 Intel Corporation
+ * Copyright (C) 2012-2014, 2018-2019, 2021 Intel Corporation
  * Copyright (C) 2013-2015 Intel Mobile Communications GmbH
  * Copyright (C) 2016-2017 Intel Deutschland GmbH
  */
@@ -416,7 +416,7 @@ iwl_mvm_update_mcc(struct iwl_mvm *mvm, const char *alpha2,
        struct iwl_rx_packet *pkt;
        struct iwl_host_cmd cmd = {
                .id = MCC_UPDATE_CMD,
-               .flags = CMD_WANT_SKB,
+               .flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL,
                .data = { &mcc_update_cmd },
        };
 
index edff2cd..8ce937f 100644 (file)
@@ -692,11 +692,16 @@ static int iwl_mvm_start_get_nvm(struct iwl_mvm *mvm)
 
        if (ret && ret != -ERFKILL)
                iwl_fw_dbg_error_collect(&mvm->fwrt, FW_DBG_TRIGGER_DRIVER);
+       if (!ret && iwl_mvm_is_lar_supported(mvm)) {
+               mvm->hw->wiphy->regulatory_flags |= REGULATORY_WIPHY_SELF_MANAGED;
+               ret = iwl_mvm_init_mcc(mvm);
+       }
 
        if (!iwlmvm_mod_params.init_dbg || !ret)
                iwl_mvm_stop_device(mvm);
 
        mutex_unlock(&mvm->mutex);
+       rtnl_unlock();
 
        if (ret < 0)
                IWL_ERR(mvm, "Failed to run INIT ucode: %d\n", ret);