@@ -4319,13 +4319,16 @@ void e1000e_reinit_locked(struct e1000_adapter *adapter)
4319
4319
/**
4320
4320
* e1000e_sanitize_systim - sanitize raw cycle counter reads
4321
4321
* @hw: pointer to the HW structure
4322
- * @systim: time value read, sanitized and returned
4322
+ * @systim: PHC time value read, sanitized and returned
4323
+ * @sts: structure to hold system time before and after reading SYSTIML,
4324
+ * may be NULL
4323
4325
*
4324
4326
* Errata for 82574/82583 possible bad bits read from SYSTIMH/L:
4325
4327
* check to see that the time is incrementing at a reasonable
4326
4328
* rate and is a multiple of incvalue.
4327
4329
**/
4328
- static u64 e1000e_sanitize_systim (struct e1000_hw * hw , u64 systim )
4330
+ static u64 e1000e_sanitize_systim (struct e1000_hw * hw , u64 systim ,
4331
+ struct ptp_system_timestamp * sts )
4329
4332
{
4330
4333
u64 time_delta , rem , temp ;
4331
4334
u64 systim_next ;
@@ -4335,7 +4338,9 @@ static u64 e1000e_sanitize_systim(struct e1000_hw *hw, u64 systim)
4335
4338
incvalue = er32 (TIMINCA ) & E1000_TIMINCA_INCVALUE_MASK ;
4336
4339
for (i = 0 ; i < E1000_MAX_82574_SYSTIM_REREADS ; i ++ ) {
4337
4340
/* latch SYSTIMH on read of SYSTIML */
4341
+ ptp_read_system_prets (sts );
4338
4342
systim_next = (u64 )er32 (SYSTIML );
4343
+ ptp_read_system_postts (sts );
4339
4344
systim_next |= (u64 )er32 (SYSTIMH ) << 32 ;
4340
4345
4341
4346
time_delta = systim_next - systim ;
@@ -4353,27 +4358,32 @@ static u64 e1000e_sanitize_systim(struct e1000_hw *hw, u64 systim)
4353
4358
}
4354
4359
4355
4360
/**
4356
- * e1000e_cyclecounter_read - read raw cycle counter (used by time counter)
4357
- * @cc: cyclecounter structure
4361
+ * e1000e_read_systim - read SYSTIM register
4362
+ * @adapter: board private structure
4363
+ * @sts: structure which will contain system time before and after reading
4364
+ * SYSTIML, may be NULL
4358
4365
**/
4359
- static u64 e1000e_cyclecounter_read (const struct cyclecounter * cc )
4366
+ u64 e1000e_read_systim (struct e1000_adapter * adapter ,
4367
+ struct ptp_system_timestamp * sts )
4360
4368
{
4361
- struct e1000_adapter * adapter = container_of (cc , struct e1000_adapter ,
4362
- cc );
4363
4369
struct e1000_hw * hw = & adapter -> hw ;
4364
- u32 systimel , systimeh ;
4370
+ u32 systimel , systimel_2 , systimeh ;
4365
4371
u64 systim ;
4366
4372
/* SYSTIMH latching upon SYSTIML read does not work well.
4367
4373
* This means that if SYSTIML overflows after we read it but before
4368
4374
* we read SYSTIMH, the value of SYSTIMH has been incremented and we
4369
4375
* will experience a huge non linear increment in the systime value
4370
4376
* to fix that we test for overflow and if true, we re-read systime.
4371
4377
*/
4378
+ ptp_read_system_prets (sts );
4372
4379
systimel = er32 (SYSTIML );
4380
+ ptp_read_system_postts (sts );
4373
4381
systimeh = er32 (SYSTIMH );
4374
4382
/* Is systimel is so large that overflow is possible? */
4375
4383
if (systimel >= (u32 )0xffffffff - E1000_TIMINCA_INCVALUE_MASK ) {
4376
- u32 systimel_2 = er32 (SYSTIML );
4384
+ ptp_read_system_prets (sts );
4385
+ systimel_2 = er32 (SYSTIML );
4386
+ ptp_read_system_postts (sts );
4377
4387
if (systimel > systimel_2 ) {
4378
4388
/* There was an overflow, read again SYSTIMH, and use
4379
4389
* systimel_2
@@ -4386,11 +4396,23 @@ static u64 e1000e_cyclecounter_read(const struct cyclecounter *cc)
4386
4396
systim |= (u64 )systimeh << 32 ;
4387
4397
4388
4398
if (adapter -> flags2 & FLAG2_CHECK_SYSTIM_OVERFLOW )
4389
- systim = e1000e_sanitize_systim (hw , systim );
4399
+ systim = e1000e_sanitize_systim (hw , systim , sts );
4390
4400
4391
4401
return systim ;
4392
4402
}
4393
4403
4404
+ /**
4405
+ * e1000e_cyclecounter_read - read raw cycle counter (used by time counter)
4406
+ * @cc: cyclecounter structure
4407
+ **/
4408
+ static u64 e1000e_cyclecounter_read (const struct cyclecounter * cc )
4409
+ {
4410
+ struct e1000_adapter * adapter = container_of (cc , struct e1000_adapter ,
4411
+ cc );
4412
+
4413
+ return e1000e_read_systim (adapter , NULL );
4414
+ }
4415
+
4394
4416
/**
4395
4417
* e1000_sw_init - Initialize general software structures (struct e1000_adapter)
4396
4418
* @adapter: board private structure to initialize
0 commit comments