linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luca Coelho <luca@coelho.fi>
To: kvalo@codeaurora.org
Cc: luca@coelho.fi, linux-wireless@vger.kernel.org
Subject: [PATCH 11/12] iwlwifi: mvm: load regdomain at INIT stage
Date: Thu,  5 Aug 2021 14:21:57 +0300	[thread overview]
Message-ID: <iwlwifi.20210805141826.a6077801d7d5.I7d8d5c895bc467efbf81ea055dde366ea01cced1@changeid> (raw)
In-Reply-To: <20210805112158.460799-1-luca@coelho.fi>

From: Miri Korenblit <miriam.rachel.korenblit@intel.com>

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>
---
 .../wireless/intel/iwlwifi/iwl-nvm-parse.c    | 19 +++++++++++++++++++
 drivers/net/wireless/intel/iwlwifi/mvm/nvm.c  |  4 ++--
 drivers/net/wireless/intel/iwlwifi/mvm/ops.c  |  5 +++++
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
index 2fbb7cdf00a4..03387a5f8cbc 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
@@ -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;
 
 	/*
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
index 7fb4e618f76e..da705fcaf0fc 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/nvm.c
@@ -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 },
 	};
 
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
index edff2cd3a30e..8ce937f8445a 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c
@@ -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);
-- 
2.32.0


  parent reply	other threads:[~2021-08-05 11:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-05 11:21 [PATCH 00/12] iwlwifi: updates intended for v5.15 2021-08-05 part 2 Luca Coelho
2021-08-05 11:21 ` [PATCH 01/12] iwlwifi: pass number of chains and sub-bands to iwl_sar_set_profile() Luca Coelho
2021-08-26 20:36   ` Luca Coelho
2021-08-05 11:21 ` [PATCH 02/12] iwlwifi: acpi: support reading and storing WRDS revision 1 and 2 Luca Coelho
2021-08-05 11:21 ` [PATCH 03/12] iwlwifi: support reading and storing EWRD revisions " Luca Coelho
2021-08-05 11:21 ` [PATCH 04/12] iwlwifi: remove unused ACPI_WGDS_TABLE_SIZE definition Luca Coelho
2021-08-05 11:21 ` [PATCH 05/12] iwlwifi: convert flat GEO profile table to a struct version Luca Coelho
2021-08-05 11:21 ` [PATCH 06/12] iwlwifi: mvm: support version 11 of wowlan statuses notification Luca Coelho
2021-08-05 11:21 ` [PATCH 07/12] iwlwifi: skip first element in the WTAS ACPI table Luca Coelho
2021-08-05 11:21 ` [PATCH 08/12] iwlwifi: fw: correctly limit to monitor dump Luca Coelho
2021-08-05 11:21 ` [PATCH 09/12] iwlwifi: mvm: trigger WRT when no beacon heard Luca Coelho
2021-08-05 11:21 ` [PATCH 10/12] iwlwifi: mvm: Read the PPAG and SAR tables at INIT stage Luca Coelho
2021-08-05 11:21 ` Luca Coelho [this message]
2021-08-05 11:21 ` [PATCH 12/12] iwlwifi: acpi: support reading and storing WGDS revision 2 Luca Coelho

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=iwlwifi.20210805141826.a6077801d7d5.I7d8d5c895bc467efbf81ea055dde366ea01cced1@changeid \
    --to=luca@coelho.fi \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).