ixgbe: stop resetting SYSTIME in ixgbe_ptp_start_cyclecounter
Subsystems (2)
PATCH 1/1 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 a9763f3cb54c ("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 ixtbe_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.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c | 59 +++++++++++++++----- 1 file changed, 46 insertions(+), 13 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c +46 -13
@@ -1208,7 +1208,6 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)struct cyclecounter cc;unsigned long flags;u32 incval =0 ; -u32 tsauxc =0 ;u32 fuse0 =0 ;/* For some of the boards below this mask is technically incorrect.
@@ -1243,18 +1242,6 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)case ixgbe_mac_x550em_a:case ixgbe_mac_X550: cc.read = ixgbe_ptp_read_X550; - -/* enable SYSTIME counter */ -IXGBE_WRITE_REG (hw,IXGBE_SYSTIMR ,0 ); -IXGBE_WRITE_REG (hw,IXGBE_SYSTIML ,0 ); -IXGBE_WRITE_REG (hw,IXGBE_SYSTIMH ,0 ); - tsauxc =IXGBE_READ_REG (hw,IXGBE_TSAUXC ); -IXGBE_WRITE_REG (hw,IXGBE_TSAUXC , - tsauxc & ~IXGBE_TSAUXC_DISABLE_SYSTIME ); -IXGBE_WRITE_REG (hw,IXGBE_TSIM ,IXGBE_TSIM_TXTS ); -IXGBE_WRITE_REG (hw,IXGBE_EIMS ,IXGBE_EIMS_TIMESYNC ); - -IXGBE_WRITE_FLUSH (hw);break ;case ixgbe_mac_X540: cc.read = ixgbe_ptp_read_82599;
@@ -1286,6 +1273,50 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)spin_unlock_irqrestore (&adapter->tmreg_lock, flags); } +/** +* ixgbe_ptp_init_systime - Initialize SYSTIME registers +* @adapter: the ixgbe private board structure +* +* Initialize and start the SYSTIME registers. +*/ +static void ixgbe_ptp_init_systime (struct ixgbe_adapter *adapter) +{ +struct ixgbe_hw *hw = &adapter->hw; +u32 tsauxc; + +switch (hw->mac.type) { +case ixgbe_mac_X550EM_x: +case ixgbe_mac_x550em_a: +case ixgbe_mac_X550: + tsauxc =IXGBE_READ_REG (hw,IXGBE_TSAUXC ); + +/* Reset SYSTIME registers to 0 */ +IXGBE_WRITE_REG (hw,IXGBE_SYSTIMR ,0 ); +IXGBE_WRITE_REG (hw,IXGBE_SYSTIML ,0 ); +IXGBE_WRITE_REG (hw,IXGBE_SYSTIMH ,0 ); + +/* Reset interrupt settings */ +IXGBE_WRITE_REG (hw,IXGBE_TSIM ,IXGBE_TSIM_TXTS ); +IXGBE_WRITE_REG (hw,IXGBE_EIMS ,IXGBE_EIMS_TIMESYNC ); + +/* Activate the SYSTIME counter */ +IXGBE_WRITE_REG (hw,IXGBE_TSAUXC , + tsauxc & ~IXGBE_TSAUXC_DISABLE_SYSTIME ); +break ; +case ixgbe_mac_X540: +case ixgbe_mac_82599EB: +/* Reset SYSTIME registers to 0 */ +IXGBE_WRITE_REG (hw,IXGBE_SYSTIML ,0 ); +IXGBE_WRITE_REG (hw,IXGBE_SYSTIMH ,0 ); +break ; +default : +/* Other devices aren't supported */ +return ; + }; + +IXGBE_WRITE_FLUSH (hw); +} +/** * ixgbe_ptp_reset * @adapter: the ixgbe private board structure
@@ -1312,6 +1343,8 @@ void ixgbe_ptp_reset(struct ixgbe_adapter *adapter)ixgbe_ptp_start_cyclecounter (adapter); +ixgbe_ptp_init_systime (adapter); +spin_lock_irqsave (&adapter->tmreg_lock, flags);timecounter_init (&adapter->hw_tc, &adapter->hw_cc,ktime_to_ns (ktime_get_real ()));
base-commit: a41b17ff9dacd22f5f118ee53d82da0f3e52d5e3
Signature · 6 lines
2.37.1.208.ge72d93e88cb2 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Quoted 35 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jacob Keller
Sent: Tuesday, August 2, 2022 5:54 AM
To: Intel Wired LAN <[email protected]>
Cc: Steve Payne <[email protected]>; Ilya Evenbach <[email protected]>
Subject: [Intel-wired-lan] [PATCH net] ixgbe: stop resetting SYSTIME inixgbe_ptp_start_cyclecounterThe
ixgbe_ptp_start_cyclecounteris intended to be called whenever the cyclecounter parameters need to be changed.Since commit
a9763f3cb54c("ixgbe: Update PTP to supportX550EM_xdevices"), this function has cleared the SYSTIME registers and reset the TSAUXCDISABLE_SYSTIMEbit.While these need to be cleared during
ixgbe_ptp_reset, it is wrong to clear them duringixtbe_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_resetbefore the commit above.
Quoted 8 lines
Reported-by Steve Payne <[email protected]>Reported-by Ilya Evenbach <[email protected]>Fixes a9763f3cb54c ("ixgbe: Update PTP to support X550EM_x devices")Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c | 59 +++++++++++++++----- 1 file changed, 46 insertions(+), 13 deletions(-)
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan