Skip to contentSkip to conversation

ptp: netc: explicitly clear TMR_OFF during initialization

PATCH Superseded [email protected] 2 participants 2 messages Jul 6

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ptp: netc: explicitly clear TMR_OFF during initialization

From: Clark Wang <[email protected]>

The NETC timer does not support function level reset, so TMR_OFF_L/H registers are not cleared by pcie_flr(). If TMR_OFF was set to a non-zero value in a previous binding, it will persist across driver rebind and cause inaccurate PTP time.

There is also a hardware issue: after a warm reset or soft reset, TMR_OFF_L/H registers appear to be cleared to zero, but the timer clock domain internally retains the stale value. When the timer is re-enabled, TMR_CUR_TIME continues to track the old offset until TMR_OFF is written explicitly. This can cause incorrect PTP timestamps and even PTP clock synchronization failures.

Per the recommendation from the IP team, explicitly write 0 to TMR_OFF in netc_timer_init() to flush the internally cached value and ensure TMR_CUR_TIME follows the freshly initialized counter.

Fixes 87a201d59963 ("ptp: netc: add NETC V4 Timer PTP driver support")
---
 drivers/ptp/ptp_netc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/ptp/ptp_netc.c +1 -0
index 94e952ee6990..5e381c354d74 100644
@@ -779,6 +779,7 @@ static void netc_timer_init(struct netc_timer *priv)
 	netc_timer_wr(priv, NETC_TMR_FIPER_CTRL, fiper_ctrl);
 	netc_timer_wr(priv, NETC_TMR_ECTRL, NETC_TMR_DEFAULT_ETTF_THR);
 
+	netc_timer_offset_write(priv, 0);
 	ktime_get_real_ts64(&now);
 	ns = timespec64_to_ns(&now);
 	netc_timer_cnt_write(priv, ns);
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 30 lines · On 06/07/2026 09:12, [email protected] wrote:

From: Clark Wang <[email protected]>

The NETC timer does not support function level reset, so TMR_OFF_L/H registers are not cleared by pcie_flr(). If TMR_OFF was set to a non-zero value in a previous binding, it will persist across driver rebind and cause inaccurate PTP time.

There is also a hardware issue: after a warm reset or soft reset, TMR_OFF_L/H registers appear to be cleared to zero, but the timer clock domain internally retains the stale value. When the timer is re-enabled, TMR_CUR_TIME continues to track the old offset until TMR_OFF is written explicitly. This can cause incorrect PTP timestamps and even PTP clock synchronization failures.

Per the recommendation from the IP team, explicitly write 0 to TMR_OFF in netc_timer_init() to flush the internally cached value and ensure TMR_CUR_TIME follows the freshly initialized counter.

Fixes 87a201d59963 ("ptp: netc: add NETC V4 Timer PTP driver support")
---
  drivers/ptp/ptp_netc.c | 1 +
  1 file changed, 1 insertion(+)
drivers/ptp/ptp_netc.c +0 -0
index 94e952ee6990..5e381c354d74 100644

drivers/ptp/ptp_netc.c static void netc_timer_init(struct netc_timer *priv) · line 785

Quoted 7 lines
drivers/ptp/ptp_netc.c +1 -0
@@ -779,6 +779,7 @@ static void netc_timer_init(struct netc_timer *priv)
  	netc_timer_wr(priv, NETC_TMR_FIPER_CTRL, fiper_ctrl);
  	netc_timer_wr(priv, NETC_TMR_ECTRL, NETC_TMR_DEFAULT_ETTF_THR);
 
+	netc_timer_offset_write(priv, 0);
  	ktime_get_real_ts64(&now);
  	ns = timespec64_to_ns(&now);
  	netc_timer_cnt_write(priv, ns);