Skip to contentSkip to conversation

iwlwifi: fixes intended for v5.17 2022-01-28

PATCH In review Luca Coelho 3 participants 12 messages Jan 28, 2022 – Feb 3, 2022 Intel wireless wifi link (iwlwifi)

lore
Share & tools
lore
#0 lore raw

cover iwlwifi: fixes intended for v5.17 2022-01-28

From: Luca Coelho <[email protected]>

Hi,

This is the first patchset with fixes for v5.17.

The changes are:

* A few fixes for iwlmei;
* A couple of fixes in an error path during init that renders the device unusable;
* Two fixes for the newly introduced rate_n_flags FW API;

As usual, I'm pushing this to a pending branch, for kbuild bot. And since these are fixes for the rc series, please take them directly to wireless-drivers.git, as we agreed. I'll assign them to you.

Cheers,
Luca.

Emmanuel Grumbach (4):
iwlwifi: mei: fix the pskb_may_pull check in ipv4
iwlwifi: mei: retry mapping the shared area
iwlwifi: mvm: don't feed the hardware RFKILL into iwlmei
iwlwifi: mei: report RFKILL upon register when needed

Johannes Berg (2):
iwlwifi: pcie: fix locking when "HW not ready"
iwlwifi: pcie: gen2: fix locking when "HW not ready"

Miri Korenblit (2):
iwlwifi: mvm: fix condition which checks the version of rate_n_flags
iwlwifi: fix iwl_legacy_rate_to_fw_idx

 .../net/wireless/intel/iwlwifi/fw/api/rs.h    |  1 -
 drivers/net/wireless/intel/iwlwifi/fw/rs.c    | 33 +++++++-------
 drivers/net/wireless/intel/iwlwifi/mei/main.c | 45 ++++++++++++++-----
 drivers/net/wireless/intel/iwlwifi/mei/net.c  |  3 +-
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h  |  2 +-
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c   |  2 +-
 .../wireless/intel/iwlwifi/pcie/trans-gen2.c  |  3 +-
 .../net/wireless/intel/iwlwifi/pcie/trans.c   |  3 +-
 8 files changed, 57 insertions(+), 35 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/8 iwlwifi: mvm: fix condition which checks the version of rate_n_flags

From: Miri Korenblit <[email protected]>

We're checking the FW version of TX_CMD in order to decide whether to convert rate_n_flags from the old format to the new one. If the API is smaller or equal to 6 we should convert it. Currently we're converting if the API version is greater than 6. Fix it.

Fixes dc52fac37c87 ("iwlwifi: mvm: Support new TX_RSP and COMPRESSED_BA_RES versions")
---
 drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/tx.c +1 -1
index 6fa2c12f7955..9213f8518f10 100644
@@ -1427,7 +1427,7 @@ static void iwl_mvm_hwrate_to_tx_status(const struct iwl_fw *fw,
 	struct ieee80211_tx_rate *r = &info->status.rates[0];
 
 	if (iwl_fw_lookup_notif_ver(fw, LONG_GROUP,
-				    TX_CMD, 0) > 6)
+				    TX_CMD, 0) <= 6)
 		rate_n_flags = iwl_new_rate_from_v1(rate_n_flags);
 
 	info->status.antenna =
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH for v5.17 1/8] iwlwifi: mvm: fix condition which checks the version of rate_n_flags

Quoted 10 lines · Luca Coelho

From: Miri Korenblit <[email protected]>

We're checking the FW version of TX_CMD in order to decide whether to convert rate_n_flags from the old format to the new one. If the API is smaller or equal to 6 we should convert it. Currently we're converting if the API version is greater than 6. Fix it.

Fixes dc52fac37c87 ("iwlwifi: mvm: Support new TX_RSP and COMPRESSED_BA_RES versions")

8 patches applied to wireless.git, thanks.

be8287c9b832 iwlwifi: mvm: fix condition which checks the version of rate_n_flags 973f02c932b0 iwlwifi: fix iwl_legacy_rate_to_fw_idx
e9848aed1477 iwlwifi: pcie: fix locking when "HW not ready" 4c29c1e27a1e iwlwifi: pcie: gen2: fix locking when "HW not ready" e1849784de9b iwlwifi: mei: fix the pskb_may_pull check in ipv4 44bf7c4667ef iwlwifi: mei: retry mapping the shared area 7cf800f46e07 iwlwifi: mvm: don't feed the hardware RFKILL into iwlmei 30de48b436a0 iwlwifi: mei: report RFKILL upon register when needed

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/iwlwifi.20220128142706.a264ac51d106.I228ba1317cdcbfef931c09d280d701fcad9048d2@changeid/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#3 lore raw

PATCH 2/8 iwlwifi: fix iwl_legacy_rate_to_fw_idx

In reply to Luca Coelho

From: Miri Korenblit <[email protected]>

There are a couple of bugs in this function:

1. It is declared as a non-static function, even though it's only used in one file.
2. Its return value should be of type u32 but it returns (in some cases) -1.

Fix them by making this function static and returning an error value of type unsigned.

In addition, we're assigning the return value of this function as the legacy rate even if the function returned an error value. Fix this by assigning the lowest rate in this case.

Fixes 9998f81e4ba5 ("iwlwifi: mvm: convert old rate & flags to the new format.")
---
 .../net/wireless/intel/iwlwifi/fw/api/rs.h    |  1 -
 drivers/net/wireless/intel/iwlwifi/fw/rs.c    | 33 ++++++++++---------
 2 files changed, 18 insertions(+), 16 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/api/rs.h +0 -1
index 173a6991587b..4a7723eb8c1d 100644
@@ -752,7 +752,6 @@ struct iwl_lq_cmd {
 
 u8 iwl_fw_rate_idx_to_plcp(int idx);
 u32 iwl_new_rate_from_v1(u32 rate_v1);
-u32 iwl_legacy_rate_to_fw_idx(u32 rate_n_flags);
 const struct iwl_rate_mcs_info *iwl_rate_mcs(int idx);
 const char *iwl_rs_pretty_ant(u8 ant);
 const char *iwl_rs_pretty_bw(int bw);
drivers/net/wireless/intel/iwlwifi/fw/rs.c +18 -15
index a21c3befd93b..a835214611ce 100644
@@ -91,6 +91,20 @@ const char *iwl_rs_pretty_bw(int bw)
 }
 IWL_EXPORT_SYMBOL(iwl_rs_pretty_bw);
 
+static u32 iwl_legacy_rate_to_fw_idx(u32 rate_n_flags)
+{
+	int rate = rate_n_flags & RATE_LEGACY_RATE_MSK_V1;
+	int idx;
+	bool ofdm = !(rate_n_flags & RATE_MCS_CCK_MSK_V1);
+	int offset = ofdm ? IWL_FIRST_OFDM_RATE : 0;
+	int last = ofdm ? IWL_RATE_COUNT_LEGACY : IWL_FIRST_OFDM_RATE;
+
+	for (idx = offset; idx < last; idx++)
+		if (iwl_fw_rate_idx_to_plcp(idx) == rate)
+			return idx - offset;
+	return IWL_RATE_INVALID;
+}
+
 u32 iwl_new_rate_from_v1(u32 rate_v1)
 {
 	u32 rate_v2 = 0;
@@ -144,7 +158,10 @@ u32 iwl_new_rate_from_v1(u32 rate_v1)
 	} else {
 		u32 legacy_rate = iwl_legacy_rate_to_fw_idx(rate_v1);
 
-		WARN_ON(legacy_rate < 0);
+		if (WARN_ON_ONCE(legacy_rate == IWL_RATE_INVALID))
+			legacy_rate = (rate_v1 & RATE_MCS_CCK_MSK_V1) ?
+				IWL_FIRST_CCK_RATE : IWL_FIRST_OFDM_RATE;
+
 		rate_v2 |= legacy_rate;
 		if (!(rate_v1 & RATE_MCS_CCK_MSK_V1))
 			rate_v2 |= RATE_MCS_LEGACY_OFDM_MSK;
@@ -172,20 +189,6 @@ u32 iwl_new_rate_from_v1(u32 rate_v1)
 }
 IWL_EXPORT_SYMBOL(iwl_new_rate_from_v1);
 
-u32 iwl_legacy_rate_to_fw_idx(u32 rate_n_flags)
-{
-	int rate = rate_n_flags & RATE_LEGACY_RATE_MSK_V1;
-	int idx;
-	bool ofdm = !(rate_n_flags & RATE_MCS_CCK_MSK_V1);
-	int offset = ofdm ? IWL_FIRST_OFDM_RATE : 0;
-	int last = ofdm ? IWL_RATE_COUNT_LEGACY : IWL_FIRST_OFDM_RATE;
-
-	for (idx = offset; idx < last; idx++)
-		if (iwl_fw_rate_idx_to_plcp(idx) == rate)
-			return idx - offset;
-	return -1;
-}
-
 int rs_pretty_print_rate(char *buf, int bufsz, const u32 rate)
 {
 	char *type;
Signature · 1 line
2.34.1
#4 lore raw

PATCH 3/8 iwlwifi: pcie: fix locking when "HW not ready"

In reply to Luca Coelho

From: Johannes Berg <[email protected]>

If we run into this error path, we shouldn't unlock the mutex since it's not locked since. Fix this.

Fixes a6bd005fe92d ("iwlwifi: pcie: fix RF-Kill vs. firmware load race")
---
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/pcie/trans.c +1 -2
index a63386a01232..ef14584fc0a1 100644
@@ -1329,8 +1329,7 @@ static int iwl_trans_pcie_start_fw(struct iwl_trans *trans,
 	/* This may fail if AMT took ownership of the device */
 	if (iwl_pcie_prepare_card_hw(trans)) {
 		IWL_WARN(trans, "Exit HW not ready\n");
-		ret = -EIO;
-		goto out;
+		return -EIO;
 	}
 
 	iwl_enable_rfkill_int(trans);
Signature · 1 line
2.34.1
#5 lore raw

PATCH 4/8 iwlwifi: pcie: gen2: fix locking when "HW not ready"

In reply to Luca Coelho

From: Johannes Berg <[email protected]>

If we run into this error path, we shouldn't unlock the mutex since it's not locked since. Fix this in the gen2 code as well.

Fixes eda50cde58de ("iwlwifi: pcie: add context information support")
---
 drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c +1 -2
index 0febdcacbd42..94f40c4d2421 100644
@@ -385,8 +385,7 @@ int iwl_trans_pcie_gen2_start_fw(struct iwl_trans *trans,
 	/* This may fail if AMT took ownership of the device */
 	if (iwl_pcie_prepare_card_hw(trans)) {
 		IWL_WARN(trans, "Exit HW not ready\n");
-		ret = -EIO;
-		goto out;
+		return -EIO;
 	}
 
 	iwl_enable_rfkill_int(trans);
Signature · 1 line
2.34.1
#6 lore raw

PATCH 5/8 iwlwifi: mei: fix the pskb_may_pull check in ipv4

In reply to Luca Coelho

From: Emmanuel Grumbach <[email protected]>

The check makes sure that we can look at the ip header. We first need to check that the basic ip header (20 bytes) can be pulled before we look at the field that will teach us how long is the ip header. This is why there are two checks.

The second check was wrong and smatch pointed that sizeof(ip_hdrlen(skb) - sizeof(*iphdr)) can't be right.

Looking at the code again made me think that we really need ip_hdrlen(skb) since we want to make sure all the IP header is in the buffer header. This will allow us to set the transport offset and from there to look at the transport header (TCP / UDP).

Fixes 2da4366f9e2c ("iwlwifi: mei: add the driver to allow cooperation with CSME")
---
 drivers/net/wireless/intel/iwlwifi/mei/net.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/mei/net.c +1 -2
index 5f966af69720..468102a95e1b 100644
@@ -195,8 +195,7 @@ static bool iwl_mei_rx_filter_ipv4(struct sk_buff *skb,
 	bool match;
 
 	if (!pskb_may_pull(skb, skb_network_offset(skb) + sizeof(*iphdr)) ||
-	    !pskb_may_pull(skb, skb_network_offset(skb) +
-			   sizeof(ip_hdrlen(skb) - sizeof(*iphdr))))
+	    !pskb_may_pull(skb, skb_network_offset(skb) + ip_hdrlen(skb)))
 		return false;
 
 	iphdrlen = ip_hdrlen(skb);
Signature · 1 line
2.34.1
#7 lore raw

PATCH 6/8 iwlwifi: mei: retry mapping the shared area

In reply to Luca Coelho

From: Emmanuel Grumbach <[email protected]>

The shared area is a DMA memory allocated in the host and mapped so that the host and the CSME firmware can exchange data. It is mapped through a dedicated PCI device that is driven by the mei bus driver.

The bus driver is in charge of allocating and mapping this memory. It also needs to configure the CSME firmware with a specific set of commands, so that the CSME firmware will know that this memory is meant to be used by its internal WLAN module.

For this, the CSME firmware first needs to completely initialize its WLAN module and only then get the mapping request.

The problem is that the mei bus enumeration completes before the WLAN is completely ready. This means that the WLAN module's initialization is racing with iwlmei's allocation and mapping flow.

Testing showed a problem in resume flows where iwlmei was too fast and the DMA mapping failed.

Add a retry mechanism to make sure that we will succeed to map the memory.

Fixes 2da4366f9e2c ("iwlwifi: mei: add the driver to allow cooperation with CSME")
Fixes bcbddc4f9d02 ("iwlwifi: mei: wait before mapping the shared area")
---
 drivers/net/wireless/intel/iwlwifi/mei/main.c | 35 ++++++++++++++-----
 1 file changed, 26 insertions(+), 9 deletions(-)
drivers/net/wireless/intel/iwlwifi/mei/main.c +26 -9
index d9733aaf6f6e..6cc5553027a0 100644
@@ -229,8 +229,6 @@ static int iwl_mei_alloc_shared_mem(struct mei_cl_device *cldev)
 	if (IS_ERR(mem->ctrl)) {
 		int ret = PTR_ERR(mem->ctrl);
 
-		dev_err(&cldev->dev, "Couldn't allocate the shared memory: %d\n",
-			ret);
 		mem->ctrl = NULL;
 
 		return ret;
@@ -1784,6 +1782,8 @@ static void iwl_mei_dbgfs_unregister(struct iwl_mei *mei) {}
 
 #endif /* CONFIG_DEBUG_FS */
 
+#define ALLOC_SHARED_MEM_RETRY_MAX_NUM	3
+
 /*
  * iwl_mei_probe - the probe function called by the mei bus enumeration
  *
@@ -1795,6 +1795,7 @@ static void iwl_mei_dbgfs_unregister(struct iwl_mei *mei) {}
 static int iwl_mei_probe(struct mei_cl_device *cldev,
 			 const struct mei_cl_device_id *id)
 {
+	int alloc_retry = ALLOC_SHARED_MEM_RETRY_MAX_NUM;
 	struct iwl_mei *mei;
 	int ret;
 
@@ -1812,15 +1813,31 @@ static int iwl_mei_probe(struct mei_cl_device *cldev,
 	mei_cldev_set_drvdata(cldev, mei);
 	mei->cldev = cldev;
 
-	/*
-	 * The CSME firmware needs to boot the internal WLAN client. Wait here
-	 * so that the DMA map request will succeed.
-	 */
-	msleep(20);
+	do {
+		ret = iwl_mei_alloc_shared_mem(cldev);
+		if (!ret)
+			break;
+		/*
+		 * The CSME firmware needs to boot the internal WLAN client.
+		 * This can take time in certain configurations (usually
+		 * upon resume and when the whole CSME firmware is shut down
+		 * during suspend).
+		 *
+		 * Wait a bit before retrying and hope we'll succeed next time.
+		 */
 
-	ret = iwl_mei_alloc_shared_mem(cldev);
-	if (ret)
+		dev_dbg(&cldev->dev,
+			"Couldn't allocate the shared memory: %d, attempt %d / %d\n",
+			ret, alloc_retry, ALLOC_SHARED_MEM_RETRY_MAX_NUM);
+		msleep(100);
+		alloc_retry--;
+	} while (alloc_retry);
+
+	if (ret) {
+		dev_err(&cldev->dev, "Couldn't allocate the shared memory: %d\n",
+			ret);
 		goto free;
+	}
 
 	iwl_mei_init_shared_mem(mei);
 
Signature · 1 line
2.34.1
#8 lore raw

Re: [PATCH for v5.17 6/8] iwlwifi: mei: retry mapping the shared area

Quoted 25 lines · Luca Coelho

From: Emmanuel Grumbach <[email protected]>

The shared area is a DMA memory allocated in the host and mapped so that the host and the CSME firmware can exchange data. It is mapped through a dedicated PCI device that is driven by the mei bus driver.

The bus driver is in charge of allocating and mapping this memory. It also needs to configure the CSME firmware with a specific set of commands, so that the CSME firmware will know that this memory is meant to be used by its internal WLAN module.

For this, the CSME firmware first needs to completely initialize its WLAN module and only then get the mapping request.

The problem is that the mei bus enumeration completes before the WLAN is completely ready. This means that the WLAN module's initialization is racing with iwlmei's allocation and mapping flow.

Testing showed a problem in resume flows where iwlmei was too fast and the DMA mapping failed.

Quoted 6 lines

Add a retry mechanism to make sure that we will succeed to map the memory.

Fixes 2da4366f9e2c ("iwlwifi: mei: add the driver to allow cooperation with CSME")
Fixes bcbddc4f9d02 ("iwlwifi: mei: wait before mapping the shared area")

I'll move the latter Fixes before s-o-b tag.

Quoted 16 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c +11 -5
-	/*
-	 * The CSME firmware needs to boot the internal WLAN client. Wait here
-	 * so that the DMA map request will succeed.
-	 */
-	msleep(20);
+	do {
+		ret = iwl_mei_alloc_shared_mem(cldev);
+		if (!ret)
+			break;
+		/*
+		 * The CSME firmware needs to boot the internal WLAN client.
+		 * This can take time in certain configurations (usually
+		 * upon resume and when the whole CSME firmware is shut down
+		 * during suspend).
+		 *
+		 * Wait a bit before retrying and hope we'll succeed next time.

drivers/net/wireless/intel/iwlwifi/mei/main.c static int iwl_mei_probe(struct mei_cl_device *cldev, · line 1834

Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c +7 -2
+		 */
 
-	ret = iwl_mei_alloc_shared_mem(cldev);
-	if (ret)
+		dev_dbg(&cldev->dev,
+			"Couldn't allocate the shared memory: %d, attempt %d / %d\n",
+			ret, alloc_retry, ALLOC_SHARED_MEM_RETRY_MAX_NUM);
+		msleep(100);
+		alloc_retry--;
+	} while (alloc_retry);

Nitpicking, but this could have been:

while (alloc_retry--);

But no need to resend because of this.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#9 lore raw

PATCH 7/8 iwlwifi: mvm: don't feed the hardware RFKILL into iwlmei

In reply to Luca Coelho

From: Emmanuel Grumbach <[email protected]>

iwlmei can trigger a hardware RFKILL when the CSME firmware does not want the host to touch the device.
But then, iwlmvm reports RFKILL which makes cfg80211 update iwlmvm about RFKILL. iwlmvm then thinks there is a change in the _software_ rfkill and it calls rfkill_blocked() to fetch the RFKILL state. This returns that RFKILL is blocked (because of iwlmei) and iwlmvm tells iwlmei that _software_ RFKILL is asserted.

This is a bug of course.
Fix this by checking explicitly the software RFKILL state and not the overall RFKILL state.

Fixes 7ce1f2157e14 ("iwlwifi: mvm: read the rfkill state and feed it to iwlmei")
Fixes 7ce1f2157e14 ("iwlwifi: mvm: read the rfkill state and feed it to iwlmei")
---
 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +1 -1
index 1dcbb0eb63c3..b1fe8434ab0d 100644
@@ -2225,7 +2225,7 @@ static inline void iwl_mvm_mei_device_down(struct iwl_mvm *mvm)
 static inline void iwl_mvm_mei_set_sw_rfkill_state(struct iwl_mvm *mvm)
 {
 	bool sw_rfkill =
-		mvm->hw_registered ? rfkill_blocked(mvm->hw->wiphy->rfkill) : false;
+		mvm->hw_registered ? rfkill_soft_blocked(mvm->hw->wiphy->rfkill) : false;
 
 	if (mvm->mei_registered)
 		iwl_mei_set_rfkill_state(iwl_mvm_is_radio_killed(mvm),
Signature · 1 line
2.34.1
#10 lore raw

Re: [PATCH for v5.17 7/8] iwlwifi: mvm: don't feed the hardware RFKILL into iwlmei

Thank you for the patch! Yet something to improve:

Hi Luca,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.17-rc2 next-20220131]
[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-fixes-intended-for-v5-17-2022-01-28/20220128-203214
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 23a46422c56144939c091c76cf389aa863ce9c18
config: ia64-randconfig-r021-20220131 (https://download.01.org/0day-ci/archive/20220201/202202011714.XrRkrols-lkp(a)intel.com/config)
compiler: ia64-linux-gcc (GCC) 11.2.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/1d33a974994cf1c846390af775b6af723b9f3077
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Luca-Coelho/iwlwifi-fixes-intended-for-v5-17-2022-01-28/20220128-203214 git checkout 1d33a974994cf1c846390af775b6af723b9f3077
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/net/wireless/

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from arch/ia64/include/asm/pgtable.h:153,

                    from include/linux/pgtable.h:6,
                    from arch/ia64/include/asm/uaccess.h:40,
                    from include/linux/uaccess.h:11,
                    from include/linux/sched/task.h:11,
                    from include/linux/sched/signal.h:9,
                    from include/linux/rcuwait.h:6,
                    from include/linux/percpu-rwsem.h:7,
                    from include/linux/fs.h:33,
                    from include/linux/highmem.h:5,
                    from include/linux/bvec.h:10,
                    from include/linux/skbuff.h:17,
                    from include/linux/if_ether.h:19,
                    from include/net/mac80211.h:18,
                    from drivers/net/wireless/intel/iwlwifi/mvm/fw.c:7:
   arch/ia64/include/asm/mmu_context.h: In function 'reload_context':
   arch/ia64/include/asm/mmu_context.h:127:48: warning: variable 'old_rr4' set but not used [-Wunused-but-set-variable]
     127 |         unsigned long rr0, rr1, rr2, rr3, rr4, old_rr4;
         |                                                ^~~~~~~
   In file included from drivers/net/wireless/intel/iwlwifi/mvm/fw.c:19:
   drivers/net/wireless/intel/iwlwifi/mvm/mvm.h: In function 'iwl_mvm_mei_set_sw_rfkill_state':
>> drivers/net/wireless/intel/iwlwifi/mvm/mvm.h:2228:38: error: implicit declaration of function 'rfkill_soft_blocked'; did you mean 'rfkill_blocked'? [-Werror=implicit-function-declaration]
    2228 |                 mvm->hw_registered ? rfkill_soft_blocked(mvm->hw->wiphy->rfkill) : false;
         |                                      ^~~~~~~~~~~~~~~~~~~
         |                                      rfkill_blocked

cc1: some warnings being treated as errors

vim +2228 drivers/net/wireless/intel/iwlwifi/mvm/mvm.h

2224
2225 static inline void iwl_mvm_mei_set_sw_rfkill_state(struct iwl_mvm *mvm)
2226 {
2227 bool sw_rfkill =

> 2228			mvm->hw_registered ? rfkill_soft_blocked(mvm->hw->wiphy->rfkill) : false;

2229
2230 if (mvm->mei_registered)
2231 iwl_mei_set_rfkill_state(iwl_mvm_is_radio_killed(mvm),
2232 sw_rfkill);
2233 }
2234

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

#11 lore raw

PATCH 8/8 iwlwifi: mei: report RFKILL upon register when needed

In reply to Luca Coelho

From: Emmanuel Grumbach <[email protected]>

When we register and we are in link protection passive, meaning that the host can't touch the device, report RFKILL immediately upon register() and don't wait for the CSME firmware to let us know again about the link protection state.

What happens if we wait is that the host will not see RFKILL soon enough and we'll have a window of time during which it can bring up the device which will request ownership.

Fixes 2da4366f9e2c ("iwlwifi: mei: add the driver to allow cooperation with CSME")
---
 drivers/net/wireless/intel/iwlwifi/mei/main.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/mei/main.c +8 -2
index 6cc5553027a0..2f7f0f994ca3 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Copyright (C) 2021 Intel Corporation
+ * Copyright (C) 2021-2022 Intel Corporation
  */
 
 #include <linux/etherdevice.h>
@@ -146,6 +146,7 @@ struct iwl_mei_filters {
  * @csme_taking_ownership: true when CSME is taking ownership. Used to remember
  *	to send CSME_OWNERSHIP_CONFIRMED when the driver completes its down
  *	flow.
+ * @link_prot_state: true when we are in link protection PASSIVE
  * @csa_throttle_end_wk: used when &csa_throttled is true
  * @data_q_lock: protects the access to the data queues which are
  *	accessed without the mutex.
@@ -165,6 +166,7 @@ struct iwl_mei {
 	bool amt_enabled;
 	bool csa_throttled;
 	bool csme_taking_ownership;
+	bool link_prot_state;
 	struct delayed_work csa_throttle_end_wk;
 	spinlock_t data_q_lock;
 
@@ -667,6 +669,8 @@ iwl_mei_handle_conn_status(struct mei_cl_device *cldev,
 
 	iwl_mei_cache.ops->me_conn_status(iwl_mei_cache.priv, &conn_info);
 
+	mei->link_prot_state = status->link_prot_state;
+
 	/*
 	 * Update the Rfkill state in case the host does not own the device:
 	 * if we are in Link Protection, ask to not touch the device, else,
@@ -1661,9 +1665,11 @@ int iwl_mei_register(void *priv, const struct iwl_mei_ops *ops)
 			mei_cldev_get_drvdata(iwl_mei_global_cldev);
 
 		/* we have already a SAP connection */
-		if (iwl_mei_is_connected())
+		if (iwl_mei_is_connected()) {
 			iwl_mei_send_sap_msg(mei->cldev,
 					     SAP_MSG_NOTIF_WIFIDR_UP);
+			ops->rfkill(priv, mei->link_prot_state);
+		}
 	}
 	ret = 0;
 
Signature · 1 line
2.34.1