Message ID | 20210202132944.017286490@linuxfoundation.org |
---|---|
State | Superseded |
Headers | show |
Series | None | expand |
Hi! > From: Johannes Berg <johannes.berg@intel.com> > > [ Upstream commit 6701317476bbfb1f341aa935ddf75eb73af784f9 ] > > 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(). > > This cleanup is preparation for the following patch "iwlwifi: pcie: reschedule > in long-running memory reads". The code gets simpler with the weird clock use > etc. removed before we add cond_resched(). As far as I can tell, this is not really suitable for v4.19 (and probably others), as we still disable interrupts in iwl_trans_pcie_release_nic_access() in 4.19. Best regards, Pavel > @@ -2137,11 +2137,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); -- http://www.livejournal.com/~pavelmachek
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c index f48c7cac122e9..fe772b716a8df 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c @@ -2126,7 +2126,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, @@ -2137,11 +2137,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);