linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] iwlwifi: updates intended for v5.12 2021-02-10 part 2
@ 2021-02-10 15:23 Luca Coelho
  2021-02-10 15:23 ` [PATCH 1/8] iwlwifi: mvm: reduce the print severity of failing getting NIC temp Luca Coelho
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Luca Coelho @ 2021-02-10 15:23 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Luca Coelho <luciano.coelho@intel.com>

Hi,

Here's the seventh set of patches intended for v5.12.  It's the usual
development, new features, cleanups and bugfixes.

The changes are:

* Bump the FW API support version;
* Implement support for PNVM from BIOS;
* Fix PM status when a FW crash happens;
* Some other small fixes, clean-ups and improvements.

As usual, I'm pushing this to a pending branch, for kbuild bot, and
will send a pull-request later.

Please review.

Cheers,
Luca.


Golan Ben Ami (1):
  iwlwifi: mvm: reduce the print severity of failing getting NIC temp

Luca Coelho (5):
  iwlwifi: pnvm: set the PNVM again if it was already loaded
  iwlwifi: pnvm: increment the pointer before checking the TLV
  iwlwifi: pnvm: move file loading code to a separate function
  iwlwifi: pnvm: implement reading PNVM from UEFI
  iwlwifi: bump FW API to 62 for AX devices

Matti Gottlieb (1):
  iwlwifi: pcie: define FW_RESET_TIMEOUT for clarity

Ravi Darsi (1):
  iwlwifi: mvm: global PM mode does not reset after FW crash

 .../net/wireless/intel/iwlwifi/cfg/22000.c    |   2 +-
 drivers/net/wireless/intel/iwlwifi/fw/pnvm.c  | 190 ++++++++++++++----
 drivers/net/wireless/intel/iwlwifi/mvm/d3.c   |   1 +
 drivers/net/wireless/intel/iwlwifi/mvm/tt.c   |   2 +-
 .../intel/iwlwifi/pcie/ctxt-info-gen3.c       |  21 +-
 .../wireless/intel/iwlwifi/pcie/trans-gen2.c  |   4 +-
 6 files changed, 172 insertions(+), 48 deletions(-)

-- 
2.30.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/8] iwlwifi: mvm: reduce the print severity of failing getting NIC temp
  2021-02-10 15:23 [PATCH 0/8] iwlwifi: updates intended for v5.12 2021-02-10 part 2 Luca Coelho
@ 2021-02-10 15:23 ` Luca Coelho
  2021-02-10 23:57   ` Luca Coelho
  2021-02-10 15:23 ` [PATCH 2/8] iwlwifi: mvm: global PM mode does not reset after FW crash Luca Coelho
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Luca Coelho @ 2021-02-10 15:23 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Golan Ben Ami <golan.ben.ami@intel.com>

Currently, for all devices and families, failing getting the temp
from the fw is indicated in the log as ERR.
This is too severe for two reasons:
1. The driver has a fall back - and schedules the next temp
read immediately after failing to read temp from the fw.
2. The temp read implementation in the fw is different between
HWs, and on older devices the flow is a-sync and may timeout.

Reducing the print severity from ERR to WARN will allow to
track the issue if it will appear many times, but not frighten users
if it appears once.

Signed-off-by: Golan Ben Ami <golan.ben.ami@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
index 790bc68a515a..2a7339b12b13 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
@@ -261,7 +261,7 @@ int iwl_mvm_get_temp(struct iwl_mvm *mvm, s32 *temp)
 	ret = iwl_wait_notification(&mvm->notif_wait, &wait_temp_notif,
 				    IWL_MVM_TEMP_NOTIF_WAIT_TIMEOUT);
 	if (ret)
-		IWL_ERR(mvm, "Getting the temperature timed out\n");
+		IWL_WARN(mvm, "Getting the temperature timed out\n");
 
 	return ret;
 }
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/8] iwlwifi: mvm: global PM mode does not reset after FW crash
  2021-02-10 15:23 [PATCH 0/8] iwlwifi: updates intended for v5.12 2021-02-10 part 2 Luca Coelho
  2021-02-10 15:23 ` [PATCH 1/8] iwlwifi: mvm: reduce the print severity of failing getting NIC temp Luca Coelho
@ 2021-02-10 15:23 ` Luca Coelho
  2021-02-10 15:23 ` [PATCH 3/8] iwlwifi: pnvm: set the PNVM again if it was already loaded Luca Coelho
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Luca Coelho @ 2021-02-10 15:23 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Ravi Darsi <ravi.darsi@intel.com>

When The driver in D3 and FW crash happens, trans->system_pm_mode
is  not reset to IWL_PLAT_PM_MODE_DISABLED which causes the driver
not to send INIT conmmands and D3 resume fails.

This patch contains the fix for resetting trans->system_pm_mode to
IWL_PLAT_PM_MODE_DISABLED and D3 resume is successful.

Signed-off-by: Ravi Darsi <ravi.darsi@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/mvm/d3.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
index 7c51c781cfaf..a7dc85c704a9 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
@@ -2043,6 +2043,7 @@ static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool test)
 		iwl_fw_dbg_collect_desc(&mvm->fwrt, &iwl_dump_desc_assert,
 					false, 0);
 		ret = 1;
+		mvm->trans->system_pm_mode = IWL_PLAT_PM_MODE_DISABLED;
 		goto err;
 	}
 
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/8] iwlwifi: pnvm: set the PNVM again if it was already loaded
  2021-02-10 15:23 [PATCH 0/8] iwlwifi: updates intended for v5.12 2021-02-10 part 2 Luca Coelho
  2021-02-10 15:23 ` [PATCH 1/8] iwlwifi: mvm: reduce the print severity of failing getting NIC temp Luca Coelho
  2021-02-10 15:23 ` [PATCH 2/8] iwlwifi: mvm: global PM mode does not reset after FW crash Luca Coelho
@ 2021-02-10 15:23 ` Luca Coelho
  2021-02-10 15:23 ` [PATCH 4/8] iwlwifi: pcie: define FW_RESET_TIMEOUT for clarity Luca Coelho
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Luca Coelho @ 2021-02-10 15:23 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Luca Coelho <luciano.coelho@intel.com>

When the interface goes up, we have already loaded the PNVM during
init, so we don't load it anymore.  But we still need to set the PNVM
values in the context so that the FW can load it again.

Call set_pnvm when the PNVM is already loaded and change the
trans_pcie implementation to accept a second call to set_pnvm when we
have already allocated and, in this case, only set the values without
allocating again.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Fixes: 6972592850c0 ("iwlwifi: read and parse PNVM file")
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/fw/pnvm.c  |  7 ++++++-
 .../intel/iwlwifi/pcie/ctxt-info-gen3.c       | 21 +++++++++++--------
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
index 895a907acdf0..1e16f83b402b 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
@@ -227,6 +227,7 @@ int iwl_pnvm_load(struct iwl_trans *trans,
 	struct iwl_notification_wait pnvm_wait;
 	static const u16 ntf_cmds[] = { WIDE_ID(REGULATORY_AND_NVM_GROUP,
 						PNVM_INIT_COMPLETE_NTFY) };
+	int ret;
 
 	/* if the SKU_ID is empty, there's nothing to do */
 	if (!trans->sku_id[0] && !trans->sku_id[1] && !trans->sku_id[2])
@@ -236,7 +237,6 @@ int iwl_pnvm_load(struct iwl_trans *trans,
 	if (!trans->pnvm_loaded) {
 		const struct firmware *pnvm;
 		char pnvm_name[64];
-		int ret;
 
 		/*
 		 * The prefix unfortunately includes a hyphen at the end, so
@@ -264,6 +264,11 @@ int iwl_pnvm_load(struct iwl_trans *trans,
 
 			release_firmware(pnvm);
 		}
+	} else {
+		/* if we already loaded, we need to set it again */
+		ret = iwl_trans_set_pnvm(trans, NULL, 0);
+		if (ret)
+			return ret;
 	}
 
 	iwl_init_notification_wait(notif_wait, &pnvm_wait,
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c
index 5b5134dd49af..8fba190e84cf 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c
@@ -298,17 +298,20 @@ int iwl_trans_pcie_ctx_info_gen3_set_pnvm(struct iwl_trans *trans,
 	if (trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_AX210)
 		return 0;
 
-	ret = iwl_pcie_ctxt_info_alloc_dma(trans, data, len,
-					   &trans_pcie->pnvm_dram);
-	if (ret < 0) {
-		IWL_DEBUG_FW(trans, "Failed to allocate PNVM DMA %d.\n",
-			     ret);
-		return ret;
+	/* only allocate the DRAM if not allocated yet */
+	if (!trans->pnvm_loaded) {
+		if (WARN_ON(prph_sc_ctrl->pnvm_cfg.pnvm_size))
+			return -EBUSY;
+
+		ret = iwl_pcie_ctxt_info_alloc_dma(trans, data, len,
+						   &trans_pcie->pnvm_dram);
+		if (ret < 0) {
+			IWL_DEBUG_FW(trans, "Failed to allocate PNVM DMA %d.\n",
+				     ret);
+			return ret;
+		}
 	}
 
-	if (WARN_ON(prph_sc_ctrl->pnvm_cfg.pnvm_size))
-		return -EBUSY;
-
 	prph_sc_ctrl->pnvm_cfg.pnvm_base_addr =
 		cpu_to_le64(trans_pcie->pnvm_dram.physical);
 	prph_sc_ctrl->pnvm_cfg.pnvm_size =
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/8] iwlwifi: pcie: define FW_RESET_TIMEOUT for clarity
  2021-02-10 15:23 [PATCH 0/8] iwlwifi: updates intended for v5.12 2021-02-10 part 2 Luca Coelho
                   ` (2 preceding siblings ...)
  2021-02-10 15:23 ` [PATCH 3/8] iwlwifi: pnvm: set the PNVM again if it was already loaded Luca Coelho
@ 2021-02-10 15:23 ` Luca Coelho
  2021-02-10 15:23 ` [PATCH 5/8] iwlwifi: pnvm: increment the pointer before checking the TLV Luca Coelho
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Luca Coelho @ 2021-02-10 15:23 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Matti Gottlieb <matti.gottlieb@intel.com>

Move fw reset timeout to a FW_RESET_TIMEOUT macro
for better readability.

Signed-off-by: Matti Gottlieb <matti.gottlieb@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c
index 0e55aacd6175..497ef3405da3 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c
@@ -10,6 +10,8 @@
 #include "internal.h"
 #include "fw/dbg.h"
 
+#define FW_RESET_TIMEOUT (HZ / 5)
+
 /*
  * Start up NIC's basic functionality after it has been reset
  * (e.g. after platform boot, or shutdown via iwl_pcie_apm_stop())
@@ -104,7 +106,7 @@ static void iwl_trans_pcie_fw_reset_handshake(struct iwl_trans *trans)
 
 	/* wait 200ms */
 	ret = wait_event_timeout(trans_pcie->fw_reset_waitq,
-				 trans_pcie->fw_reset_done, HZ / 5);
+				 trans_pcie->fw_reset_done, FW_RESET_TIMEOUT);
 	if (!ret)
 		IWL_ERR(trans,
 			"firmware didn't ACK the reset - continue anyway\n");
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/8] iwlwifi: pnvm: increment the pointer before checking the TLV
  2021-02-10 15:23 [PATCH 0/8] iwlwifi: updates intended for v5.12 2021-02-10 part 2 Luca Coelho
                   ` (3 preceding siblings ...)
  2021-02-10 15:23 ` [PATCH 4/8] iwlwifi: pcie: define FW_RESET_TIMEOUT for clarity Luca Coelho
@ 2021-02-10 15:23 ` Luca Coelho
  2021-02-10 15:23 ` [PATCH 6/8] iwlwifi: pnvm: move file loading code to a separate function Luca Coelho
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Luca Coelho @ 2021-02-10 15:23 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Luca Coelho <luciano.coelho@intel.com>

If the SKU_ID doesn't match, we don't increment the pointer and keep
checking the same TLV over and over again.

We need to increment the pointer in all situtations, namely if the TLV
is not a SKU_ID, if the SKU_ID matched or if the SKU_ID didn't match.
So we can increment the pointer already before checking for these
conditions to solve the problem.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Fixes: 6972592850c0 ("iwlwifi: read and parse PNVM file")
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/fw/pnvm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
index 1e16f83b402b..37ce4fe136c5 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
@@ -198,14 +198,14 @@ static int iwl_pnvm_parse(struct iwl_trans *trans, const u8 *data,
 				     le32_to_cpu(sku_id->data[1]),
 				     le32_to_cpu(sku_id->data[2]));
 
+			data += sizeof(*tlv) + ALIGN(tlv_len, 4);
+			len -= ALIGN(tlv_len, 4);
+
 			if (trans->sku_id[0] == le32_to_cpu(sku_id->data[0]) &&
 			    trans->sku_id[1] == le32_to_cpu(sku_id->data[1]) &&
 			    trans->sku_id[2] == le32_to_cpu(sku_id->data[2])) {
 				int ret;
 
-				data += sizeof(*tlv) + ALIGN(tlv_len, 4);
-				len -= ALIGN(tlv_len, 4);
-
 				ret = iwl_pnvm_handle_section(trans, data, len);
 				if (!ret)
 					return 0;
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/8] iwlwifi: pnvm: move file loading code to a separate function
  2021-02-10 15:23 [PATCH 0/8] iwlwifi: updates intended for v5.12 2021-02-10 part 2 Luca Coelho
                   ` (4 preceding siblings ...)
  2021-02-10 15:23 ` [PATCH 5/8] iwlwifi: pnvm: increment the pointer before checking the TLV Luca Coelho
@ 2021-02-10 15:23 ` Luca Coelho
  2021-02-10 15:23 ` [PATCH 7/8] iwlwifi: pnvm: implement reading PNVM from UEFI Luca Coelho
  2021-02-10 15:23 ` [PATCH 8/8] iwlwifi: bump FW API to 62 for AX devices Luca Coelho
  7 siblings, 0 replies; 12+ messages in thread
From: Luca Coelho @ 2021-02-10 15:23 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Luca Coelho <luciano.coelho@intel.com>

In preparation to support loading the PNVM from UEFI, move the
function that loads the PNVM from the filesystem to a separate
function.  This will make it easier to try to load from both places
later on.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/fw/pnvm.c | 98 ++++++++++++--------
 1 file changed, 61 insertions(+), 37 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
index 37ce4fe136c5..d515af8c1686 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
@@ -1,9 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
-/******************************************************************************
- *
- * Copyright(c) 2020 Intel Corporation
- *
- *****************************************************************************/
+/*
+ * Copyright(c) 2020-2021 Intel Corporation
+ */
 
 #include "iwl-drv.h"
 #include "pnvm.h"
@@ -221,9 +219,44 @@ static int iwl_pnvm_parse(struct iwl_trans *trans, const u8 *data,
 	return -ENOENT;
 }
 
+static int iwl_pnvm_get_from_fs(struct iwl_trans *trans, u8 **data, size_t *len)
+{
+	const struct firmware *pnvm;
+	char pnvm_name[64];
+	int ret;
+
+	/*
+	 * The prefix unfortunately includes a hyphen at the end, so
+	 * don't add the dot here...
+	 */
+	snprintf(pnvm_name, sizeof(pnvm_name), "%spnvm",
+		 trans->cfg->fw_name_pre);
+
+	/* ...but replace the hyphen with the dot here. */
+	if (strlen(trans->cfg->fw_name_pre) < sizeof(pnvm_name))
+		pnvm_name[strlen(trans->cfg->fw_name_pre) - 1] = '.';
+
+	ret = firmware_request_nowarn(&pnvm, pnvm_name, trans->dev);
+	if (ret) {
+		IWL_DEBUG_FW(trans, "PNVM file %s not found %d\n",
+			     pnvm_name, ret);
+		return ret;
+	}
+
+	*data = kmemdup(pnvm->data, pnvm->size, GFP_KERNEL);
+	if (!*data)
+		return -ENOMEM;
+
+	*len = pnvm->size;
+
+	return 0;
+}
+
 int iwl_pnvm_load(struct iwl_trans *trans,
 		  struct iwl_notif_wait_data *notif_wait)
 {
+	u8 *data;
+	size_t len;
 	struct iwl_notification_wait pnvm_wait;
 	static const u16 ntf_cmds[] = { WIDE_ID(REGULATORY_AND_NVM_GROUP,
 						PNVM_INIT_COMPLETE_NTFY) };
@@ -233,44 +266,35 @@ int iwl_pnvm_load(struct iwl_trans *trans,
 	if (!trans->sku_id[0] && !trans->sku_id[1] && !trans->sku_id[2])
 		return 0;
 
-	/* load from disk only if we haven't done it (or tried) before */
-	if (!trans->pnvm_loaded) {
-		const struct firmware *pnvm;
-		char pnvm_name[64];
+	/*
+	 * If we already loaded (or tried to load) it before, we just
+	 * need to set it again.
+	 */
+	if (trans->pnvm_loaded) {
+		ret = iwl_trans_set_pnvm(trans, NULL, 0);
+		if (ret)
+			return ret;
+		goto skip_parse;
+	}
 
+	/* Try to load the PNVM from the filesystem */
+	ret = iwl_pnvm_get_from_fs(trans, &data, &len);
+	if (ret) {
 		/*
-		 * The prefix unfortunately includes a hyphen at the end, so
-		 * don't add the dot here...
+		 * Pretend we've loaded it - at least we've tried and
+		 * couldn't load it at all, so there's no point in
+		 * trying again over and over.
 		 */
-		snprintf(pnvm_name, sizeof(pnvm_name), "%spnvm",
-			 trans->cfg->fw_name_pre);
-
-		/* ...but replace the hyphen with the dot here. */
-		if (strlen(trans->cfg->fw_name_pre) < sizeof(pnvm_name))
-			pnvm_name[strlen(trans->cfg->fw_name_pre) - 1] = '.';
-
-		ret = firmware_request_nowarn(&pnvm, pnvm_name, trans->dev);
-		if (ret) {
-			IWL_DEBUG_FW(trans, "PNVM file %s not found %d\n",
-				     pnvm_name, ret);
-			/*
-			 * Pretend we've loaded it - at least we've tried and
-			 * couldn't load it at all, so there's no point in
-			 * trying again over and over.
-			 */
-			trans->pnvm_loaded = true;
-		} else {
-			iwl_pnvm_parse(trans, pnvm->data, pnvm->size);
+		trans->pnvm_loaded = true;
 
-			release_firmware(pnvm);
-		}
-	} else {
-		/* if we already loaded, we need to set it again */
-		ret = iwl_trans_set_pnvm(trans, NULL, 0);
-		if (ret)
-			return ret;
+		goto skip_parse;
 	}
 
+	iwl_pnvm_parse(trans, data, len);
+
+	kfree(data);
+
+skip_parse:
 	iwl_init_notification_wait(notif_wait, &pnvm_wait,
 				   ntf_cmds, ARRAY_SIZE(ntf_cmds),
 				   iwl_pnvm_complete_fn, trans);
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 7/8] iwlwifi: pnvm: implement reading PNVM from UEFI
  2021-02-10 15:23 [PATCH 0/8] iwlwifi: updates intended for v5.12 2021-02-10 part 2 Luca Coelho
                   ` (5 preceding siblings ...)
  2021-02-10 15:23 ` [PATCH 6/8] iwlwifi: pnvm: move file loading code to a separate function Luca Coelho
@ 2021-02-10 15:23 ` Luca Coelho
  2021-02-10 18:01   ` kernel test robot
  2021-02-10 15:23 ` [PATCH 8/8] iwlwifi: bump FW API to 62 for AX devices Luca Coelho
  7 siblings, 1 reply; 12+ messages in thread
From: Luca Coelho @ 2021-02-10 15:23 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Luca Coelho <luciano.coelho@intel.com>

We now support fetching the PNVM data from a UEFI variable.  Add the
code to read this variable first and use it.  If it's not available,
we fall back to reading the data from the filesystem, as before.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/fw/pnvm.c | 91 +++++++++++++++++++-
 1 file changed, 90 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
index d515af8c1686..5c2977b6364b 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
@@ -10,6 +10,7 @@
 #include "fw/api/commands.h"
 #include "fw/api/nvm-reg.h"
 #include "fw/api/alive.h"
+#include <linux/efi.h>
 
 struct iwl_pnvm_section {
 	__le32 offset;
@@ -219,6 +220,88 @@ static int iwl_pnvm_parse(struct iwl_trans *trans, const u8 *data,
 	return -ENOENT;
 }
 
+/*
+ * This is known to be broken on v4.19 and to work on v5.4.  Until we
+ * figure out why this is the case and how to make it work, simply
+ * disable the feature in old kernels.
+ */
+#if defined(CONFIG_EFI) && LINUX_VERSION_IS_GEQ(5,4,0)
+
+#define IWL_EFI_VAR_GUID EFI_GUID(0x92daaf2f, 0xc02b, 0x455b,	\
+				  0xb2, 0xec, 0xf5, 0xa3,	\
+				  0x59, 0x4f, 0x4a, 0xea)
+
+#define IWL_UEFI_OEM_PNVM_NAME	L"UefiCnvWlanOemSignedPnvm"
+
+#define IWL_HARDCODED_PNVM_SIZE 4096
+
+struct pnvm_sku_package {
+	u8 rev;
+	u8 reserved1[3];
+	u32 total_size;
+	u8 n_skus;
+	u8 reserved2[11];
+	u8 data[];
+};
+
+static int iwl_pnvm_get_from_efi(struct iwl_trans *trans,
+				 u8 **data, size_t *len)
+{
+	struct efivar_entry *pnvm_efivar;
+	struct pnvm_sku_package *package;
+	unsigned long package_size;
+	int err;
+
+	pnvm_efivar = kzalloc(sizeof(*pnvm_efivar), GFP_KERNEL);
+	if (!pnvm_efivar)
+		return -ENOMEM;
+
+	memcpy(&pnvm_efivar->var.VariableName, IWL_UEFI_OEM_PNVM_NAME,
+	       sizeof(IWL_UEFI_OEM_PNVM_NAME));
+	pnvm_efivar->var.VendorGuid = IWL_EFI_VAR_GUID;
+
+	/*
+	 * TODO: we hardcode a maximum length here, because reading
+	 * from the UEFI is not working.  To implement this properly,
+	 * we have to call efivar_entry_size().
+	 */
+	package_size = IWL_HARDCODED_PNVM_SIZE;
+
+	package = kmalloc(package_size, GFP_KERNEL);
+	if (!package) {
+		err = -ENOMEM;
+		goto out;
+	}
+
+	err = efivar_entry_get(pnvm_efivar, NULL, &package_size, package);
+	if (err) {
+		IWL_DEBUG_FW(trans,
+			     "PNVM UEFI variable not found %d (len %zd)\n",
+			     err, package_size);
+		goto out;
+	}
+
+	IWL_DEBUG_FW(trans, "Read PNVM fro UEFI with size %zd\n", package_size);
+
+	*data = kmemdup(package->data, *len, GFP_KERNEL);
+	if (!*data)
+		err = -ENOMEM;
+	*len = package_size - sizeof(*package);
+
+out:
+	kfree(package);
+	kfree(pnvm_efivar);
+
+	return err;
+}
+#else /* CONFIG_EFI */
+static inline int iwl_pnvm_get_from_efi(struct iwl_trans *trans,
+					u8 **data, size_t *len)
+{
+	return -EOPNOTSUPP;
+}
+#endif /* CONFIG_EFI */
+
 static int iwl_pnvm_get_from_fs(struct iwl_trans *trans, u8 **data, size_t *len)
 {
 	const struct firmware *pnvm;
@@ -277,7 +360,12 @@ int iwl_pnvm_load(struct iwl_trans *trans,
 		goto skip_parse;
 	}
 
-	/* Try to load the PNVM from the filesystem */
+	/* First attempt to get the PNVM from BIOS */
+	ret = iwl_pnvm_get_from_efi(trans, &data, &len);
+	if (!ret)
+		goto parse;
+
+	/* If it's not available, try from the filesystem */
 	ret = iwl_pnvm_get_from_fs(trans, &data, &len);
 	if (ret) {
 		/*
@@ -290,6 +378,7 @@ int iwl_pnvm_load(struct iwl_trans *trans,
 		goto skip_parse;
 	}
 
+parse:
 	iwl_pnvm_parse(trans, data, len);
 
 	kfree(data);
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 8/8] iwlwifi: bump FW API to 62 for AX devices
  2021-02-10 15:23 [PATCH 0/8] iwlwifi: updates intended for v5.12 2021-02-10 part 2 Luca Coelho
                   ` (6 preceding siblings ...)
  2021-02-10 15:23 ` [PATCH 7/8] iwlwifi: pnvm: implement reading PNVM from UEFI Luca Coelho
@ 2021-02-10 15:23 ` Luca Coelho
  2021-02-10 23:58   ` Luca Coelho
  7 siblings, 1 reply; 12+ messages in thread
From: Luca Coelho @ 2021-02-10 15:23 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Luca Coelho <luciano.coelho@intel.com>

Start supporting API version 62 for AX devices.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/cfg/22000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/cfg/22000.c b/drivers/net/wireless/intel/iwlwifi/cfg/22000.c
index 6c87cc121887..0a0e25a3c681 100644
--- a/drivers/net/wireless/intel/iwlwifi/cfg/22000.c
+++ b/drivers/net/wireless/intel/iwlwifi/cfg/22000.c
@@ -9,7 +9,7 @@
 #include "iwl-prph.h"
 
 /* Highest firmware API version supported */
-#define IWL_22000_UCODE_API_MAX	61
+#define IWL_22000_UCODE_API_MAX	62
 
 /* Lowest firmware API version supported */
 #define IWL_22000_UCODE_API_MIN	39
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 7/8] iwlwifi: pnvm: implement reading PNVM from UEFI
  2021-02-10 15:23 ` [PATCH 7/8] iwlwifi: pnvm: implement reading PNVM from UEFI Luca Coelho
@ 2021-02-10 18:01   ` kernel test robot
  0 siblings, 0 replies; 12+ messages in thread
From: kernel test robot @ 2021-02-10 18:01 UTC (permalink / raw)
  To: Luca Coelho, kvalo; +Cc: kbuild-all, linux-wireless

[-- Attachment #1: Type: text/plain, Size: 2846 bytes --]

Hi Luca,

I love your patch! Yet something to improve:

[auto build test ERROR on wireless-drivers-next/master]
[also build test ERROR on wireless-drivers/master linus/master v5.11-rc7]
[cannot apply to next-20210125]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Luca-Coelho/iwlwifi-updates-intended-for-v5-12-2021-02-10-part-2/20210210-233911
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/477683319e91793d94debf7f0c0019a31e6cde3f
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Luca-Coelho/iwlwifi-updates-intended-for-v5-12-2021-02-10-part-2/20210210-233911
        git checkout 477683319e91793d94debf7f0c0019a31e6cde3f
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

>> drivers/net/wireless/intel/iwlwifi/fw/pnvm.c:228:28: warning: "LINUX_VERSION_IS_GEQ" is not defined, evaluates to 0 [-Wundef]
     228 | #if defined(CONFIG_EFI) && LINUX_VERSION_IS_GEQ(5,4,0)
         |                            ^~~~~~~~~~~~~~~~~~~~
>> drivers/net/wireless/intel/iwlwifi/fw/pnvm.c:228:48: error: missing binary operator before token "("
     228 | #if defined(CONFIG_EFI) && LINUX_VERSION_IS_GEQ(5,4,0)
         |                                                ^

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for FRAME_POINTER
   Depends on DEBUG_KERNEL && (M68K || UML || SUPERH) || ARCH_WANT_FRAME_POINTERS
   Selected by
   - FAULT_INJECTION_STACKTRACE_FILTER && FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT && !X86_64 && !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM && !ARC && !X86


vim +228 drivers/net/wireless/intel/iwlwifi/fw/pnvm.c

   222	
   223	/*
   224	 * This is known to be broken on v4.19 and to work on v5.4.  Until we
   225	 * figure out why this is the case and how to make it work, simply
   226	 * disable the feature in old kernels.
   227	 */
 > 228	#if defined(CONFIG_EFI) && LINUX_VERSION_IS_GEQ(5,4,0)
   229	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 63532 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/8] iwlwifi: mvm: reduce the print severity of failing getting NIC temp
  2021-02-10 15:23 ` [PATCH 1/8] iwlwifi: mvm: reduce the print severity of failing getting NIC temp Luca Coelho
@ 2021-02-10 23:57   ` Luca Coelho
  0 siblings, 0 replies; 12+ messages in thread
From: Luca Coelho @ 2021-02-10 23:57 UTC (permalink / raw)
  To: Luca Coelho; +Cc: kvalo, linux-wireless

Luca Coelho <luca@coelho.fi> wrote:

> From: Golan Ben Ami <golan.ben.ami@intel.com>
> 
> Currently, for all devices and families, failing getting the temp
> from the fw is indicated in the log as ERR.
> This is too severe for two reasons:
> 1. The driver has a fall back - and schedules the next temp
> read immediately after failing to read temp from the fw.
> 2. The temp read implementation in the fw is different between
> HWs, and on older devices the flow is a-sync and may timeout.
> 
> Reducing the print severity from ERR to WARN will allow to
> track the issue if it will appear many times, but not frighten users
> if it appears once.
> 
> Signed-off-by: Golan Ben Ami <golan.ben.ami@intel.com>
> Signed-off-by: Luca Coelho <luciano.coelho@intel.com>

6 patches applied to iwlwifi-next.git, thanks.

c61734a69caf iwlwifi: mvm: reduce the print severity of failing getting NIC temp
11dd729afa48 iwlwifi: mvm: global PM mode does not reset after FW crash
4a81598f0f39 iwlwifi: pnvm: set the PNVM again if it was already loaded
25df65ae8a92 iwlwifi: pcie: define FW_RESET_TIMEOUT for clarity
ff11a8ee2d2d iwlwifi: pnvm: increment the pointer before checking the TLV
cdda18fbbefa iwlwifi: pnvm: move file loading code to a separate function


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 8/8] iwlwifi: bump FW API to 62 for AX devices
  2021-02-10 15:23 ` [PATCH 8/8] iwlwifi: bump FW API to 62 for AX devices Luca Coelho
@ 2021-02-10 23:58   ` Luca Coelho
  0 siblings, 0 replies; 12+ messages in thread
From: Luca Coelho @ 2021-02-10 23:58 UTC (permalink / raw)
  To: Luca Coelho; +Cc: kvalo, linux-wireless

Luca Coelho <luca@coelho.fi> wrote:

> From: Luca Coelho <luciano.coelho@intel.com>
> 
> Start supporting API version 62 for AX devices.
> 
> Signed-off-by: Luca Coelho <luciano.coelho@intel.com>

Patch applied to iwlwifi-next.git, thanks.

000735e5dbbb iwlwifi: bump FW API to 62 for AX devices


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-02-10 23:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10 15:23 [PATCH 0/8] iwlwifi: updates intended for v5.12 2021-02-10 part 2 Luca Coelho
2021-02-10 15:23 ` [PATCH 1/8] iwlwifi: mvm: reduce the print severity of failing getting NIC temp Luca Coelho
2021-02-10 23:57   ` Luca Coelho
2021-02-10 15:23 ` [PATCH 2/8] iwlwifi: mvm: global PM mode does not reset after FW crash Luca Coelho
2021-02-10 15:23 ` [PATCH 3/8] iwlwifi: pnvm: set the PNVM again if it was already loaded Luca Coelho
2021-02-10 15:23 ` [PATCH 4/8] iwlwifi: pcie: define FW_RESET_TIMEOUT for clarity Luca Coelho
2021-02-10 15:23 ` [PATCH 5/8] iwlwifi: pnvm: increment the pointer before checking the TLV Luca Coelho
2021-02-10 15:23 ` [PATCH 6/8] iwlwifi: pnvm: move file loading code to a separate function Luca Coelho
2021-02-10 15:23 ` [PATCH 7/8] iwlwifi: pnvm: implement reading PNVM from UEFI Luca Coelho
2021-02-10 18:01   ` kernel test robot
2021-02-10 15:23 ` [PATCH 8/8] iwlwifi: bump FW API to 62 for AX devices Luca Coelho
2021-02-10 23:58   ` Luca Coelho

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).