diff options
-rw-r--r-- | sys/kern/kern_ntptime.c | 12 | ||||
-rw-r--r-- | sys/kern/kern_tc.c | 16 |
2 files changed, 9 insertions, 19 deletions
diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c index b632cecdfadb..815a26182096 100644 --- a/sys/kern/kern_ntptime.c +++ b/sys/kern/kern_ntptime.c @@ -771,16 +771,10 @@ hardpps(struct timespec *tsp, long delta_nsec) pps_tf[0].tv_nsec = u_nsec; /* - * Compute the difference between the current and previous - * counter values. If the difference exceeds 0.5 s, assume it - * has wrapped around, so correct 1.0 s. + * Update the frequency accumulator using the difference between the + * current and previous PPS event measured directly by the timecounter. */ - u_nsec = delta_nsec; - if (u_nsec > (NANOSECOND >> 1)) - u_nsec -= NANOSECOND; - else if (u_nsec < -(NANOSECOND >> 1)) - u_nsec += NANOSECOND; - pps_fcount += u_nsec; + pps_fcount += delta_nsec - NANOSECOND; if (v_nsec > MAXFREQ || v_nsec < -MAXFREQ) goto out; time_status &= ~STA_PPSJITTER; diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index be564e4347f8..0dc233896baa 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -1781,7 +1781,7 @@ pps_event(struct pps_state *pps, int event) struct timecounter *captc; uint64_t capth_scale; struct bintime bt; - struct timespec ts, *tsp, *osp; + struct timespec *tsp, *osp; u_int tcount, *pcount; int foff; pps_seq_t *pseq; @@ -1881,7 +1881,7 @@ pps_event(struct pps_state *pps, int event) #ifdef PPS_SYNC if (fhard) { - uint64_t scale; + uint64_t delta_nsec; /* * Feed the NTP PLL/FLL. @@ -1891,14 +1891,10 @@ pps_event(struct pps_state *pps, int event) tcount = pps->capcount - pps->ppscount[2]; pps->ppscount[2] = pps->capcount; tcount &= captc->tc_counter_mask; - scale = (uint64_t)1 << 63; - scale /= captc->tc_frequency; - scale *= 2; - bt.sec = 0; - bt.frac = 0; - bintime_addx(&bt, scale * tcount); - bintime2timespec(&bt, &ts); - hardpps(tsp, ts.tv_nsec + 1000000000 * ts.tv_sec); + delta_nsec = 1000000000; + delta_nsec *= tcount; + delta_nsec /= captc->tc_frequency; + hardpps(tsp, (long)delta_nsec); } #endif |