Lines Matching +full:clock +full:- +full:duration +full:- +full:ns
1 // SPDX-License-Identifier: GPL-2.0
26 * struct ntp_data - Structure holding all NTP related state
30 * @time_state: State of the clock synchronization
31 * @time_status: Clock status bits
40 * @ntp_tick_adj: Constant boot-param configurable NTP tick adjustment (upscaled)
47 * @pps_shift: PPS current interval duration in seconds (shift value)
49 * @pps_freq: PPS frequency offset in scaled ns/s
50 * @pps_stabil: PPS current stability in scaled ns/s
108 * The following variables are used when a pulse-per-second (PPS) signal
109 * is available. They establish the engineering parameters of the clock
119 #define PPS_MAXWANDER 100000 /* max PPS freq wander (ns/s) */
127 if (ntpdata->time_status & STA_PPSTIME && ntpdata->time_status & STA_PPSSIGNAL) in ntp_offset_chunk()
130 return shift_right(offset, SHIFT_PLL + ntpdata->time_constant); in ntp_offset_chunk()
136 ntpdata->pps_shift = PPS_INTMIN; in pps_reset_freq_interval()
137 ntpdata->pps_intcnt = 0; in pps_reset_freq_interval()
141 * pps_clear - Clears the PPS state variables
147 ntpdata->pps_tf[0] = 0; in pps_clear()
148 ntpdata->pps_tf[1] = 0; in pps_clear()
149 ntpdata->pps_tf[2] = 0; in pps_clear()
150 ntpdata->pps_fbase.tv_sec = ntpdata->pps_fbase.tv_nsec = 0; in pps_clear()
151 ntpdata->pps_freq = 0; in pps_clear()
160 if (ntpdata->pps_valid > 0) { in pps_dec_valid()
161 ntpdata->pps_valid--; in pps_dec_valid()
163 ntpdata->time_status &= ~(STA_PPSSIGNAL | STA_PPSJITTER | in pps_dec_valid()
171 ntpdata->pps_freq = ntpdata->time_freq; in pps_set_freq()
199 txc->ppsfreq = shift_right((ntpdata->pps_freq >> PPM_SCALE_INV_SHIFT) * in pps_fill_timex()
201 txc->jitter = ntpdata->pps_jitter; in pps_fill_timex()
202 if (!(ntpdata->time_status & STA_NANO)) in pps_fill_timex()
203 txc->jitter = ntpdata->pps_jitter / NSEC_PER_USEC; in pps_fill_timex()
204 txc->shift = ntpdata->pps_shift; in pps_fill_timex()
205 txc->stabil = ntpdata->pps_stabil; in pps_fill_timex()
206 txc->jitcnt = ntpdata->pps_jitcnt; in pps_fill_timex()
207 txc->calcnt = ntpdata->pps_calcnt; in pps_fill_timex()
208 txc->errcnt = ntpdata->pps_errcnt; in pps_fill_timex()
209 txc->stbcnt = ntpdata->pps_stbcnt; in pps_fill_timex()
216 return shift_right(offset, SHIFT_PLL + ntpdata->time_constant); in ntp_offset_chunk()
232 txc->ppsfreq = 0; in pps_fill_timex()
233 txc->jitter = 0; in pps_fill_timex()
234 txc->shift = 0; in pps_fill_timex()
235 txc->stabil = 0; in pps_fill_timex()
236 txc->jitcnt = 0; in pps_fill_timex()
237 txc->calcnt = 0; in pps_fill_timex()
238 txc->errcnt = 0; in pps_fill_timex()
239 txc->stbcnt = 0; in pps_fill_timex()
250 u64 second_length, new_base, tick_usec = (u64)ntpdata->tick_usec; in ntp_update_frequency()
254 second_length += ntpdata->ntp_tick_adj; in ntp_update_frequency()
255 second_length += ntpdata->time_freq; in ntp_update_frequency()
263 ntpdata->tick_length += new_base - ntpdata->tick_length_base; in ntp_update_frequency()
264 ntpdata->tick_length_base = new_base; in ntp_update_frequency()
269 ntpdata->time_status &= ~STA_MODE; in ntp_update_offset_fll()
274 if (!(ntpdata->time_status & STA_FLL) && (secs <= MAXSEC)) in ntp_update_offset_fll()
277 ntpdata->time_status |= STA_MODE; in ntp_update_offset_fll()
279 return div64_long(offset64 << (NTP_SCALE_SHIFT - SHIFT_FLL), secs); in ntp_update_offset_fll()
287 if (!(ntpdata->time_status & STA_PLL)) in ntp_update_offset()
290 if (!(ntpdata->time_status & STA_NANO)) { in ntp_update_offset()
292 offset = clamp(offset, -USEC_PER_SEC, USEC_PER_SEC); in ntp_update_offset()
297 offset = clamp(offset, -MAXPHASE, MAXPHASE); in ntp_update_offset()
304 secs = (long)(real_secs - ntpdata->time_reftime); in ntp_update_offset()
305 if (unlikely(ntpdata->time_status & STA_FREQHOLD)) in ntp_update_offset()
308 ntpdata->time_reftime = real_secs; in ntp_update_offset()
318 if (unlikely(secs > 1 << (SHIFT_PLL + 1 + ntpdata->time_constant))) in ntp_update_offset()
319 secs = 1 << (SHIFT_PLL + 1 + ntpdata->time_constant); in ntp_update_offset()
322 (NTP_SCALE_SHIFT - 2 * (SHIFT_PLL + 2 + ntpdata->time_constant)); in ntp_update_offset()
324 freq_adj = min(freq_adj + ntpdata->time_freq, MAXFREQ_SCALED); in ntp_update_offset()
326 ntpdata->time_freq = max(freq_adj, -MAXFREQ_SCALED); in ntp_update_offset()
328 ntpdata->time_offset = div_s64(offset64 << NTP_SCALE_SHIFT, NTP_INTERVAL_FREQ); in ntp_update_offset()
334 ntpdata->time_adjust = 0; in __ntp_clear()
335 ntpdata->time_status |= STA_UNSYNC; in __ntp_clear()
336 ntpdata->time_maxerror = NTP_PHASE_LIMIT; in __ntp_clear()
337 ntpdata->time_esterror = NTP_PHASE_LIMIT; in __ntp_clear()
341 ntpdata->tick_length = ntpdata->tick_length_base; in __ntp_clear()
342 ntpdata->time_offset = 0; in __ntp_clear()
344 ntpdata->ntp_next_leap_sec = TIME64_MAX; in __ntp_clear()
350 * ntp_clear - Clears the NTP state variables
364 * ntp_get_next_leap - Returns the next leapsecond in CLOCK_REALTIME ktime_t
374 if ((ntpdata->time_state == TIME_INS) && (ntpdata->time_status & STA_INS)) in ntp_get_next_leap()
375 return ktime_set(ntpdata->ntp_next_leap_sec, 0); in ntp_get_next_leap()
383 * The tricky bits of code to handle the accurate clock support
398 * Leap second processing. If in leap-insert state at the end of the in second_overflow()
399 * day, the system clock is set back one second; if in leap-delete in second_overflow()
400 * state, the system clock is set ahead one second. in second_overflow()
402 switch (ntpdata->time_state) { in second_overflow()
404 if (ntpdata->time_status & STA_INS) { in second_overflow()
405 ntpdata->time_state = TIME_INS; in second_overflow()
407 ntpdata->ntp_next_leap_sec = secs + SECS_PER_DAY - rem; in second_overflow()
408 } else if (ntpdata->time_status & STA_DEL) { in second_overflow()
409 ntpdata->time_state = TIME_DEL; in second_overflow()
411 ntpdata->ntp_next_leap_sec = secs + SECS_PER_DAY - rem; in second_overflow()
415 if (!(ntpdata->time_status & STA_INS)) { in second_overflow()
416 ntpdata->ntp_next_leap_sec = TIME64_MAX; in second_overflow()
417 ntpdata->time_state = TIME_OK; in second_overflow()
418 } else if (secs == ntpdata->ntp_next_leap_sec) { in second_overflow()
419 leap = -1; in second_overflow()
420 ntpdata->time_state = TIME_OOP; in second_overflow()
421 pr_notice("Clock: inserting leap second 23:59:60 UTC\n"); in second_overflow()
425 if (!(ntpdata->time_status & STA_DEL)) { in second_overflow()
426 ntpdata->ntp_next_leap_sec = TIME64_MAX; in second_overflow()
427 ntpdata->time_state = TIME_OK; in second_overflow()
428 } else if (secs == ntpdata->ntp_next_leap_sec) { in second_overflow()
430 ntpdata->ntp_next_leap_sec = TIME64_MAX; in second_overflow()
431 ntpdata->time_state = TIME_WAIT; in second_overflow()
432 pr_notice("Clock: deleting leap second 23:59:59 UTC\n"); in second_overflow()
436 ntpdata->ntp_next_leap_sec = TIME64_MAX; in second_overflow()
437 ntpdata->time_state = TIME_WAIT; in second_overflow()
440 if (!(ntpdata->time_status & (STA_INS | STA_DEL))) in second_overflow()
441 ntpdata->time_state = TIME_OK; in second_overflow()
446 ntpdata->time_maxerror += MAXFREQ / NSEC_PER_USEC; in second_overflow()
447 if (ntpdata->time_maxerror > NTP_PHASE_LIMIT) { in second_overflow()
448 ntpdata->time_maxerror = NTP_PHASE_LIMIT; in second_overflow()
449 ntpdata->time_status |= STA_UNSYNC; in second_overflow()
453 ntpdata->tick_length = ntpdata->tick_length_base; in second_overflow()
455 delta = ntp_offset_chunk(ntpdata, ntpdata->time_offset); in second_overflow()
456 ntpdata->time_offset -= delta; in second_overflow()
457 ntpdata->tick_length += delta; in second_overflow()
462 if (!ntpdata->time_adjust) in second_overflow()
465 if (ntpdata->time_adjust > MAX_TICKADJ) { in second_overflow()
466 ntpdata->time_adjust -= MAX_TICKADJ; in second_overflow()
467 ntpdata->tick_length += MAX_TICKADJ_SCALED; in second_overflow()
471 if (ntpdata->time_adjust < -MAX_TICKADJ) { in second_overflow()
472 ntpdata->time_adjust += MAX_TICKADJ; in second_overflow()
473 ntpdata->tick_length -= MAX_TICKADJ_SCALED; in second_overflow()
477 ntpdata->tick_length += (s64)(ntpdata->time_adjust * NSEC_PER_USEC / NTP_INTERVAL_FREQ) in second_overflow()
479 ntpdata->time_adjust = 0; in second_overflow()
503 exp = ktime_add_ns(exp, 2ULL * NSEC_PER_SEC - offset_nsec); in sched_sync_hw_clock()
505 exp = ktime_add_ns(exp, SYNC_PERIOD_NS - offset_nsec); in sched_sync_hw_clock()
514 * seconds increment of clock REALTIME.
516 * tsched t1 write(t2.tv_sec - 1sec)) t2 RTC increments seconds
519 * tsched = t2 - set_offset_nsec
520 * newval = t2 - NSEC_PER_SEC
522 * ==> neval = tsched + set_offset_nsec - NSEC_PER_SEC
527 * abs(now - tsched) < FUZZ
535 /* Allowed error in tv_nsec, arbitrarily set to 5 jiffies in ns. */ in rtc_tv_nsec_ok()
537 struct timespec64 delay = {.tv_sec = -1, in rtc_tv_nsec_ok()
542 if (to_set->tv_nsec < TIME_SET_NSEC_FUZZ) { in rtc_tv_nsec_ok()
543 to_set->tv_nsec = 0; in rtc_tv_nsec_ok()
547 if (to_set->tv_nsec > NSEC_PER_SEC - TIME_SET_NSEC_FUZZ) { in rtc_tv_nsec_ok()
548 to_set->tv_sec++; in rtc_tv_nsec_ok()
549 to_set->tv_nsec = 0; in rtc_tv_nsec_ok()
558 return -ENODEV; in update_persistent_clock64()
563 return -ENODEV; in update_persistent_clock64()
573 int err = -ENODEV; in update_rtc()
577 return -ENODEV; in update_rtc()
579 if (!rtc->ops || !rtc->ops->set_time) in update_rtc()
583 if (*offset_nsec == rtc->set_offset_nsec) { in update_rtc()
584 rtc_time64_to_tm(to_set->tv_sec, &tm); in update_rtc()
588 *offset_nsec = rtc->set_offset_nsec; in update_rtc()
589 err = -EAGAIN; in update_rtc()
598 return -ENODEV; in update_rtc()
603 * ntp_synced - Tells whether the NTP status is not UNSYNC
612 * If we have an externally synchronized Linux clock, then update RTC clock
617 * with the kernel clock.
624 * the infamous CMOS clock (MC146818). in sync_hw_clock()
628 int res = -EAGAIN; in sync_hw_clock()
645 to_set.tv_sec -= (sys_tz.tz_minuteswest * 60); in sync_hw_clock()
649 if (res != -ENODEV) in sync_hw_clock()
654 if (res == -ENODEV) in sync_hw_clock()
688 * Propagate a new txc->status value into the NTP state:
692 if ((ntpdata->time_status & STA_PLL) && !(txc->status & STA_PLL)) { in process_adj_status()
693 ntpdata->time_state = TIME_OK; in process_adj_status()
694 ntpdata->time_status = STA_UNSYNC; in process_adj_status()
695 ntpdata->ntp_next_leap_sec = TIME64_MAX; in process_adj_status()
704 if (!(ntpdata->time_status & STA_PLL) && (txc->status & STA_PLL)) in process_adj_status()
705 ntpdata->time_reftime = __ktime_get_real_seconds(); in process_adj_status()
708 ntpdata->time_status &= STA_RONLY; in process_adj_status()
709 ntpdata->time_status |= txc->status & ~STA_RONLY; in process_adj_status()
715 if (txc->modes & ADJ_STATUS) in process_adjtimex_modes()
718 if (txc->modes & ADJ_NANO) in process_adjtimex_modes()
719 ntpdata->time_status |= STA_NANO; in process_adjtimex_modes()
721 if (txc->modes & ADJ_MICRO) in process_adjtimex_modes()
722 ntpdata->time_status &= ~STA_NANO; in process_adjtimex_modes()
724 if (txc->modes & ADJ_FREQUENCY) { in process_adjtimex_modes()
725 ntpdata->time_freq = txc->freq * PPM_SCALE; in process_adjtimex_modes()
726 ntpdata->time_freq = min(ntpdata->time_freq, MAXFREQ_SCALED); in process_adjtimex_modes()
727 ntpdata->time_freq = max(ntpdata->time_freq, -MAXFREQ_SCALED); in process_adjtimex_modes()
732 if (txc->modes & ADJ_MAXERROR) in process_adjtimex_modes()
733 ntpdata->time_maxerror = clamp(txc->maxerror, 0, NTP_PHASE_LIMIT); in process_adjtimex_modes()
735 if (txc->modes & ADJ_ESTERROR) in process_adjtimex_modes()
736 ntpdata->time_esterror = clamp(txc->esterror, 0, NTP_PHASE_LIMIT); in process_adjtimex_modes()
738 if (txc->modes & ADJ_TIMECONST) { in process_adjtimex_modes()
739 ntpdata->time_constant = clamp(txc->constant, 0, MAXTC); in process_adjtimex_modes()
740 if (!(ntpdata->time_status & STA_NANO)) in process_adjtimex_modes()
741 ntpdata->time_constant += 4; in process_adjtimex_modes()
742 ntpdata->time_constant = clamp(ntpdata->time_constant, 0, MAXTC); in process_adjtimex_modes()
745 if (txc->modes & ADJ_TAI && txc->constant >= 0 && txc->constant <= MAX_TAI_OFFSET) in process_adjtimex_modes()
746 *time_tai = txc->constant; in process_adjtimex_modes()
748 if (txc->modes & ADJ_OFFSET) in process_adjtimex_modes()
749 ntp_update_offset(ntpdata, txc->offset); in process_adjtimex_modes()
751 if (txc->modes & ADJ_TICK) in process_adjtimex_modes()
752 ntpdata->tick_usec = txc->tick; in process_adjtimex_modes()
754 if (txc->modes & (ADJ_TICK|ADJ_FREQUENCY|ADJ_OFFSET)) in process_adjtimex_modes()
760 * kernel time-keeping variables. used by xntpd.
768 if (txc->modes & ADJ_ADJTIME) { in __do_adjtimex()
769 long save_adjust = ntpdata->time_adjust; in __do_adjtimex()
771 if (!(txc->modes & ADJ_OFFSET_READONLY)) { in __do_adjtimex()
773 ntpdata->time_adjust = txc->offset; in __do_adjtimex()
777 audit_ntp_set_new(ad, AUDIT_NTP_ADJUST, ntpdata->time_adjust); in __do_adjtimex()
779 txc->offset = save_adjust; in __do_adjtimex()
782 if (txc->modes) { in __do_adjtimex()
783 audit_ntp_set_old(ad, AUDIT_NTP_OFFSET, ntpdata->time_offset); in __do_adjtimex()
784 audit_ntp_set_old(ad, AUDIT_NTP_FREQ, ntpdata->time_freq); in __do_adjtimex()
785 audit_ntp_set_old(ad, AUDIT_NTP_STATUS, ntpdata->time_status); in __do_adjtimex()
787 audit_ntp_set_old(ad, AUDIT_NTP_TICK, ntpdata->tick_usec); in __do_adjtimex()
791 audit_ntp_set_new(ad, AUDIT_NTP_OFFSET, ntpdata->time_offset); in __do_adjtimex()
792 audit_ntp_set_new(ad, AUDIT_NTP_FREQ, ntpdata->time_freq); in __do_adjtimex()
793 audit_ntp_set_new(ad, AUDIT_NTP_STATUS, ntpdata->time_status); in __do_adjtimex()
795 audit_ntp_set_new(ad, AUDIT_NTP_TICK, ntpdata->tick_usec); in __do_adjtimex()
798 txc->offset = shift_right(ntpdata->time_offset * NTP_INTERVAL_FREQ, NTP_SCALE_SHIFT); in __do_adjtimex()
799 if (!(ntpdata->time_status & STA_NANO)) in __do_adjtimex()
800 txc->offset = div_s64(txc->offset, NSEC_PER_USEC); in __do_adjtimex()
803 result = ntpdata->time_state; in __do_adjtimex()
804 if (is_error_status(ntpdata->time_status)) in __do_adjtimex()
807 txc->freq = shift_right((ntpdata->time_freq >> PPM_SCALE_INV_SHIFT) * in __do_adjtimex()
809 txc->maxerror = ntpdata->time_maxerror; in __do_adjtimex()
810 txc->esterror = ntpdata->time_esterror; in __do_adjtimex()
811 txc->status = ntpdata->time_status; in __do_adjtimex()
812 txc->constant = ntpdata->time_constant; in __do_adjtimex()
813 txc->precision = 1; in __do_adjtimex()
814 txc->tolerance = MAXFREQ_SCALED / PPM_SCALE; in __do_adjtimex()
815 txc->tick = ntpdata->tick_usec; in __do_adjtimex()
816 txc->tai = *time_tai; in __do_adjtimex()
821 txc->time.tv_sec = ts->tv_sec; in __do_adjtimex()
822 txc->time.tv_usec = ts->tv_nsec; in __do_adjtimex()
823 if (!(ntpdata->time_status & STA_NANO)) in __do_adjtimex()
824 txc->time.tv_usec = ts->tv_nsec / NSEC_PER_USEC; in __do_adjtimex()
827 if (unlikely(ts->tv_sec >= ntpdata->ntp_next_leap_sec)) { in __do_adjtimex()
828 if ((ntpdata->time_state == TIME_INS) && (ntpdata->time_status & STA_INS)) { in __do_adjtimex()
830 txc->tai++; in __do_adjtimex()
831 txc->time.tv_sec--; in __do_adjtimex()
833 if ((ntpdata->time_state == TIME_DEL) && (ntpdata->time_status & STA_DEL)) { in __do_adjtimex()
835 txc->tai--; in __do_adjtimex()
836 txc->time.tv_sec++; in __do_adjtimex()
838 if ((ntpdata->time_state == TIME_OOP) && (ts->tv_sec == ntpdata->ntp_next_leap_sec)) in __do_adjtimex()
850 * pps_normtime.nsec has a range of ( -NSEC_PER_SEC / 2, NSEC_PER_SEC / 2 ]
860 * [ -NSEC_PER_SEC / 2, NSEC_PER_SEC / 2 ] interval
870 norm.nsec -= NSEC_PER_SEC; in pps_normalize_ts()
880 *jitter = ntpdata->pps_tf[0] - ntpdata->pps_tf[1]; in pps_phase_filter_get()
882 *jitter = -*jitter; in pps_phase_filter_get()
885 return ntpdata->pps_tf[0]; in pps_phase_filter_get()
891 ntpdata->pps_tf[2] = ntpdata->pps_tf[1]; in pps_phase_filter_add()
892 ntpdata->pps_tf[1] = ntpdata->pps_tf[0]; in pps_phase_filter_add()
893 ntpdata->pps_tf[0] = err; in pps_phase_filter_add()
902 if (--ntpdata->pps_intcnt <= -PPS_INTCOUNT) { in pps_dec_freq_interval()
903 ntpdata->pps_intcnt = -PPS_INTCOUNT; in pps_dec_freq_interval()
904 if (ntpdata->pps_shift > PPS_INTMIN) { in pps_dec_freq_interval()
905 ntpdata->pps_shift--; in pps_dec_freq_interval()
906 ntpdata->pps_intcnt = 0; in pps_dec_freq_interval()
917 if (++ntpdata->pps_intcnt >= PPS_INTCOUNT) { in pps_inc_freq_interval()
918 ntpdata->pps_intcnt = PPS_INTCOUNT; in pps_inc_freq_interval()
919 if (ntpdata->pps_shift < PPS_INTMAX) { in pps_inc_freq_interval()
920 ntpdata->pps_shift++; in pps_inc_freq_interval()
921 ntpdata->pps_intcnt = 0; in pps_inc_freq_interval()
927 * Update clock frequency based on MONOTONIC_RAW clock PPS signal
931 * first and last MONOTONIC_RAW clock timestamps divided by the length
942 if (freq_norm.sec > (2 << ntpdata->pps_shift)) { in hardpps_update_freq()
943 ntpdata->time_status |= STA_PPSERROR; in hardpps_update_freq()
944 ntpdata->pps_errcnt++; in hardpps_update_freq()
946 printk_deferred(KERN_ERR "hardpps: PPSERROR: interval too long - %lld s\n", in hardpps_update_freq()
956 ftemp = div_s64(((s64)(-freq_norm.nsec)) << NTP_SCALE_SHIFT, in hardpps_update_freq()
958 delta = shift_right(ftemp - ntpdata->pps_freq, NTP_SCALE_SHIFT); in hardpps_update_freq()
959 ntpdata->pps_freq = ftemp; in hardpps_update_freq()
960 if (delta > PPS_MAXWANDER || delta < -PPS_MAXWANDER) { in hardpps_update_freq()
962 ntpdata->time_status |= STA_PPSWANDER; in hardpps_update_freq()
963 ntpdata->pps_stbcnt++; in hardpps_update_freq()
976 delta_mod = -delta_mod; in hardpps_update_freq()
977 ntpdata->pps_stabil += (div_s64(((s64)delta_mod) << (NTP_SCALE_SHIFT - SHIFT_USEC), in hardpps_update_freq()
978 NSEC_PER_USEC) - ntpdata->pps_stabil) >> PPS_INTMIN; in hardpps_update_freq()
980 /* If enabled, the system clock frequency is updated */ in hardpps_update_freq()
981 if ((ntpdata->time_status & STA_PPSFREQ) && !(ntpdata->time_status & STA_FREQHOLD)) { in hardpps_update_freq()
982 ntpdata->time_freq = ntpdata->pps_freq; in hardpps_update_freq()
989 /* Correct REALTIME clock phase error against PPS signal */
992 long correction = -error; in hardpps_update_phase()
1004 if (jitter > (ntpdata->pps_jitter << PPS_POPCORN)) { in hardpps_update_phase()
1006 jitter, (ntpdata->pps_jitter << PPS_POPCORN)); in hardpps_update_phase()
1007 ntpdata->time_status |= STA_PPSJITTER; in hardpps_update_phase()
1008 ntpdata->pps_jitcnt++; in hardpps_update_phase()
1009 } else if (ntpdata->time_status & STA_PPSTIME) { in hardpps_update_phase()
1011 ntpdata->time_offset = div_s64(((s64)correction) << NTP_SCALE_SHIFT, in hardpps_update_phase()
1014 ntpdata->time_adjust = 0; in hardpps_update_phase()
1017 ntpdata->pps_jitter += (jitter - ntpdata->pps_jitter) >> PPS_INTMIN; in hardpps_update_phase()
1021 * __hardpps() - discipline CPU clock oscillator to external PPS signal
1024 * discipline the CPU clock oscillator to the PPS signal. It takes two
1025 * parameters: REALTIME and MONOTONIC_RAW clock timestamps. The former
1026 * is used to correct clock phase error and the latter is used to
1040 ntpdata->time_status &= ~(STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR); in __hardpps()
1043 ntpdata->time_status |= STA_PPSSIGNAL; in __hardpps()
1044 ntpdata->pps_valid = PPS_VALID; in __hardpps()
1050 if (unlikely(ntpdata->pps_fbase.tv_sec == 0)) { in __hardpps()
1051 ntpdata->pps_fbase = *raw_ts; in __hardpps()
1056 freq_norm = pps_normalize_ts(timespec64_sub(*raw_ts, ntpdata->pps_fbase)); in __hardpps()
1060 * [1s - MAXFREQ us, 1s + MAXFREQ us], otherwise reject it in __hardpps()
1063 (freq_norm.nsec < -MAXFREQ * freq_norm.sec)) { in __hardpps()
1064 ntpdata->time_status |= STA_PPSJITTER; in __hardpps()
1066 ntpdata->pps_fbase = *raw_ts; in __hardpps()
1072 if (freq_norm.sec >= (1 << ntpdata->pps_shift)) { in __hardpps()
1073 ntpdata->pps_calcnt++; in __hardpps()
1075 ntpdata->pps_fbase = *raw_ts; in __hardpps()