Skip to content

Commit 37b1291

Browse files
ravargilJeff Kirsher
authored andcommitted
e1000e: Fix tight loop implementation of systime read algorithm
Change the algorithm. Read systimel twice and check for overflow. If there was no overflow, use the first value. If there was an overflow, read systimeh again and use the second systimel value. Signed-off-by: Raanan Avargil <raanan.avargil@intel.com> Tested-by: Aaron Brown <aaron.f.brown@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
1 parent 2758f9e commit 37b1291

File tree

1 file changed

+21
-10
lines changed
  • drivers/net/ethernet/intel/e1000e

1 file changed

+21
-10
lines changed

drivers/net/ethernet/intel/e1000e/netdev.c

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4280,18 +4280,29 @@ static cycle_t e1000e_cyclecounter_read(const struct cyclecounter *cc)
42804280
struct e1000_adapter *adapter = container_of(cc, struct e1000_adapter,
42814281
cc);
42824282
struct e1000_hw *hw = &adapter->hw;
4283+
u32 systimel_1, systimel_2, systimeh;
42834284
cycle_t systim, systim_next;
4284-
/* SYSTIMH latching upon SYSTIML read does not work well. To fix that
4285-
* we don't want to allow overflow of SYSTIML and a change to SYSTIMH
4286-
* to occur between reads, so if we read a vale close to overflow, we
4287-
* wait for overflow to occur and read both registers when its safe.
4285+
/* SYSTIMH latching upon SYSTIML read does not work well.
4286+
* This means that if SYSTIML overflows after we read it but before
4287+
* we read SYSTIMH, the value of SYSTIMH has been incremented and we
4288+
* will experience a huge non linear increment in the systime value
4289+
* to fix that we test for overflow and if true, we re-read systime.
42884290
*/
4289-
u32 systim_overflow_latch_fix = 0x3FFFFFFF;
4290-
4291-
do {
4292-
systim = (cycle_t)er32(SYSTIML);
4293-
} while (systim > systim_overflow_latch_fix);
4294-
systim |= (cycle_t)er32(SYSTIMH) << 32;
4291+
systimel_1 = er32(SYSTIML);
4292+
systimeh = er32(SYSTIMH);
4293+
systimel_2 = er32(SYSTIML);
4294+
/* Check for overflow. If there was no overflow, use the values */
4295+
if (systimel_1 < systimel_2) {
4296+
systim = (cycle_t)systimel_1;
4297+
systim |= (cycle_t)systimeh << 32;
4298+
} else {
4299+
/* There was an overflow, read again SYSTIMH, and use
4300+
* systimel_2
4301+
*/
4302+
systimeh = er32(SYSTIMH);
4303+
systim = (cycle_t)systimel_2;
4304+
systim |= (cycle_t)systimeh << 32;
4305+
}
42954306

42964307
if ((hw->mac.type == e1000_82574) || (hw->mac.type == e1000_82583)) {
42974308
u64 incvalue, time_delta, rem, temp;

0 commit comments

Comments
 (0)