Skip to content

Commit 25d7a5f

Browse files
jacob-kelleranguy11
authored andcommitted
ixgbe: stop resetting SYSTIME in ixgbe_ptp_start_cyclecounter
The ixgbe_ptp_start_cyclecounter is intended to be called whenever the cyclecounter parameters need to be changed. Since commit a9763f3 ("ixgbe: Update PTP to support X550EM_x devices"), this function has cleared the SYSTIME registers and reset the TSAUXC DISABLE_SYSTIME bit. While these need to be cleared during ixgbe_ptp_reset, it is wrong to clear them during ixgbe_ptp_start_cyclecounter. This function may be called during both reset and link status change. When link changes, the SYSTIME counter is still operating normally, but the cyclecounter should be updated to account for the possibly changed parameters. Clearing SYSTIME when link changes causes the timecounter to jump because the cycle counter now reads zero. Extract the SYSTIME initialization out to a new function and call this during ixgbe_ptp_reset. This prevents the timecounter adjustment and avoids an unnecessary reset of the current time. This also restores the original SYSTIME clearing that occurred during ixgbe_ptp_reset before the commit above. Reported-by: Steve Payne <[email protected]> Reported-by: Ilya Evenbach <[email protected]> Fixes: a9763f3 ("ixgbe: Update PTP to support X550EM_x devices") Signed-off-by: Jacob Keller <[email protected]> Tested-by: Gurucharan <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]>
1 parent 0c4a954 commit 25d7a5f

File tree

1 file changed

+46
-13
lines changed

1 file changed

+46
-13
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,6 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
12141214
struct cyclecounter cc;
12151215
unsigned long flags;
12161216
u32 incval = 0;
1217-
u32 tsauxc = 0;
12181217
u32 fuse0 = 0;
12191218

12201219
/* For some of the boards below this mask is technically incorrect.
@@ -1249,18 +1248,6 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
12491248
case ixgbe_mac_x550em_a:
12501249
case ixgbe_mac_X550:
12511250
cc.read = ixgbe_ptp_read_X550;
1252-
1253-
/* enable SYSTIME counter */
1254-
IXGBE_WRITE_REG(hw, IXGBE_SYSTIMR, 0);
1255-
IXGBE_WRITE_REG(hw, IXGBE_SYSTIML, 0);
1256-
IXGBE_WRITE_REG(hw, IXGBE_SYSTIMH, 0);
1257-
tsauxc = IXGBE_READ_REG(hw, IXGBE_TSAUXC);
1258-
IXGBE_WRITE_REG(hw, IXGBE_TSAUXC,
1259-
tsauxc & ~IXGBE_TSAUXC_DISABLE_SYSTIME);
1260-
IXGBE_WRITE_REG(hw, IXGBE_TSIM, IXGBE_TSIM_TXTS);
1261-
IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_TIMESYNC);
1262-
1263-
IXGBE_WRITE_FLUSH(hw);
12641251
break;
12651252
case ixgbe_mac_X540:
12661253
cc.read = ixgbe_ptp_read_82599;
@@ -1292,6 +1279,50 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
12921279
spin_unlock_irqrestore(&adapter->tmreg_lock, flags);
12931280
}
12941281

1282+
/**
1283+
* ixgbe_ptp_init_systime - Initialize SYSTIME registers
1284+
* @adapter: the ixgbe private board structure
1285+
*
1286+
* Initialize and start the SYSTIME registers.
1287+
*/
1288+
static void ixgbe_ptp_init_systime(struct ixgbe_adapter *adapter)
1289+
{
1290+
struct ixgbe_hw *hw = &adapter->hw;
1291+
u32 tsauxc;
1292+
1293+
switch (hw->mac.type) {
1294+
case ixgbe_mac_X550EM_x:
1295+
case ixgbe_mac_x550em_a:
1296+
case ixgbe_mac_X550:
1297+
tsauxc = IXGBE_READ_REG(hw, IXGBE_TSAUXC);
1298+
1299+
/* Reset SYSTIME registers to 0 */
1300+
IXGBE_WRITE_REG(hw, IXGBE_SYSTIMR, 0);
1301+
IXGBE_WRITE_REG(hw, IXGBE_SYSTIML, 0);
1302+
IXGBE_WRITE_REG(hw, IXGBE_SYSTIMH, 0);
1303+
1304+
/* Reset interrupt settings */
1305+
IXGBE_WRITE_REG(hw, IXGBE_TSIM, IXGBE_TSIM_TXTS);
1306+
IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_TIMESYNC);
1307+
1308+
/* Activate the SYSTIME counter */
1309+
IXGBE_WRITE_REG(hw, IXGBE_TSAUXC,
1310+
tsauxc & ~IXGBE_TSAUXC_DISABLE_SYSTIME);
1311+
break;
1312+
case ixgbe_mac_X540:
1313+
case ixgbe_mac_82599EB:
1314+
/* Reset SYSTIME registers to 0 */
1315+
IXGBE_WRITE_REG(hw, IXGBE_SYSTIML, 0);
1316+
IXGBE_WRITE_REG(hw, IXGBE_SYSTIMH, 0);
1317+
break;
1318+
default:
1319+
/* Other devices aren't supported */
1320+
return;
1321+
};
1322+
1323+
IXGBE_WRITE_FLUSH(hw);
1324+
}
1325+
12951326
/**
12961327
* ixgbe_ptp_reset
12971328
* @adapter: the ixgbe private board structure
@@ -1318,6 +1349,8 @@ void ixgbe_ptp_reset(struct ixgbe_adapter *adapter)
13181349

13191350
ixgbe_ptp_start_cyclecounter(adapter);
13201351

1352+
ixgbe_ptp_init_systime(adapter);
1353+
13211354
spin_lock_irqsave(&adapter->tmreg_lock, flags);
13221355
timecounter_init(&adapter->hw_tc, &adapter->hw_cc,
13231356
ktime_to_ns(ktime_get_real()));

0 commit comments

Comments
 (0)