phc2sys: Use reversed sysoff when synchronizing to system clock.

If synchronizing a PHC to the system clock, use one of the
PTP_SYS_OFFSET ioctls (if supported) to measure the offset between the
two clocks. Negate the offset and switch the timestamp before passing
them to the servo.

This makes the synchronization between PHC and system clock symmetric.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
master
Miroslav Lichvar 2018-11-12 17:28:02 +01:00 committed by Richard Cochran
parent 68a9011c9d
commit 8142da41b6
1 changed files with 10 additions and 0 deletions

View File

@ -790,6 +790,16 @@ static int do_loop(struct node *node, int subscriptions)
node->phc_readings,
&offset, &ts, &delay) < 0)
return -1;
} else if (node->master->clkid == CLOCK_REALTIME &&
clock->sysoff_method >= 0) {
/* use reversed sysoff */
if (sysoff_measure(CLOCKID_TO_FD(clock->clkid),
clock->sysoff_method,
node->phc_readings,
&offset, &ts, &delay) < 0)
return -1;
ts += offset;
offset = -offset;
} else {
/* use phc */
if (!read_phc(node->master->clkid, clock->clkid,