When a virtual clock is being created, initialize the timecounter to the
current system time instead of the Unix epoch to avoid very large steps
when the clock will be synchronized.
Signed-off-by: Miroslav Lichvar <redacted>
Cc: Yangbo Lu <yangbo.lu@nxp.com>
Cc: Richard Cochran <richardcochran@gmail.com>
---
drivers/ptp/ptp_vclock.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/ptp/ptp_vclock.c b/drivers/ptp/ptp_vclock.c
index cb179a3ea508..5a24a5128013 100644
--- a/drivers/ptp/ptp_vclock.c
+++ b/drivers/ptp/ptp_vclock.c
@@ -187,7 +187,8 @@ struct ptp_vclock *ptp_vclock_register(struct ptp_clock *pclock)
return NULL;
}
- timecounter_init(&vclock->tc, &vclock->cc, 0);
+ timecounter_init(&vclock->tc, &vclock->cc,
+ ktime_to_ns(ktime_get_real()));
ptp_schedule_worker(vclock->clock, PTP_VCLOCK_REFRESH_INTERVAL);
return vclock;
--
2.34.1