linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for v5.11 00/12] iwlwifi: fixes intended for v5.10 2020-12-02
@ 2021-01-15 11:05 Luca Coelho
  2021-01-15 11:05 ` [PATCH for v5.11 01/12] iwlwifi: mvm: skip power command when unbinding vif during CSA Luca Coelho
                   ` (11 more replies)
  0 siblings, 12 replies; 17+ messages in thread
From: Luca Coelho @ 2021-01-15 11:05 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

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

Hi,

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

The changes are:

* Some memory leak fixes;
* Potential NULL pointer dereference fixes;
* Fixes for a few locking issues;
* Fix NMI trigger for FW assert recovery in old devices;
* A couple of fixes for CSA.

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.

Cheers,
Luca.


Emmanuel Grumbach (3):
  iwlwifi: fix the NMI flow for old devices
  iwlwifi: queue: don't crash if txq->entries is NULL
  iwlwifi: pcie: add a NULL check in iwl_pcie_txq_unmap

Johannes Berg (8):
  iwlwifi: mvm: take mutex for calling iwl_mvm_get_sync_time()
  iwlwifi: pcie: avoid potential PNVM leaks
  iwlwifi: pnvm: don't skip everything when not reloading
  iwlwifi: pnvm: don't try to load after failures
  iwlwifi: pcie: set LTR on more devices
  iwlwifi: pcie: fix context info memory leak
  iwlwifi: pcie: use jiffies for memory read spin time limit
  iwlwifi: pcie: reschedule in long-running memory reads

Sara Sharon (1):
  iwlwifi: mvm: skip power command when unbinding vif during CSA

 drivers/net/wireless/intel/iwlwifi/fw/pnvm.c  | 56 ++++++++++---------
 drivers/net/wireless/intel/iwlwifi/iwl-io.c   |  9 +--
 drivers/net/wireless/intel/iwlwifi/iwl-io.h   | 10 +++-
 drivers/net/wireless/intel/iwlwifi/iwl-prph.h |  6 ++
 .../wireless/intel/iwlwifi/mvm/debugfs-vif.c  |  3 +
 .../net/wireless/intel/iwlwifi/mvm/mac80211.c |  3 +
 .../intel/iwlwifi/pcie/ctxt-info-gen3.c       | 53 +++++++++++-------
 .../net/wireless/intel/iwlwifi/pcie/trans.c   | 14 +++--
 drivers/net/wireless/intel/iwlwifi/pcie/tx.c  |  5 ++
 drivers/net/wireless/intel/iwlwifi/queue/tx.c | 49 ++++++++--------
 10 files changed, 127 insertions(+), 81 deletions(-)

-- 
2.29.2


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

* [PATCH for v5.11 01/12] iwlwifi: mvm: skip power command when unbinding vif during CSA
  2021-01-15 11:05 [PATCH for v5.11 00/12] iwlwifi: fixes intended for v5.10 2020-12-02 Luca Coelho
@ 2021-01-15 11:05 ` Luca Coelho
  2021-01-25 13:54   ` Kalle Valo
  2021-01-15 11:05 ` [PATCH for v5.11 02/12] iwlwifi: mvm: take mutex for calling iwl_mvm_get_sync_time() Luca Coelho
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 17+ messages in thread
From: Luca Coelho @ 2021-01-15 11:05 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Sara Sharon <sara.sharon@intel.com>

In the new CSA flow, we remain associated during CSA, but
still do a unbind-bind to the vif. However, sending the power
command right after when vif is unbound but still associated
causes FW to assert (0x3400) since it cannot tell the LMAC id.

Just skip this command, we will send it again in a bit, when
assigning the new context.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
index da32937ba9a7..43ff0407916a 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c
@@ -4194,6 +4194,9 @@ static void __iwl_mvm_unassign_vif_chanctx(struct iwl_mvm *mvm,
 	iwl_mvm_binding_remove_vif(mvm, vif);
 
 out:
+	if (fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_CHANNEL_SWITCH_CMD) &&
+	    switching_chanctx)
+		return;
 	mvmvif->phy_ctxt = NULL;
 	iwl_mvm_power_update_mac(mvm);
 }
-- 
2.29.2


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

* [PATCH for v5.11 02/12] iwlwifi: mvm: take mutex for calling iwl_mvm_get_sync_time()
  2021-01-15 11:05 [PATCH for v5.11 00/12] iwlwifi: fixes intended for v5.10 2020-12-02 Luca Coelho
  2021-01-15 11:05 ` [PATCH for v5.11 01/12] iwlwifi: mvm: skip power command when unbinding vif during CSA Luca Coelho
@ 2021-01-15 11:05 ` Luca Coelho
  2021-01-15 11:05 ` [PATCH for v5.11 03/12] iwlwifi: pcie: avoid potential PNVM leaks Luca Coelho
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Luca Coelho @ 2021-01-15 11:05 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Johannes Berg <johannes.berg@intel.com>

We need to take the mutex to call iwl_mvm_get_sync_time(), do it.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
index 573e46956c14..38d0bfb649cc 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
@@ -459,7 +459,10 @@ static ssize_t iwl_dbgfs_os_device_timediff_read(struct file *file,
 	const size_t bufsz = sizeof(buf);
 	int pos = 0;
 
+	mutex_lock(&mvm->mutex);
 	iwl_mvm_get_sync_time(mvm, &curr_gp2, &curr_os);
+	mutex_unlock(&mvm->mutex);
+
 	do_div(curr_os, NSEC_PER_USEC);
 	diff = curr_os - curr_gp2;
 	pos += scnprintf(buf + pos, bufsz - pos, "diff=%lld\n", diff);
-- 
2.29.2


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

* [PATCH for v5.11 03/12] iwlwifi: pcie: avoid potential PNVM leaks
  2021-01-15 11:05 [PATCH for v5.11 00/12] iwlwifi: fixes intended for v5.10 2020-12-02 Luca Coelho
  2021-01-15 11:05 ` [PATCH for v5.11 01/12] iwlwifi: mvm: skip power command when unbinding vif during CSA Luca Coelho
  2021-01-15 11:05 ` [PATCH for v5.11 02/12] iwlwifi: mvm: take mutex for calling iwl_mvm_get_sync_time() Luca Coelho
@ 2021-01-15 11:05 ` Luca Coelho
  2021-01-15 11:05 ` [PATCH for v5.11 04/12] iwlwifi: pnvm: don't skip everything when not reloading Luca Coelho
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Luca Coelho @ 2021-01-15 11:05 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Johannes Berg <johannes.berg@intel.com>

If we erroneously try to set the PNVM data again after it has
already been set, we could leak the old DMA memory. Avoid that
and warn, we shouldn't be doing this.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Fixes: 6972592850c0 ("iwlwifi: read and parse PNVM file")
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c | 3 +++
 1 file changed, 3 insertions(+)

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 36bf414a388a..afe585228435 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c
@@ -294,6 +294,9 @@ int iwl_trans_pcie_ctx_info_gen3_set_pnvm(struct iwl_trans *trans,
 		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.29.2


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

* [PATCH for v5.11 04/12] iwlwifi: pnvm: don't skip everything when not reloading
  2021-01-15 11:05 [PATCH for v5.11 00/12] iwlwifi: fixes intended for v5.10 2020-12-02 Luca Coelho
                   ` (2 preceding siblings ...)
  2021-01-15 11:05 ` [PATCH for v5.11 03/12] iwlwifi: pcie: avoid potential PNVM leaks Luca Coelho
@ 2021-01-15 11:05 ` Luca Coelho
  2021-01-15 11:05 ` [PATCH for v5.11 05/12] iwlwifi: pnvm: don't try to load after failures Luca Coelho
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Luca Coelho @ 2021-01-15 11:05 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Johannes Berg <johannes.berg@intel.com>

Even if we don't reload the file from disk, we still need to
trigger the PNVM load flow with the device; fix that.

Signed-off-by: Johannes Berg <johannes.berg@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 | 50 ++++++++++----------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
index 6d8f7bff1243..ebd1a09a2fb8 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
@@ -224,40 +224,40 @@ static int iwl_pnvm_parse(struct iwl_trans *trans, const u8 *data,
 int iwl_pnvm_load(struct iwl_trans *trans,
 		  struct iwl_notif_wait_data *notif_wait)
 {
-	const struct firmware *pnvm;
 	struct iwl_notification_wait pnvm_wait;
 	static const u16 ntf_cmds[] = { WIDE_ID(REGULATORY_AND_NVM_GROUP,
 						PNVM_INIT_COMPLETE_NTFY) };
-	char pnvm_name[64];
-	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])
 		return 0;
 
-	/* if we already have it, nothing to do either */
-	if (trans->pnvm_loaded)
-		return 0;
+	/* load from disk only if we haven't done it before */
+	if (!trans->pnvm_loaded) {
+		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);
+		} else {
+			iwl_pnvm_parse(trans, pnvm->data, pnvm->size);
 
-	/*
-	 * 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);
-	} else {
-		iwl_pnvm_parse(trans, pnvm->data, pnvm->size);
-
-		release_firmware(pnvm);
+			release_firmware(pnvm);
+		}
 	}
 
 	iwl_init_notification_wait(notif_wait, &pnvm_wait,
-- 
2.29.2


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

* [PATCH for v5.11 05/12] iwlwifi: pnvm: don't try to load after failures
  2021-01-15 11:05 [PATCH for v5.11 00/12] iwlwifi: fixes intended for v5.10 2020-12-02 Luca Coelho
                   ` (3 preceding siblings ...)
  2021-01-15 11:05 ` [PATCH for v5.11 04/12] iwlwifi: pnvm: don't skip everything when not reloading Luca Coelho
@ 2021-01-15 11:05 ` Luca Coelho
  2021-01-15 11:05 ` [PATCH for v5.11 06/12] iwlwifi: fix the NMI flow for old devices Luca Coelho
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Luca Coelho @ 2021-01-15 11:05 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Johannes Berg <johannes.berg@intel.com>

If loading the PNVM file failed on the first try during the
interface up, the file is unlikely to show up later, and we
already don't try to reload it if it changes, so just don't
try loading it again and again.

This also fixes some issues where we may try to load it at
resume time, which may not be possible yet.

Signed-off-by: Johannes Berg <johannes.berg@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 | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
index ebd1a09a2fb8..895a907acdf0 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
@@ -232,7 +232,7 @@ 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 before */
+	/* 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];
@@ -253,6 +253,12 @@ int iwl_pnvm_load(struct iwl_trans *trans,
 		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);
 
-- 
2.29.2


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

* [PATCH for v5.11 06/12] iwlwifi: fix the NMI flow for old devices
  2021-01-15 11:05 [PATCH for v5.11 00/12] iwlwifi: fixes intended for v5.10 2020-12-02 Luca Coelho
                   ` (4 preceding siblings ...)
  2021-01-15 11:05 ` [PATCH for v5.11 05/12] iwlwifi: pnvm: don't try to load after failures Luca Coelho
@ 2021-01-15 11:05 ` Luca Coelho
  2021-01-15 11:05 ` [PATCH for v5.11 07/12] iwlwifi: queue: don't crash if txq->entries is NULL Luca Coelho
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Luca Coelho @ 2021-01-15 11:05 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>

I noticed that the flow that triggers an NMI on the firmware
for old devices (tested on 7265) doesn't work.
Apparently, the firmware / device is still in low power when
we write the register that triggers the NMI. We call the
"grab_nic_access" function to make sure the device is awake
but that wasn't enough. I played with this and noticed that
if we wait 1 ms after the device reports it is awake before
we write to the NMI register, the device always sees our
write and the firmware gets properly asserted.

Triggering an NMI to the firmware can be done with the
debugfs hook:
echo 1 > /sys/kernel/debug/iwlwifi/0000\:00\:03.0/iwlmvm/fw_nmi

What happened before is that the firmware would just stall
without running its NMI routine. Because of that the driver
wouldn't get the "firmware crashed" interrupt. After a while
the driver would notice that the firmware is not responding
to some command and it would read the error data from the
firmware, but this data is populated in the NMI service
routine in the firmware which was not called. So in the logs
it looked like:

iwlwifi 0000:00:03.0: Error sending REPLY_ERROR: time out after 2000ms.
iwlwifi 0000:00:03.0: Current CMD queue read_ptr 33 write_ptr 34
iwlwifi 0000:00:03.0: Loaded firmware version: 29.09bd31e1.0 7265D-29.ucode
iwlwifi 0000:00:03.0: 0x00000000 | ADVANCED_SYSASSERT
iwlwifi 0000:00:03.0: 0x00000000 | trm_hw_status0
iwlwifi 0000:00:03.0: 0x00000000 | trm_hw_status1
iwlwifi 0000:00:03.0: 0x00000000 | branchlink2
iwlwifi 0000:00:03.0: 0x00000000 | interruptlink1
iwlwifi 0000:00:03.0: 0x00000000 | interruptlink2
iwlwifi 0000:00:03.0: 0x00000000 | data1
iwlwifi 0000:00:03.0: 0x00000000 | data2
iwlwifi 0000:00:03.0: 0x00000000 | data3
iwlwifi 0000:00:03.0: 0x00000000 | beacon time
iwlwifi 0000:00:03.0: 0x00000000 | tsf low
...

With this fix, immediately after we trigger the NMI to the
firmware, we get the expected:
iwlwifi 0000:00:03.0: Microcode SW error detected.  Restarting 0x2000000.
iwlwifi 0000:00:03.0: Start IWL Error Log Dump:
iwlwifi 0000:00:03.0: Status: 0x00000040, count: 6
iwlwifi 0000:00:03.0: Loaded firmware version: 29.09bd31e1.0 7265D-29.ucode
iwlwifi 0000:00:03.0: 0x00000084 | NMI_INTERRUPT_UNKNOWN
iwlwifi 0000:00:03.0: 0x000002F1 | trm_hw_status0
iwlwifi 0000:00:03.0: 0x00000000 | trm_hw_status1
iwlwifi 0000:00:03.0: 0x00043D6C | branchlink2
iwlwifi 0000:00:03.0: 0x0004AFD6 | interruptlink1
iwlwifi 0000:00:03.0: 0x000008C4 | interruptlink2
iwlwifi 0000:00:03.0: 0x00000000 | data1
iwlwifi 0000:00:03.0: 0x00000080 | data2
iwlwifi 0000:00:03.0: 0x07030000 | data3
iwlwifi 0000:00:03.0: 0x003FD4C3 | beacon time
iwlwifi 0000:00:03.0: 0x00C22AC3 | tsf low
iwlwifi 0000:00:03.0: 0x00000000 | tsf hi
iwlwifi 0000:00:03.0: 0x00000000 | time gp1
iwlwifi 0000:00:03.0: 0x00C22AC3 | time gp2
iwlwifi 0000:00:03.0: 0x00000001 | uCode revision type
iwlwifi 0000:00:03.0: 0x0000001D | uCode version major

Notice the first line: "Microcode SW error detected:" which
is printed in the driver's ISR, which means that the driver
actually got an interrupt from the firmware saying that it
crashed. And then we have the properly populated error data.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/iwl-io.c |  9 +++++----
 drivers/net/wireless/intel/iwlwifi/iwl-io.h | 10 ++++++++--
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-io.c b/drivers/net/wireless/intel/iwlwifi/iwl-io.c
index 2ac20d0a30eb..2b7ef1583e7f 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-io.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-io.c
@@ -150,16 +150,17 @@ u32 iwl_read_prph(struct iwl_trans *trans, u32 ofs)
 }
 IWL_EXPORT_SYMBOL(iwl_read_prph);
 
-void iwl_write_prph(struct iwl_trans *trans, u32 ofs, u32 val)
+void iwl_write_prph_delay(struct iwl_trans *trans, u32 ofs, u32 val, u32 delay_ms)
 {
 	unsigned long flags;
 
 	if (iwl_trans_grab_nic_access(trans, &flags)) {
+		mdelay(delay_ms);
 		iwl_write_prph_no_grab(trans, ofs, val);
 		iwl_trans_release_nic_access(trans, &flags);
 	}
 }
-IWL_EXPORT_SYMBOL(iwl_write_prph);
+IWL_EXPORT_SYMBOL(iwl_write_prph_delay);
 
 int iwl_poll_prph_bit(struct iwl_trans *trans, u32 addr,
 		      u32 bits, u32 mask, int timeout)
@@ -219,8 +220,8 @@ IWL_EXPORT_SYMBOL(iwl_clear_bits_prph);
 void iwl_force_nmi(struct iwl_trans *trans)
 {
 	if (trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_9000)
-		iwl_write_prph(trans, DEVICE_SET_NMI_REG,
-			       DEVICE_SET_NMI_VAL_DRV);
+		iwl_write_prph_delay(trans, DEVICE_SET_NMI_REG,
+				     DEVICE_SET_NMI_VAL_DRV, 1);
 	else if (trans->trans_cfg->device_family < IWL_DEVICE_FAMILY_AX210)
 		iwl_write_umac_prph(trans, UREG_NIC_SET_NMI_DRIVER,
 				UREG_NIC_SET_NMI_DRIVER_NMI_FROM_DRIVER);
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-io.h b/drivers/net/wireless/intel/iwlwifi/iwl-io.h
index 39bceee4e9e7..3c21c0e081f8 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-io.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-io.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
- * Copyright (C) 2018-2019 Intel Corporation
+ * Copyright (C) 2018-2020 Intel Corporation
  */
 #ifndef __iwl_io_h__
 #define __iwl_io_h__
@@ -37,7 +37,13 @@ u32 iwl_read_prph_no_grab(struct iwl_trans *trans, u32 ofs);
 u32 iwl_read_prph(struct iwl_trans *trans, u32 ofs);
 void iwl_write_prph_no_grab(struct iwl_trans *trans, u32 ofs, u32 val);
 void iwl_write_prph64_no_grab(struct iwl_trans *trans, u64 ofs, u64 val);
-void iwl_write_prph(struct iwl_trans *trans, u32 ofs, u32 val);
+void iwl_write_prph_delay(struct iwl_trans *trans, u32 ofs,
+			  u32 val, u32 delay_ms);
+static inline void iwl_write_prph(struct iwl_trans *trans, u32 ofs, u32 val)
+{
+	iwl_write_prph_delay(trans, ofs, val, 0);
+}
+
 int iwl_poll_prph_bit(struct iwl_trans *trans, u32 addr,
 		      u32 bits, u32 mask, int timeout);
 void iwl_set_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask);
-- 
2.29.2


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

* [PATCH for v5.11 07/12] iwlwifi: queue: don't crash if txq->entries is NULL
  2021-01-15 11:05 [PATCH for v5.11 00/12] iwlwifi: fixes intended for v5.10 2020-12-02 Luca Coelho
                   ` (5 preceding siblings ...)
  2021-01-15 11:05 ` [PATCH for v5.11 06/12] iwlwifi: fix the NMI flow for old devices Luca Coelho
@ 2021-01-15 11:05 ` Luca Coelho
  2021-01-15 11:05 ` [PATCH for v5.11 08/12] iwlwifi: pcie: set LTR on more devices Luca Coelho
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Luca Coelho @ 2021-01-15 11:05 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>

The code was really awkward, we would first dereference
txq->entries when calling iwl_txq_genX_tfd_unmap and then
we would check that txq->entries is non-NULL.
Fix that by exiting if txq->entries is NULL.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/queue/tx.c | 49 +++++++++----------
 1 file changed, 24 insertions(+), 25 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/queue/tx.c b/drivers/net/wireless/intel/iwlwifi/queue/tx.c
index 27eea909e32d..62c0c4cbe481 100644
--- a/drivers/net/wireless/intel/iwlwifi/queue/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/queue/tx.c
@@ -142,26 +142,25 @@ void iwl_txq_gen2_free_tfd(struct iwl_trans *trans, struct iwl_txq *txq)
 	 * idx is bounded by n_window
 	 */
 	int idx = iwl_txq_get_cmd_index(txq, txq->read_ptr);
+	struct sk_buff *skb;
 
 	lockdep_assert_held(&txq->lock);
 
+	if (!txq->entries)
+		return;
+
 	iwl_txq_gen2_tfd_unmap(trans, &txq->entries[idx].meta,
 			       iwl_txq_get_tfd(trans, txq, idx));
 
-	/* free SKB */
-	if (txq->entries) {
-		struct sk_buff *skb;
-
-		skb = txq->entries[idx].skb;
+	skb = txq->entries[idx].skb;
 
-		/* Can be called from irqs-disabled context
-		 * If skb is not NULL, it means that the whole queue is being
-		 * freed and that the queue is not empty - free the skb
-		 */
-		if (skb) {
-			iwl_op_mode_free_skb(trans->op_mode, skb);
-			txq->entries[idx].skb = NULL;
-		}
+	/* Can be called from irqs-disabled context
+	 * If skb is not NULL, it means that the whole queue is being
+	 * freed and that the queue is not empty - free the skb
+	 */
+	if (skb) {
+		iwl_op_mode_free_skb(trans->op_mode, skb);
+		txq->entries[idx].skb = NULL;
 	}
 }
 
@@ -1494,28 +1493,28 @@ void iwl_txq_free_tfd(struct iwl_trans *trans, struct iwl_txq *txq)
 	 */
 	int rd_ptr = txq->read_ptr;
 	int idx = iwl_txq_get_cmd_index(txq, rd_ptr);
+	struct sk_buff *skb;
 
 	lockdep_assert_held(&txq->lock);
 
+	if (!txq->entries)
+		return;
+
 	/* We have only q->n_window txq->entries, but we use
 	 * TFD_QUEUE_SIZE_MAX tfds
 	 */
 	iwl_txq_gen1_tfd_unmap(trans, &txq->entries[idx].meta, txq, rd_ptr);
 
 	/* free SKB */
-	if (txq->entries) {
-		struct sk_buff *skb;
-
-		skb = txq->entries[idx].skb;
+	skb = txq->entries[idx].skb;
 
-		/* Can be called from irqs-disabled context
-		 * If skb is not NULL, it means that the whole queue is being
-		 * freed and that the queue is not empty - free the skb
-		 */
-		if (skb) {
-			iwl_op_mode_free_skb(trans->op_mode, skb);
-			txq->entries[idx].skb = NULL;
-		}
+	/* Can be called from irqs-disabled context
+	 * If skb is not NULL, it means that the whole queue is being
+	 * freed and that the queue is not empty - free the skb
+	 */
+	if (skb) {
+		iwl_op_mode_free_skb(trans->op_mode, skb);
+		txq->entries[idx].skb = NULL;
 	}
 }
 
-- 
2.29.2


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

* [PATCH for v5.11 08/12] iwlwifi: pcie: set LTR on more devices
  2021-01-15 11:05 [PATCH for v5.11 00/12] iwlwifi: fixes intended for v5.10 2020-12-02 Luca Coelho
                   ` (6 preceding siblings ...)
  2021-01-15 11:05 ` [PATCH for v5.11 07/12] iwlwifi: queue: don't crash if txq->entries is NULL Luca Coelho
@ 2021-01-15 11:05 ` Luca Coelho
  2021-01-15 11:05 ` [PATCH for v5.11 09/12] iwlwifi: pcie: add a NULL check in iwl_pcie_txq_unmap Luca Coelho
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Luca Coelho @ 2021-01-15 11:05 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Johannes Berg <johannes.berg@intel.com>

To avoid completion timeouts during device boot, set up the
LTR timeouts on more devices - similar to what we had before
for AX210.

This also corrects the AX210 workaround to be done only on
discrete (non-integrated) devices, otherwise the registers
have no effect.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Fixes: edb625208d84 ("iwlwifi: pcie: set LTR to avoid completion timeout")
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/iwl-prph.h |  6 +++
 .../intel/iwlwifi/pcie/ctxt-info-gen3.c       | 39 +++++++++++--------
 2 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-prph.h b/drivers/net/wireless/intel/iwlwifi/iwl-prph.h
index 0b03fdedc1f7..1158e256f601 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-prph.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-prph.h
@@ -301,6 +301,12 @@
 #define RADIO_RSP_ADDR_POS		(6)
 #define RADIO_RSP_RD_CMD		(3)
 
+/* LTR control (Qu only) */
+#define HPM_MAC_LTR_CSR			0xa0348c
+#define HPM_MAC_LRT_ENABLE_ALL		0xf
+/* also uses CSR_LTR_* for values */
+#define HPM_UMAC_LTR			0xa03480
+
 /* FW monitor */
 #define MON_BUFF_SAMPLE_CTL		(0xa03c00)
 #define MON_BUFF_BASE_ADDR		(0xa03c1c)
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 afe585228435..342a53e4488c 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c
@@ -75,6 +75,15 @@ int iwl_pcie_ctxt_info_gen3_init(struct iwl_trans *trans,
 				 const struct fw_img *fw)
 {
 	struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
+	u32 ltr_val = CSR_LTR_LONG_VAL_AD_NO_SNOOP_REQ |
+		      u32_encode_bits(CSR_LTR_LONG_VAL_AD_SCALE_USEC,
+				      CSR_LTR_LONG_VAL_AD_NO_SNOOP_SCALE) |
+		      u32_encode_bits(250,
+				      CSR_LTR_LONG_VAL_AD_NO_SNOOP_VAL) |
+		      CSR_LTR_LONG_VAL_AD_SNOOP_REQ |
+		      u32_encode_bits(CSR_LTR_LONG_VAL_AD_SCALE_USEC,
+				      CSR_LTR_LONG_VAL_AD_SNOOP_SCALE) |
+		      u32_encode_bits(250, CSR_LTR_LONG_VAL_AD_SNOOP_VAL);
 	struct iwl_context_info_gen3 *ctxt_info_gen3;
 	struct iwl_prph_scratch *prph_scratch;
 	struct iwl_prph_scratch_ctrl_cfg *prph_sc_ctrl;
@@ -206,23 +215,19 @@ int iwl_pcie_ctxt_info_gen3_init(struct iwl_trans *trans,
 	iwl_set_bit(trans, CSR_CTXT_INFO_BOOT_CTRL,
 		    CSR_AUTO_FUNC_BOOT_ENA);
 
-	if (trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_AX210) {
-		/*
-		 * The firmware initializes this again later (to a smaller
-		 * value), but for the boot process initialize the LTR to
-		 * ~250 usec.
-		 */
-		u32 val = CSR_LTR_LONG_VAL_AD_NO_SNOOP_REQ |
-			  u32_encode_bits(CSR_LTR_LONG_VAL_AD_SCALE_USEC,
-					  CSR_LTR_LONG_VAL_AD_NO_SNOOP_SCALE) |
-			  u32_encode_bits(250,
-					  CSR_LTR_LONG_VAL_AD_NO_SNOOP_VAL) |
-			  CSR_LTR_LONG_VAL_AD_SNOOP_REQ |
-			  u32_encode_bits(CSR_LTR_LONG_VAL_AD_SCALE_USEC,
-					  CSR_LTR_LONG_VAL_AD_SNOOP_SCALE) |
-			  u32_encode_bits(250, CSR_LTR_LONG_VAL_AD_SNOOP_VAL);
-
-		iwl_write32(trans, CSR_LTR_LONG_VAL_AD, val);
+	/*
+	 * To workaround hardware latency issues during the boot process,
+	 * initialize the LTR to ~250 usec (see ltr_val above).
+	 * The firmware initializes this again later (to a smaller value).
+	 */
+	if ((trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_AX210 ||
+	     trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_22000) &&
+	    !trans->trans_cfg->integrated) {
+		iwl_write32(trans, CSR_LTR_LONG_VAL_AD, ltr_val);
+	} else if (trans->trans_cfg->integrated &&
+		   trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_22000) {
+		iwl_write_prph(trans, HPM_MAC_LTR_CSR, HPM_MAC_LRT_ENABLE_ALL);
+		iwl_write_prph(trans, HPM_UMAC_LTR, ltr_val);
 	}
 
 	if (trans->trans_cfg->device_family >= IWL_DEVICE_FAMILY_AX210)
-- 
2.29.2


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

* [PATCH for v5.11 09/12] iwlwifi: pcie: add a NULL check in iwl_pcie_txq_unmap
  2021-01-15 11:05 [PATCH for v5.11 00/12] iwlwifi: fixes intended for v5.10 2020-12-02 Luca Coelho
                   ` (7 preceding siblings ...)
  2021-01-15 11:05 ` [PATCH for v5.11 08/12] iwlwifi: pcie: set LTR on more devices Luca Coelho
@ 2021-01-15 11:05 ` Luca Coelho
  2021-01-15 11:05 ` [PATCH for v5.11 10/12] iwlwifi: pcie: fix context info memory leak Luca Coelho
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Luca Coelho @ 2021-01-15 11:05 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>

I hit a NULL pointer exception in this function when the
init flow went really bad.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/pcie/tx.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
index 5dda0015522d..83f4964f3cb2 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
@@ -201,6 +201,11 @@ static void iwl_pcie_txq_unmap(struct iwl_trans *trans, int txq_id)
 	struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
 	struct iwl_txq *txq = trans->txqs.txq[txq_id];
 
+	if (!txq) {
+		IWL_ERR(trans, "Trying to free a queue that wasn't allocated?\n");
+		return;
+	}
+
 	spin_lock_bh(&txq->lock);
 	while (txq->write_ptr != txq->read_ptr) {
 		IWL_DEBUG_TX_REPLY(trans, "Q %d Free %d\n",
-- 
2.29.2


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

* [PATCH for v5.11 10/12] iwlwifi: pcie: fix context info memory leak
  2021-01-15 11:05 [PATCH for v5.11 00/12] iwlwifi: fixes intended for v5.10 2020-12-02 Luca Coelho
                   ` (8 preceding siblings ...)
  2021-01-15 11:05 ` [PATCH for v5.11 09/12] iwlwifi: pcie: add a NULL check in iwl_pcie_txq_unmap Luca Coelho
@ 2021-01-15 11:05 ` Luca Coelho
  2021-01-15 11:05 ` [PATCH for v5.11 11/12] iwlwifi: pcie: use jiffies for memory read spin time limit Luca Coelho
  2021-01-15 11:05 ` [PATCH for v5.11 12/12] iwlwifi: pcie: reschedule in long-running memory reads Luca Coelho
  11 siblings, 0 replies; 17+ messages in thread
From: Luca Coelho @ 2021-01-15 11:05 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Johannes Berg <johannes.berg@intel.com>

If the image loader allocation fails, we leak all the previously
allocated memory. Fix this.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 .../net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c  | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

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 342a53e4488c..5b5134dd49af 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c
@@ -198,8 +198,10 @@ int iwl_pcie_ctxt_info_gen3_init(struct iwl_trans *trans,
 	/* Allocate IML */
 	iml_img = dma_alloc_coherent(trans->dev, trans->iml_len,
 				     &trans_pcie->iml_dma_addr, GFP_KERNEL);
-	if (!iml_img)
-		return -ENOMEM;
+	if (!iml_img) {
+		ret = -ENOMEM;
+		goto err_free_ctxt_info;
+	}
 
 	memcpy(iml_img, trans->iml, trans->iml_len);
 
@@ -237,6 +239,11 @@ int iwl_pcie_ctxt_info_gen3_init(struct iwl_trans *trans,
 
 	return 0;
 
+err_free_ctxt_info:
+	dma_free_coherent(trans->dev, sizeof(*trans_pcie->ctxt_info_gen3),
+			  trans_pcie->ctxt_info_gen3,
+			  trans_pcie->ctxt_info_dma_addr);
+	trans_pcie->ctxt_info_gen3 = NULL;
 err_free_prph_info:
 	dma_free_coherent(trans->dev,
 			  sizeof(*prph_info),
-- 
2.29.2


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

* [PATCH for v5.11 11/12] iwlwifi: pcie: use jiffies for memory read spin time limit
  2021-01-15 11:05 [PATCH for v5.11 00/12] iwlwifi: fixes intended for v5.10 2020-12-02 Luca Coelho
                   ` (9 preceding siblings ...)
  2021-01-15 11:05 ` [PATCH for v5.11 10/12] iwlwifi: pcie: fix context info memory leak Luca Coelho
@ 2021-01-15 11:05 ` Luca Coelho
  2021-01-18 15:16   ` Kalle Valo
  2021-01-15 11:05 ` [PATCH for v5.11 12/12] iwlwifi: pcie: reschedule in long-running memory reads Luca Coelho
  11 siblings, 1 reply; 17+ messages in thread
From: Luca Coelho @ 2021-01-15 11:05 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Johannes Berg <johannes.berg@intel.com>

There's no reason to use ktime_get() since we don't need any better
precision than jiffies, and since we no longer disable interrupts
around this code (when grabbing NIC access), jiffies will work fine.
Use jiffies instead of ktime_get().

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index 285e0d586021..e3760c41b31e 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -2107,7 +2107,7 @@ static int iwl_trans_pcie_read_mem(struct iwl_trans *trans, u32 addr,
 
 	while (offs < dwords) {
 		/* limit the time we spin here under lock to 1/2s */
-		ktime_t timeout = ktime_add_us(ktime_get(), 500 * USEC_PER_MSEC);
+		unsigned long end = jiffies + HZ / 2;
 
 		if (iwl_trans_grab_nic_access(trans, &flags)) {
 			iwl_write32(trans, HBUS_TARG_MEM_RADDR,
@@ -2118,11 +2118,7 @@ static int iwl_trans_pcie_read_mem(struct iwl_trans *trans, u32 addr,
 							HBUS_TARG_MEM_RDAT);
 				offs++;
 
-				/* calling ktime_get is expensive so
-				 * do it once in 128 reads
-				 */
-				if (offs % 128 == 0 && ktime_after(ktime_get(),
-								   timeout))
+				if (time_after(jiffies, end))
 					break;
 			}
 			iwl_trans_release_nic_access(trans, &flags);
-- 
2.29.2


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

* [PATCH for v5.11 12/12] iwlwifi: pcie: reschedule in long-running memory reads
  2021-01-15 11:05 [PATCH for v5.11 00/12] iwlwifi: fixes intended for v5.10 2020-12-02 Luca Coelho
                   ` (10 preceding siblings ...)
  2021-01-15 11:05 ` [PATCH for v5.11 11/12] iwlwifi: pcie: use jiffies for memory read spin time limit Luca Coelho
@ 2021-01-15 11:05 ` Luca Coelho
  11 siblings, 0 replies; 17+ messages in thread
From: Luca Coelho @ 2021-01-15 11:05 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless

From: Johannes Berg <johannes.berg@intel.com>

If we spin for a long time in memory reads that (for some reason in
hardware) take a long time, then we'll eventually get messages such
as

  watchdog: BUG: soft lockup - CPU#2 stuck for 24s! [kworker/2:2:272]

This is because the reading really does take a very long time, and
we don't schedule, so we're hogging the CPU with this task, at least
if CONFIG_PREEMPT is not set, e.g. with CONFIG_PREEMPT_VOLUNTARY=y.

Previously I misinterpreted the situation and thought that this was
only going to happen if we had interrupts disabled, and then fixed
this (which is good anyway, however), but that didn't always help;
looking at it again now I realized that the spin unlock will only
reschedule if CONFIG_PREEMPT is used.

In order to avoid this issue, change the code to cond_resched() if
we've been spinning for too long here.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Fixes: 04516706bb99 ("iwlwifi: pcie: limit memory read spin time")
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index e3760c41b31e..ab93a848a466 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -2108,6 +2108,7 @@ static int iwl_trans_pcie_read_mem(struct iwl_trans *trans, u32 addr,
 	while (offs < dwords) {
 		/* limit the time we spin here under lock to 1/2s */
 		unsigned long end = jiffies + HZ / 2;
+		bool resched = false;
 
 		if (iwl_trans_grab_nic_access(trans, &flags)) {
 			iwl_write32(trans, HBUS_TARG_MEM_RADDR,
@@ -2118,10 +2119,15 @@ static int iwl_trans_pcie_read_mem(struct iwl_trans *trans, u32 addr,
 							HBUS_TARG_MEM_RDAT);
 				offs++;
 
-				if (time_after(jiffies, end))
+				if (time_after(jiffies, end)) {
+					resched = true;
 					break;
+				}
 			}
 			iwl_trans_release_nic_access(trans, &flags);
+
+			if (resched)
+				cond_resched();
 		} else {
 			return -EBUSY;
 		}
-- 
2.29.2


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

* Re: [PATCH for v5.11 11/12] iwlwifi: pcie: use jiffies for memory read spin time limit
  2021-01-15 11:05 ` [PATCH for v5.11 11/12] iwlwifi: pcie: use jiffies for memory read spin time limit Luca Coelho
@ 2021-01-18 15:16   ` Kalle Valo
  2021-01-18 15:18     ` Kalle Valo
  0 siblings, 1 reply; 17+ messages in thread
From: Kalle Valo @ 2021-01-18 15:16 UTC (permalink / raw)
  To: Luca Coelho; +Cc: linux-wireless

Luca Coelho <luca@coelho.fi> writes:

> From: Johannes Berg <johannes.berg@intel.com>
>
> There's no reason to use ktime_get() since we don't need any better
> precision than jiffies, and since we no longer disable interrupts
> around this code (when grabbing NIC access), jiffies will work fine.
> Use jiffies instead of ktime_get().
>
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> Signed-off-by: Luca Coelho <luciano.coelho@intel.com>

What bug does this fix? After reading the commit log to me this looks
like more like cleanup and is better for -next.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

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

* Re: [PATCH for v5.11 11/12] iwlwifi: pcie: use jiffies for memory read spin time limit
  2021-01-18 15:16   ` Kalle Valo
@ 2021-01-18 15:18     ` Kalle Valo
  2021-01-18 15:51       ` Luca Coelho
  0 siblings, 1 reply; 17+ messages in thread
From: Kalle Valo @ 2021-01-18 15:18 UTC (permalink / raw)
  To: Luca Coelho; +Cc: linux-wireless

Kalle Valo <kvalo@codeaurora.org> writes:

> Luca Coelho <luca@coelho.fi> writes:
>
>> From: Johannes Berg <johannes.berg@intel.com>
>>
>> There's no reason to use ktime_get() since we don't need any better
>> precision than jiffies, and since we no longer disable interrupts
>> around this code (when grabbing NIC access), jiffies will work fine.
>> Use jiffies instead of ktime_get().
>>
>> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
>> Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
>
> What bug does this fix? After reading the commit log to me this looks
> like more like cleanup and is better for -next.

Ah, this is a dependency for patch 12. I'll mention this in the commit
log, but please correct me if I have misunderstood.

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

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

* Re: [PATCH for v5.11 11/12] iwlwifi: pcie: use jiffies for memory read spin time limit
  2021-01-18 15:18     ` Kalle Valo
@ 2021-01-18 15:51       ` Luca Coelho
  0 siblings, 0 replies; 17+ messages in thread
From: Luca Coelho @ 2021-01-18 15:51 UTC (permalink / raw)
  To: Kalle Valo; +Cc: linux-wireless

On Mon, 2021-01-18 at 17:18 +0200, Kalle Valo wrote:
> Kalle Valo <kvalo@codeaurora.org> writes:
> 
> > Luca Coelho <luca@coelho.fi> writes:
> > 
> > > From: Johannes Berg <johannes.berg@intel.com>
> > > 
> > > There's no reason to use ktime_get() since we don't need any better
> > > precision than jiffies, and since we no longer disable interrupts
> > > around this code (when grabbing NIC access), jiffies will work fine.
> > > Use jiffies instead of ktime_get().
> > > 
> > > Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> > > Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
> > 
> > What bug does this fix? After reading the commit log to me this looks
> > like more like cleanup and is better for -next.
> 
> Ah, this is a dependency for patch 12. I'll mention this in the commit
> log, but please correct me if I have misunderstood.

Yes, you're right! It's a dependency and I thought it would be simpler
and cause less conflicts if I just took it too instead of sending them
via different trees.

--
Cheers,
Luca.


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

* Re: [PATCH for v5.11 01/12] iwlwifi: mvm: skip power command when unbinding vif during CSA
  2021-01-15 11:05 ` [PATCH for v5.11 01/12] iwlwifi: mvm: skip power command when unbinding vif during CSA Luca Coelho
@ 2021-01-25 13:54   ` Kalle Valo
  0 siblings, 0 replies; 17+ messages in thread
From: Kalle Valo @ 2021-01-25 13:54 UTC (permalink / raw)
  To: Luca Coelho; +Cc: linux-wireless

Luca Coelho <luca@coelho.fi> wrote:

> From: Sara Sharon <sara.sharon@intel.com>
> 
> In the new CSA flow, we remain associated during CSA, but
> still do a unbind-bind to the vif. However, sending the power
> command right after when vif is unbound but still associated
> causes FW to assert (0x3400) since it cannot tell the LMAC id.
> 
> Just skip this command, we will send it again in a bit, when
> assigning the new context.
> 
> Signed-off-by: Sara Sharon <sara.sharon@intel.com>
> Signed-off-by: Luca Coelho <luciano.coelho@intel.com>

12 patches applied to wireless-drivers.git, thanks.

bf544e9aa570 iwlwifi: mvm: skip power command when unbinding vif during CSA
5c56d862c749 iwlwifi: mvm: take mutex for calling iwl_mvm_get_sync_time()
34b9434cd0d4 iwlwifi: pcie: avoid potential PNVM leaks
1c58bed4b7f7 iwlwifi: pnvm: don't skip everything when not reloading
82a08d0cd7b5 iwlwifi: pnvm: don't try to load after failures
a800f95858d0 iwlwifi: fix the NMI flow for old devices
0f8d5656b3fd iwlwifi: queue: don't crash if txq->entries is NULL
ed0022da8bd9 iwlwifi: pcie: set LTR on more devices
98c7d21f957b iwlwifi: pcie: add a NULL check in iwl_pcie_txq_unmap
2d6bc752cc28 iwlwifi: pcie: fix context info memory leak
6701317476bb iwlwifi: pcie: use jiffies for memory read spin time limit
3d372c4edfd4 iwlwifi: pcie: reschedule in long-running memory reads

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/iwlwifi.20210115130252.64a2254ac5c3.Iaa3a9050bf3d7c9cd5beaf561e932e6defc12ec3@changeid/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


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

end of thread, other threads:[~2021-01-25 14:12 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-15 11:05 [PATCH for v5.11 00/12] iwlwifi: fixes intended for v5.10 2020-12-02 Luca Coelho
2021-01-15 11:05 ` [PATCH for v5.11 01/12] iwlwifi: mvm: skip power command when unbinding vif during CSA Luca Coelho
2021-01-25 13:54   ` Kalle Valo
2021-01-15 11:05 ` [PATCH for v5.11 02/12] iwlwifi: mvm: take mutex for calling iwl_mvm_get_sync_time() Luca Coelho
2021-01-15 11:05 ` [PATCH for v5.11 03/12] iwlwifi: pcie: avoid potential PNVM leaks Luca Coelho
2021-01-15 11:05 ` [PATCH for v5.11 04/12] iwlwifi: pnvm: don't skip everything when not reloading Luca Coelho
2021-01-15 11:05 ` [PATCH for v5.11 05/12] iwlwifi: pnvm: don't try to load after failures Luca Coelho
2021-01-15 11:05 ` [PATCH for v5.11 06/12] iwlwifi: fix the NMI flow for old devices Luca Coelho
2021-01-15 11:05 ` [PATCH for v5.11 07/12] iwlwifi: queue: don't crash if txq->entries is NULL Luca Coelho
2021-01-15 11:05 ` [PATCH for v5.11 08/12] iwlwifi: pcie: set LTR on more devices Luca Coelho
2021-01-15 11:05 ` [PATCH for v5.11 09/12] iwlwifi: pcie: add a NULL check in iwl_pcie_txq_unmap Luca Coelho
2021-01-15 11:05 ` [PATCH for v5.11 10/12] iwlwifi: pcie: fix context info memory leak Luca Coelho
2021-01-15 11:05 ` [PATCH for v5.11 11/12] iwlwifi: pcie: use jiffies for memory read spin time limit Luca Coelho
2021-01-18 15:16   ` Kalle Valo
2021-01-18 15:18     ` Kalle Valo
2021-01-18 15:51       ` Luca Coelho
2021-01-15 11:05 ` [PATCH for v5.11 12/12] iwlwifi: pcie: reschedule in long-running memory reads 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).