diff mbox series

[for,v5.11,11/12] iwlwifi: pcie: use jiffies for memory read spin time limit

Message ID iwlwifi.20210115130253.621c948b1fad.I3ee9f4bc4e74a0c9125d42fb7c35cd80df4698a1@changeid
State New
Headers show
Series iwlwifi: fixes intended for v5.10 2020-12-02 | expand

Commit Message

Luca Coelho Jan. 15, 2021, 11:05 a.m. UTC
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(-)

Comments

Kalle Valo Jan. 18, 2021, 3:16 p.m. UTC | #1
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
Kalle Valo Jan. 18, 2021, 3:18 p.m. UTC | #2
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
Luca Coelho Jan. 18, 2021, 3:51 p.m. UTC | #3
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.
diff mbox series

Patch

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