Lines Matching refs:tk

115 static inline void tk_normalize_xtime(struct timekeeper *tk)  in tk_normalize_xtime()  argument
117 while (tk->tkr_mono.xtime_nsec >= ((u64)NSEC_PER_SEC << tk->tkr_mono.shift)) { in tk_normalize_xtime()
118 tk->tkr_mono.xtime_nsec -= (u64)NSEC_PER_SEC << tk->tkr_mono.shift; in tk_normalize_xtime()
119 tk->xtime_sec++; in tk_normalize_xtime()
121 while (tk->tkr_raw.xtime_nsec >= ((u64)NSEC_PER_SEC << tk->tkr_raw.shift)) { in tk_normalize_xtime()
122 tk->tkr_raw.xtime_nsec -= (u64)NSEC_PER_SEC << tk->tkr_raw.shift; in tk_normalize_xtime()
123 tk->raw_sec++; in tk_normalize_xtime()
127 static inline struct timespec64 tk_xtime(const struct timekeeper *tk) in tk_xtime() argument
131 ts.tv_sec = tk->xtime_sec; in tk_xtime()
132 ts.tv_nsec = (long)(tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift); in tk_xtime()
136 static void tk_set_xtime(struct timekeeper *tk, const struct timespec64 *ts) in tk_set_xtime() argument
138 tk->xtime_sec = ts->tv_sec; in tk_set_xtime()
139 tk->tkr_mono.xtime_nsec = (u64)ts->tv_nsec << tk->tkr_mono.shift; in tk_set_xtime()
142 static void tk_xtime_add(struct timekeeper *tk, const struct timespec64 *ts) in tk_xtime_add() argument
144 tk->xtime_sec += ts->tv_sec; in tk_xtime_add()
145 tk->tkr_mono.xtime_nsec += (u64)ts->tv_nsec << tk->tkr_mono.shift; in tk_xtime_add()
146 tk_normalize_xtime(tk); in tk_xtime_add()
149 static void tk_set_wall_to_mono(struct timekeeper *tk, struct timespec64 wtm) in tk_set_wall_to_mono() argument
157 set_normalized_timespec64(&tmp, -tk->wall_to_monotonic.tv_sec, in tk_set_wall_to_mono()
158 -tk->wall_to_monotonic.tv_nsec); in tk_set_wall_to_mono()
159 WARN_ON_ONCE(tk->offs_real != timespec64_to_ktime(tmp)); in tk_set_wall_to_mono()
160 tk->wall_to_monotonic = wtm; in tk_set_wall_to_mono()
162 tk->offs_real = timespec64_to_ktime(tmp); in tk_set_wall_to_mono()
163 tk->offs_tai = ktime_add(tk->offs_real, ktime_set(tk->tai_offset, 0)); in tk_set_wall_to_mono()
166 static inline void tk_update_sleep_time(struct timekeeper *tk, ktime_t delta) in tk_update_sleep_time() argument
168 tk->offs_boot = ktime_add(tk->offs_boot, delta); in tk_update_sleep_time()
173 tk->monotonic_to_boot = ktime_to_timespec64(tk->offs_boot); in tk_update_sleep_time()
199 static void timekeeping_check_update(struct timekeeper *tk, u64 offset) in timekeeping_check_update() argument
202 u64 max_cycles = tk->tkr_mono.clock->max_cycles; in timekeeping_check_update()
203 const char *name = tk->tkr_mono.clock->name; in timekeeping_check_update()
217 if (tk->underflow_seen) { in timekeeping_check_update()
218 if (jiffies - tk->last_warning > WARNING_FREQ) { in timekeeping_check_update()
222 tk->last_warning = jiffies; in timekeeping_check_update()
224 tk->underflow_seen = 0; in timekeeping_check_update()
227 if (tk->overflow_seen) { in timekeeping_check_update()
228 if (jiffies - tk->last_warning > WARNING_FREQ) { in timekeeping_check_update()
232 tk->last_warning = jiffies; in timekeeping_check_update()
234 tk->overflow_seen = 0; in timekeeping_check_update()
240 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_get_delta() local
266 tk->underflow_seen = 1; in timekeeping_get_delta()
272 tk->overflow_seen = 1; in timekeeping_get_delta()
279 static inline void timekeeping_check_update(struct timekeeper *tk, u64 offset) in timekeeping_check_update() argument
307 static void tk_setup_internals(struct timekeeper *tk, struct clocksource *clock) in tk_setup_internals() argument
313 ++tk->cs_was_changed_seq; in tk_setup_internals()
314 old_clock = tk->tkr_mono.clock; in tk_setup_internals()
315 tk->tkr_mono.clock = clock; in tk_setup_internals()
316 tk->tkr_mono.mask = clock->mask; in tk_setup_internals()
317 tk->tkr_mono.cycle_last = tk_clock_read(&tk->tkr_mono); in tk_setup_internals()
319 tk->tkr_raw.clock = clock; in tk_setup_internals()
320 tk->tkr_raw.mask = clock->mask; in tk_setup_internals()
321 tk->tkr_raw.cycle_last = tk->tkr_mono.cycle_last; in tk_setup_internals()
333 tk->cycle_interval = interval; in tk_setup_internals()
336 tk->xtime_interval = interval * clock->mult; in tk_setup_internals()
337 tk->xtime_remainder = ntpinterval - tk->xtime_interval; in tk_setup_internals()
338 tk->raw_interval = interval * clock->mult; in tk_setup_internals()
344 tk->tkr_mono.xtime_nsec >>= -shift_change; in tk_setup_internals()
345 tk->tkr_raw.xtime_nsec >>= -shift_change; in tk_setup_internals()
347 tk->tkr_mono.xtime_nsec <<= shift_change; in tk_setup_internals()
348 tk->tkr_raw.xtime_nsec <<= shift_change; in tk_setup_internals()
352 tk->tkr_mono.shift = clock->shift; in tk_setup_internals()
353 tk->tkr_raw.shift = clock->shift; in tk_setup_internals()
355 tk->ntp_error = 0; in tk_setup_internals()
356 tk->ntp_error_shift = NTP_SCALE_SHIFT - clock->shift; in tk_setup_internals()
357 tk->ntp_tick = ntpinterval << tk->ntp_error_shift; in tk_setup_internals()
364 tk->tkr_mono.mult = clock->mult; in tk_setup_internals()
365 tk->tkr_raw.mult = clock->mult; in tk_setup_internals()
366 tk->ntp_err_mult = 0; in tk_setup_internals()
367 tk->skip_second_overflow = 0; in tk_setup_internals()
527 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_boot_fast_ns() local
529 return (ktime_get_mono_fast_ns() + ktime_to_ns(tk->offs_boot)); in ktime_get_boot_fast_ns()
615 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_fast_timestamps() local
618 snapshot->boot = snapshot->mono + ktime_to_ns(data_race(tk->offs_boot)); in ktime_get_fast_timestamps()
631 static void halt_fast_timekeeper(const struct timekeeper *tk) in halt_fast_timekeeper() argument
634 const struct tk_read_base *tkr = &tk->tkr_mono; in halt_fast_timekeeper()
639 tkr_dummy.base_real = tkr->base + tk->offs_real; in halt_fast_timekeeper()
642 tkr = &tk->tkr_raw; in halt_fast_timekeeper()
650 static void update_pvclock_gtod(struct timekeeper *tk, bool was_set) in update_pvclock_gtod() argument
652 raw_notifier_call_chain(&pvclock_gtod_chain, was_set, tk); in update_pvclock_gtod()
660 struct timekeeper *tk = &tk_core.timekeeper; in pvclock_gtod_register_notifier() local
666 update_pvclock_gtod(tk, true); in pvclock_gtod_register_notifier()
693 static inline void tk_update_leap_state(struct timekeeper *tk) in tk_update_leap_state() argument
695 tk->next_leap_ktime = ntp_get_next_leap(); in tk_update_leap_state()
696 if (tk->next_leap_ktime != KTIME_MAX) in tk_update_leap_state()
698 tk->next_leap_ktime = ktime_sub(tk->next_leap_ktime, tk->offs_real); in tk_update_leap_state()
704 static inline void tk_update_ktime_data(struct timekeeper *tk) in tk_update_ktime_data() argument
716 seconds = (u64)(tk->xtime_sec + tk->wall_to_monotonic.tv_sec); in tk_update_ktime_data()
717 nsec = (u32) tk->wall_to_monotonic.tv_nsec; in tk_update_ktime_data()
718 tk->tkr_mono.base = ns_to_ktime(seconds * NSEC_PER_SEC + nsec); in tk_update_ktime_data()
725 nsec += (u32)(tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift); in tk_update_ktime_data()
728 tk->ktime_sec = seconds; in tk_update_ktime_data()
731 tk->tkr_raw.base = ns_to_ktime(tk->raw_sec * NSEC_PER_SEC); in tk_update_ktime_data()
735 static void timekeeping_update(struct timekeeper *tk, unsigned int action) in timekeeping_update() argument
738 tk->ntp_error = 0; in timekeeping_update()
742 tk_update_leap_state(tk); in timekeeping_update()
743 tk_update_ktime_data(tk); in timekeeping_update()
745 update_vsyscall(tk); in timekeeping_update()
746 update_pvclock_gtod(tk, action & TK_CLOCK_WAS_SET); in timekeeping_update()
748 tk->tkr_mono.base_real = tk->tkr_mono.base + tk->offs_real; in timekeeping_update()
749 update_fast_timekeeper(&tk->tkr_mono, &tk_fast_mono); in timekeeping_update()
750 update_fast_timekeeper(&tk->tkr_raw, &tk_fast_raw); in timekeeping_update()
753 tk->clock_was_set_seq++; in timekeeping_update()
771 static void timekeeping_forward_now(struct timekeeper *tk) in timekeeping_forward_now() argument
775 cycle_now = tk_clock_read(&tk->tkr_mono); in timekeeping_forward_now()
776 delta = clocksource_delta(cycle_now, tk->tkr_mono.cycle_last, tk->tkr_mono.mask); in timekeeping_forward_now()
777 tk->tkr_mono.cycle_last = cycle_now; in timekeeping_forward_now()
778 tk->tkr_raw.cycle_last = cycle_now; in timekeeping_forward_now()
780 tk->tkr_mono.xtime_nsec += delta * tk->tkr_mono.mult; in timekeeping_forward_now()
783 tk->tkr_mono.xtime_nsec += (u64)arch_gettimeoffset() << tk->tkr_mono.shift; in timekeeping_forward_now()
786 tk->tkr_raw.xtime_nsec += delta * tk->tkr_raw.mult; in timekeeping_forward_now()
789 tk->tkr_raw.xtime_nsec += (u64)arch_gettimeoffset() << tk->tkr_raw.shift; in timekeeping_forward_now()
791 tk_normalize_xtime(tk); in timekeeping_forward_now()
802 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_real_ts64() local
811 ts->tv_sec = tk->xtime_sec; in ktime_get_real_ts64()
812 nsecs = timekeeping_get_ns(&tk->tkr_mono); in ktime_get_real_ts64()
823 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get() local
832 base = tk->tkr_mono.base; in ktime_get()
833 nsecs = timekeeping_get_ns(&tk->tkr_mono); in ktime_get()
843 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_resolution_ns() local
851 nsecs = tk->tkr_mono.mult >> tk->tkr_mono.shift; in ktime_get_resolution_ns()
866 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_with_offset() local
875 base = ktime_add(tk->tkr_mono.base, *offset); in ktime_get_with_offset()
876 nsecs = timekeeping_get_ns(&tk->tkr_mono); in ktime_get_with_offset()
887 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_coarse_with_offset() local
896 base = ktime_add(tk->tkr_mono.base, *offset); in ktime_get_coarse_with_offset()
897 nsecs = tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift; in ktime_get_coarse_with_offset()
930 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_raw() local
937 base = tk->tkr_raw.base; in ktime_get_raw()
938 nsecs = timekeeping_get_ns(&tk->tkr_raw); in ktime_get_raw()
956 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_ts64() local
965 ts->tv_sec = tk->xtime_sec; in ktime_get_ts64()
966 nsec = timekeeping_get_ns(&tk->tkr_mono); in ktime_get_ts64()
967 tomono = tk->wall_to_monotonic; in ktime_get_ts64()
988 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_seconds() local
991 return tk->ktime_sec; in ktime_get_seconds()
1008 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_real_seconds() local
1013 return tk->xtime_sec; in ktime_get_real_seconds()
1017 seconds = tk->xtime_sec; in ktime_get_real_seconds()
1032 struct timekeeper *tk = &tk_core.timekeeper; in __ktime_get_real_seconds() local
1034 return tk->xtime_sec; in __ktime_get_real_seconds()
1043 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_snapshot() local
1055 now = tk_clock_read(&tk->tkr_mono); in ktime_get_snapshot()
1056 systime_snapshot->cs_was_changed_seq = tk->cs_was_changed_seq; in ktime_get_snapshot()
1057 systime_snapshot->clock_was_set_seq = tk->clock_was_set_seq; in ktime_get_snapshot()
1058 base_real = ktime_add(tk->tkr_mono.base, in ktime_get_snapshot()
1060 base_raw = tk->tkr_raw.base; in ktime_get_snapshot()
1061 nsec_real = timekeeping_cycles_to_ns(&tk->tkr_mono, now); in ktime_get_snapshot()
1062 nsec_raw = timekeeping_cycles_to_ns(&tk->tkr_raw, now); in ktime_get_snapshot()
1111 struct timekeeper *tk = &tk_core.timekeeper; in adjust_historical_crosststamp() local
1145 (corr_raw, tk->tkr_mono.mult, tk->tkr_raw.mult); in adjust_historical_crosststamp()
1199 struct timekeeper *tk = &tk_core.timekeeper; in get_device_system_crosststamp() local
1224 if (tk->tkr_mono.clock != system_counterval.cs) in get_device_system_crosststamp()
1232 now = tk_clock_read(&tk->tkr_mono); in get_device_system_crosststamp()
1233 interval_start = tk->tkr_mono.cycle_last; in get_device_system_crosststamp()
1235 clock_was_set_seq = tk->clock_was_set_seq; in get_device_system_crosststamp()
1236 cs_was_changed_seq = tk->cs_was_changed_seq; in get_device_system_crosststamp()
1243 base_real = ktime_add(tk->tkr_mono.base, in get_device_system_crosststamp()
1245 base_raw = tk->tkr_raw.base; in get_device_system_crosststamp()
1247 nsec_real = timekeeping_cycles_to_ns(&tk->tkr_mono, in get_device_system_crosststamp()
1249 nsec_raw = timekeeping_cycles_to_ns(&tk->tkr_raw, in get_device_system_crosststamp()
1299 struct timekeeper *tk = &tk_core.timekeeper; in do_settimeofday64() local
1310 timekeeping_forward_now(tk); in do_settimeofday64()
1312 xt = tk_xtime(tk); in do_settimeofday64()
1316 if (timespec64_compare(&tk->wall_to_monotonic, &ts_delta) > 0) { in do_settimeofday64()
1321 tk_set_wall_to_mono(tk, timespec64_sub(tk->wall_to_monotonic, ts_delta)); in do_settimeofday64()
1323 tk_set_xtime(tk, ts); in do_settimeofday64()
1325 timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); in do_settimeofday64()
1348 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_inject_offset() local
1359 timekeeping_forward_now(tk); in timekeeping_inject_offset()
1362 tmp = timespec64_add(tk_xtime(tk), *ts); in timekeeping_inject_offset()
1363 if (timespec64_compare(&tk->wall_to_monotonic, ts) > 0 || in timekeeping_inject_offset()
1369 tk_xtime_add(tk, ts); in timekeeping_inject_offset()
1370 tk_set_wall_to_mono(tk, timespec64_sub(tk->wall_to_monotonic, *ts)); in timekeeping_inject_offset()
1373 timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); in timekeeping_inject_offset()
1422 static void __timekeeping_set_tai_offset(struct timekeeper *tk, s32 tai_offset) in __timekeeping_set_tai_offset() argument
1424 tk->tai_offset = tai_offset; in __timekeeping_set_tai_offset()
1425 tk->offs_tai = ktime_add(tk->offs_real, ktime_set(tai_offset, 0)); in __timekeeping_set_tai_offset()
1435 struct timekeeper *tk = &tk_core.timekeeper; in change_clocksource() local
1444 timekeeping_forward_now(tk); in change_clocksource()
1451 old = tk->tkr_mono.clock; in change_clocksource()
1452 tk_setup_internals(tk, new); in change_clocksource()
1460 timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); in change_clocksource()
1477 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_notify() local
1479 if (tk->tkr_mono.clock == clock) in timekeeping_notify()
1483 return tk->tkr_mono.clock == clock ? 0 : -1; in timekeeping_notify()
1494 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_raw_ts64() local
1500 ts->tv_sec = tk->raw_sec; in ktime_get_raw_ts64()
1501 nsecs = timekeeping_get_ns(&tk->tkr_raw); in ktime_get_raw_ts64()
1516 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_valid_for_hres() local
1523 ret = tk->tkr_mono.clock->flags & CLOCK_SOURCE_VALID_FOR_HRES; in timekeeping_valid_for_hres()
1535 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_max_deferment() local
1542 ret = tk->tkr_mono.clock->max_idle_ns; in timekeeping_max_deferment()
1608 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_init() local
1637 tk_setup_internals(tk, clock); in timekeeping_init()
1639 tk_set_xtime(tk, &wall_time); in timekeeping_init()
1640 tk->raw_sec = 0; in timekeeping_init()
1642 tk_set_wall_to_mono(tk, wall_to_mono); in timekeeping_init()
1644 timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); in timekeeping_init()
1660 static void __timekeeping_inject_sleeptime(struct timekeeper *tk, in __timekeeping_inject_sleeptime() argument
1669 tk_xtime_add(tk, delta); in __timekeeping_inject_sleeptime()
1670 tk_set_wall_to_mono(tk, timespec64_sub(tk->wall_to_monotonic, *delta)); in __timekeeping_inject_sleeptime()
1671 tk_update_sleep_time(tk, timespec64_to_ktime(*delta)); in __timekeeping_inject_sleeptime()
1724 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_inject_sleeptime64() local
1732 timekeeping_forward_now(tk); in timekeeping_inject_sleeptime64()
1734 __timekeeping_inject_sleeptime(tk, delta); in timekeeping_inject_sleeptime64()
1736 timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); in timekeeping_inject_sleeptime64()
1751 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_resume() local
1752 struct clocksource *clock = tk->tkr_mono.clock; in timekeeping_resume()
1778 cycle_now = tk_clock_read(&tk->tkr_mono); in timekeeping_resume()
1790 __timekeeping_inject_sleeptime(tk, &ts_delta); in timekeeping_resume()
1794 tk->tkr_mono.cycle_last = cycle_now; in timekeeping_resume()
1795 tk->tkr_raw.cycle_last = cycle_now; in timekeeping_resume()
1797 tk->ntp_error = 0; in timekeeping_resume()
1799 timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); in timekeeping_resume()
1811 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_suspend() local
1832 timekeeping_forward_now(tk); in timekeeping_suspend()
1840 curr_clock = tk->tkr_mono.clock; in timekeeping_suspend()
1841 cycle_now = tk->tkr_mono.cycle_last; in timekeeping_suspend()
1851 delta = timespec64_sub(tk_xtime(tk), timekeeping_suspend_time); in timekeeping_suspend()
1866 timekeeping_update(tk, TK_MIRROR); in timekeeping_suspend()
1867 halt_fast_timekeeper(tk); in timekeeping_suspend()
1894 static __always_inline void timekeeping_apply_adjustment(struct timekeeper *tk, in timekeeping_apply_adjustment() argument
1898 s64 interval = tk->cycle_interval; in timekeeping_apply_adjustment()
1957 if ((mult_adj > 0) && (tk->tkr_mono.mult + mult_adj < mult_adj)) { in timekeeping_apply_adjustment()
1963 tk->tkr_mono.mult += mult_adj; in timekeeping_apply_adjustment()
1964 tk->xtime_interval += interval; in timekeeping_apply_adjustment()
1965 tk->tkr_mono.xtime_nsec -= offset; in timekeeping_apply_adjustment()
1972 static void timekeeping_adjust(struct timekeeper *tk, s64 offset) in timekeeping_adjust() argument
1980 if (likely(tk->ntp_tick == ntp_tick_length())) { in timekeeping_adjust()
1981 mult = tk->tkr_mono.mult - tk->ntp_err_mult; in timekeeping_adjust()
1983 tk->ntp_tick = ntp_tick_length(); in timekeeping_adjust()
1984 mult = div64_u64((tk->ntp_tick >> tk->ntp_error_shift) - in timekeeping_adjust()
1985 tk->xtime_remainder, tk->cycle_interval); in timekeeping_adjust()
1994 tk->ntp_err_mult = tk->ntp_error > 0 ? 1 : 0; in timekeeping_adjust()
1995 mult += tk->ntp_err_mult; in timekeeping_adjust()
1997 timekeeping_apply_adjustment(tk, offset, mult - tk->tkr_mono.mult); in timekeeping_adjust()
1999 if (unlikely(tk->tkr_mono.clock->maxadj && in timekeeping_adjust()
2000 (abs(tk->tkr_mono.mult - tk->tkr_mono.clock->mult) in timekeeping_adjust()
2001 > tk->tkr_mono.clock->maxadj))) { in timekeeping_adjust()
2004 tk->tkr_mono.clock->name, (long)tk->tkr_mono.mult, in timekeeping_adjust()
2005 (long)tk->tkr_mono.clock->mult + tk->tkr_mono.clock->maxadj); in timekeeping_adjust()
2018 if (unlikely((s64)tk->tkr_mono.xtime_nsec < 0)) { in timekeeping_adjust()
2019 tk->tkr_mono.xtime_nsec += (u64)NSEC_PER_SEC << in timekeeping_adjust()
2020 tk->tkr_mono.shift; in timekeeping_adjust()
2021 tk->xtime_sec--; in timekeeping_adjust()
2022 tk->skip_second_overflow = 1; in timekeeping_adjust()
2034 static inline unsigned int accumulate_nsecs_to_secs(struct timekeeper *tk) in accumulate_nsecs_to_secs() argument
2036 u64 nsecps = (u64)NSEC_PER_SEC << tk->tkr_mono.shift; in accumulate_nsecs_to_secs()
2039 while (tk->tkr_mono.xtime_nsec >= nsecps) { in accumulate_nsecs_to_secs()
2042 tk->tkr_mono.xtime_nsec -= nsecps; in accumulate_nsecs_to_secs()
2043 tk->xtime_sec++; in accumulate_nsecs_to_secs()
2049 if (unlikely(tk->skip_second_overflow)) { in accumulate_nsecs_to_secs()
2050 tk->skip_second_overflow = 0; in accumulate_nsecs_to_secs()
2055 leap = second_overflow(tk->xtime_sec); in accumulate_nsecs_to_secs()
2059 tk->xtime_sec += leap; in accumulate_nsecs_to_secs()
2063 tk_set_wall_to_mono(tk, in accumulate_nsecs_to_secs()
2064 timespec64_sub(tk->wall_to_monotonic, ts)); in accumulate_nsecs_to_secs()
2066 __timekeeping_set_tai_offset(tk, tk->tai_offset - leap); in accumulate_nsecs_to_secs()
2083 static u64 logarithmic_accumulation(struct timekeeper *tk, u64 offset, in logarithmic_accumulation() argument
2086 u64 interval = tk->cycle_interval << shift; in logarithmic_accumulation()
2095 tk->tkr_mono.cycle_last += interval; in logarithmic_accumulation()
2096 tk->tkr_raw.cycle_last += interval; in logarithmic_accumulation()
2098 tk->tkr_mono.xtime_nsec += tk->xtime_interval << shift; in logarithmic_accumulation()
2099 *clock_set |= accumulate_nsecs_to_secs(tk); in logarithmic_accumulation()
2102 tk->tkr_raw.xtime_nsec += tk->raw_interval << shift; in logarithmic_accumulation()
2103 snsec_per_sec = (u64)NSEC_PER_SEC << tk->tkr_raw.shift; in logarithmic_accumulation()
2104 while (tk->tkr_raw.xtime_nsec >= snsec_per_sec) { in logarithmic_accumulation()
2105 tk->tkr_raw.xtime_nsec -= snsec_per_sec; in logarithmic_accumulation()
2106 tk->raw_sec++; in logarithmic_accumulation()
2110 tk->ntp_error += tk->ntp_tick << shift; in logarithmic_accumulation()
2111 tk->ntp_error -= (tk->xtime_interval + tk->xtime_remainder) << in logarithmic_accumulation()
2112 (tk->ntp_error_shift + shift); in logarithmic_accumulation()
2124 struct timekeeper *tk = &shadow_timekeeper; in timekeeping_advance() local
2142 offset = clocksource_delta(tk_clock_read(&tk->tkr_mono), in timekeeping_advance()
2143 tk->tkr_mono.cycle_last, tk->tkr_mono.mask); in timekeeping_advance()
2151 timekeeping_check_update(tk, offset); in timekeeping_advance()
2161 shift = ilog2(offset) - ilog2(tk->cycle_interval); in timekeeping_advance()
2166 while (offset >= tk->cycle_interval) { in timekeeping_advance()
2167 offset = logarithmic_accumulation(tk, offset, shift, in timekeeping_advance()
2169 if (offset < tk->cycle_interval<<shift) in timekeeping_advance()
2174 timekeeping_adjust(tk, offset); in timekeeping_advance()
2180 clock_set |= accumulate_nsecs_to_secs(tk); in timekeeping_advance()
2193 timekeeping_update(tk, clock_set); in timekeeping_advance()
2194 memcpy(real_tk, tk, sizeof(*tk)); in timekeeping_advance()
2226 struct timekeeper *tk = &tk_core.timekeeper; in getboottime64() local
2227 ktime_t t = ktime_sub(tk->offs_real, tk->offs_boot); in getboottime64()
2235 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_coarse_real_ts64() local
2241 *ts = tk_xtime(tk); in ktime_get_coarse_real_ts64()
2248 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_coarse_ts64() local
2255 now = tk_xtime(tk); in ktime_get_coarse_ts64()
2256 mono = tk->wall_to_monotonic; in ktime_get_coarse_ts64()
2289 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_update_offsets_now() local
2297 base = tk->tkr_mono.base; in ktime_get_update_offsets_now()
2298 nsecs = timekeeping_get_ns(&tk->tkr_mono); in ktime_get_update_offsets_now()
2301 if (*cwsseq != tk->clock_was_set_seq) { in ktime_get_update_offsets_now()
2302 *cwsseq = tk->clock_was_set_seq; in ktime_get_update_offsets_now()
2303 *offs_real = tk->offs_real; in ktime_get_update_offsets_now()
2304 *offs_boot = tk->offs_boot; in ktime_get_update_offsets_now()
2305 *offs_tai = tk->offs_tai; in ktime_get_update_offsets_now()
2309 if (unlikely(base >= tk->next_leap_ktime)) in ktime_get_update_offsets_now()
2310 *offs_real = ktime_sub(tk->offs_real, ktime_set(1, 0)); in ktime_get_update_offsets_now()
2388 struct timekeeper *tk = &tk_core.timekeeper; in do_adjtimex() local
2420 orig_tai = tai = tk->tai_offset; in do_adjtimex()
2424 __timekeeping_set_tai_offset(tk, tai); in do_adjtimex()
2425 timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); in do_adjtimex()
2427 tk_update_leap_state(tk); in do_adjtimex()