summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2000-01-04 12:04:39 +0000
committerphk <phk@FreeBSD.org>2000-01-04 12:04:39 +0000
commit325c58929addcc4459a0dbcf440b7619b0234364 (patch)
treec279d408fa7d2fa9c705d9a625f58375623660b5 /sys/kern
parenta8574b388890db2212e4cff87aaf3be885cd83e8 (diff)
downloadFreeBSD-src-325c58929addcc4459a0dbcf440b7619b0234364.zip
FreeBSD-src-325c58929addcc4459a0dbcf440b7619b0234364.tar.gz
Create a separate pps_offset variable to use for applying the
hardpps() produced offset component. This is tested and behaved stable with frequency offsets from -338.05 to +499.91 PPM. Interestingly the machine I tested this on would fail if the clock were slower than 14.3132 MHz whereas it was perfectly happy to run at 16.384 MHz, in other words [-340PPM ... +14.4%] Make pps_shift tweakable with sysctl.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_ntptime.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c
index 36394ee..71b55f4 100644
--- a/sys/kern/kern_ntptime.c
+++ b/sys/kern/kern_ntptime.c
@@ -163,6 +163,7 @@ static l_fp time_freq; /* frequency offset (ns/s) */
#define PPS_POPCORN 2 /* popcorn spike threshold (shift) */
static struct timespec pps_tf[3]; /* phase median filter */
+static l_fp pps_offset; /* time offset (ns) */
static l_fp pps_freq; /* scaled frequency offset (ns/s) */
static long pps_fcount; /* frequency accumulator */
static long pps_jitter; /* nominal jitter (ns) */
@@ -245,6 +246,7 @@ SYSCTL_PROC(_kern_ntp_pll, OID_AUTO, gettime, CTLTYPE_OPAQUE|CTLFLAG_RD,
#ifdef PPS_SYNC
SYSCTL_INT(_kern_ntp_pll, OID_AUTO, pps_shiftmax, CTLFLAG_RW, &pps_shiftmax, 0, "");
+SYSCTL_INT(_kern_ntp_pll, OID_AUTO, pps_shift, CTLFLAG_RW, &pps_shift, 0, "");
#endif
/*
* ntp_adjtime() - NTP daemon application interface
@@ -479,15 +481,19 @@ ntp_update_second(struct timecounter *tcp)
* value is in effect scaled by the clock frequency,
* since the adjustment is added at each tick interrupt.
*/
- time_adj = time_offset;
#ifdef PPS_SYNC
+ /* XXX even if signal dies we should finish adjustment ? */
if (time_status & STA_PPSTIME && time_status & STA_PPSSIGNAL) {
+ time_adj = pps_offset;
L_RSHIFT(time_adj, pps_shift);
+ L_SUB(pps_offset, time_adj);
} else {
+ time_adj = time_offset;
L_RSHIFT(time_adj, SHIFT_PLL + time_constant);
L_SUB(time_offset, time_adj);
}
#else
+ time_adj = time_offset;
L_RSHIFT(time_adj, SHIFT_PLL + time_constant);
L_SUB(time_offset, time_adj);
#endif /* PPS_SYNC */
@@ -731,6 +737,7 @@ hardpps(tsp, nsec)
pps_jitcnt++;
} else if (time_status & STA_PPSTIME) {
L_LINT(time_offset, -v_nsec);
+ L_LINT(pps_offset, -v_nsec);
}
pps_jitter += (u_nsec - pps_jitter) >> PPS_FAVG;
u_sec = pps_tf[0].tv_sec - pps_lastsec;
OpenPOWER on IntegriCloud