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()
529 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_boot_fast_ns() local
531 return (ktime_get_mono_fast_ns() + ktime_to_ns(tk->offs_boot)); in ktime_get_boot_fast_ns()
616 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_fast_timestamps() local
619 snapshot->boot = snapshot->mono + ktime_to_ns(data_race(tk->offs_boot)); in ktime_get_fast_timestamps()
632 static void halt_fast_timekeeper(const struct timekeeper *tk) in halt_fast_timekeeper() argument
635 const struct tk_read_base *tkr = &tk->tkr_mono; in halt_fast_timekeeper()
640 tkr_dummy.base_real = tkr->base + tk->offs_real; in halt_fast_timekeeper()
643 tkr = &tk->tkr_raw; in halt_fast_timekeeper()
651 static void update_pvclock_gtod(struct timekeeper *tk, bool was_set) in update_pvclock_gtod() argument
653 raw_notifier_call_chain(&pvclock_gtod_chain, was_set, tk); in update_pvclock_gtod()
662 struct timekeeper *tk = &tk_core.timekeeper; in pvclock_gtod_register_notifier() local
668 update_pvclock_gtod(tk, true); in pvclock_gtod_register_notifier()
696 static inline void tk_update_leap_state(struct timekeeper *tk) in tk_update_leap_state() argument
698 tk->next_leap_ktime = ntp_get_next_leap(); in tk_update_leap_state()
699 if (tk->next_leap_ktime != KTIME_MAX) in tk_update_leap_state()
701 tk->next_leap_ktime = ktime_sub(tk->next_leap_ktime, tk->offs_real); in tk_update_leap_state()
707 static inline void tk_update_ktime_data(struct timekeeper *tk) in tk_update_ktime_data() argument
719 seconds = (u64)(tk->xtime_sec + tk->wall_to_monotonic.tv_sec); in tk_update_ktime_data()
720 nsec = (u32) tk->wall_to_monotonic.tv_nsec; in tk_update_ktime_data()
721 tk->tkr_mono.base = ns_to_ktime(seconds * NSEC_PER_SEC + nsec); in tk_update_ktime_data()
728 nsec += (u32)(tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift); in tk_update_ktime_data()
731 tk->ktime_sec = seconds; in tk_update_ktime_data()
734 tk->tkr_raw.base = ns_to_ktime(tk->raw_sec * NSEC_PER_SEC); in tk_update_ktime_data()
738 static void timekeeping_update(struct timekeeper *tk, unsigned int action) in timekeeping_update() argument
741 tk->ntp_error = 0; in timekeeping_update()
745 tk_update_leap_state(tk); in timekeeping_update()
746 tk_update_ktime_data(tk); in timekeeping_update()
748 update_vsyscall(tk); in timekeeping_update()
749 update_pvclock_gtod(tk, action & TK_CLOCK_WAS_SET); in timekeeping_update()
751 tk->tkr_mono.base_real = tk->tkr_mono.base + tk->offs_real; in timekeeping_update()
752 update_fast_timekeeper(&tk->tkr_mono, &tk_fast_mono); in timekeeping_update()
753 update_fast_timekeeper(&tk->tkr_raw, &tk_fast_raw); in timekeeping_update()
756 tk->clock_was_set_seq++; in timekeeping_update()
775 static void timekeeping_forward_now(struct timekeeper *tk) in timekeeping_forward_now() argument
779 cycle_now = tk_clock_read(&tk->tkr_mono); in timekeeping_forward_now()
780 delta = clocksource_delta(cycle_now, tk->tkr_mono.cycle_last, tk->tkr_mono.mask); in timekeeping_forward_now()
781 tk->tkr_mono.cycle_last = cycle_now; in timekeeping_forward_now()
782 tk->tkr_raw.cycle_last = cycle_now; in timekeeping_forward_now()
784 tk->tkr_mono.xtime_nsec += delta * tk->tkr_mono.mult; in timekeeping_forward_now()
785 tk->tkr_raw.xtime_nsec += delta * tk->tkr_raw.mult; in timekeeping_forward_now()
787 tk_normalize_xtime(tk); in timekeeping_forward_now()
798 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_real_ts64() local
807 ts->tv_sec = tk->xtime_sec; in ktime_get_real_ts64()
808 nsecs = timekeeping_get_ns(&tk->tkr_mono); in ktime_get_real_ts64()
819 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get() local
828 base = tk->tkr_mono.base; in ktime_get()
829 nsecs = timekeeping_get_ns(&tk->tkr_mono); in ktime_get()
839 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_resolution_ns() local
847 nsecs = tk->tkr_mono.mult >> tk->tkr_mono.shift; in ktime_get_resolution_ns()
862 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_with_offset() local
871 base = ktime_add(tk->tkr_mono.base, *offset); in ktime_get_with_offset()
872 nsecs = timekeeping_get_ns(&tk->tkr_mono); in ktime_get_with_offset()
883 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_coarse_with_offset() local
892 base = ktime_add(tk->tkr_mono.base, *offset); in ktime_get_coarse_with_offset()
893 nsecs = tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift; in ktime_get_coarse_with_offset()
926 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_raw() local
933 base = tk->tkr_raw.base; in ktime_get_raw()
934 nsecs = timekeeping_get_ns(&tk->tkr_raw); in ktime_get_raw()
952 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_ts64() local
961 ts->tv_sec = tk->xtime_sec; in ktime_get_ts64()
962 nsec = timekeeping_get_ns(&tk->tkr_mono); in ktime_get_ts64()
963 tomono = tk->wall_to_monotonic; in ktime_get_ts64()
984 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_seconds() local
987 return tk->ktime_sec; in ktime_get_seconds()
1003 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_real_seconds() local
1008 return tk->xtime_sec; in ktime_get_real_seconds()
1012 seconds = tk->xtime_sec; in ktime_get_real_seconds()
1027 struct timekeeper *tk = &tk_core.timekeeper; in __ktime_get_real_seconds() local
1029 return tk->xtime_sec; in __ktime_get_real_seconds()
1038 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_snapshot() local
1050 now = tk_clock_read(&tk->tkr_mono); in ktime_get_snapshot()
1051 systime_snapshot->cs_id = tk->tkr_mono.clock->id; in ktime_get_snapshot()
1052 systime_snapshot->cs_was_changed_seq = tk->cs_was_changed_seq; in ktime_get_snapshot()
1053 systime_snapshot->clock_was_set_seq = tk->clock_was_set_seq; in ktime_get_snapshot()
1054 base_real = ktime_add(tk->tkr_mono.base, in ktime_get_snapshot()
1056 base_raw = tk->tkr_raw.base; in ktime_get_snapshot()
1057 nsec_real = timekeeping_cycles_to_ns(&tk->tkr_mono, now); in ktime_get_snapshot()
1058 nsec_raw = timekeeping_cycles_to_ns(&tk->tkr_raw, now); in ktime_get_snapshot()
1107 struct timekeeper *tk = &tk_core.timekeeper; in adjust_historical_crosststamp() local
1141 (corr_raw, tk->tkr_mono.mult, tk->tkr_raw.mult); in adjust_historical_crosststamp()
1195 struct timekeeper *tk = &tk_core.timekeeper; in get_device_system_crosststamp() local
1220 if (tk->tkr_mono.clock != system_counterval.cs) in get_device_system_crosststamp()
1228 now = tk_clock_read(&tk->tkr_mono); in get_device_system_crosststamp()
1229 interval_start = tk->tkr_mono.cycle_last; in get_device_system_crosststamp()
1231 clock_was_set_seq = tk->clock_was_set_seq; in get_device_system_crosststamp()
1232 cs_was_changed_seq = tk->cs_was_changed_seq; in get_device_system_crosststamp()
1239 base_real = ktime_add(tk->tkr_mono.base, in get_device_system_crosststamp()
1241 base_raw = tk->tkr_raw.base; in get_device_system_crosststamp()
1243 nsec_real = timekeeping_cycles_to_ns(&tk->tkr_mono, in get_device_system_crosststamp()
1245 nsec_raw = timekeeping_cycles_to_ns(&tk->tkr_raw, in get_device_system_crosststamp()
1295 struct timekeeper *tk = &tk_core.timekeeper; in do_settimeofday64() local
1306 timekeeping_forward_now(tk); in do_settimeofday64()
1308 xt = tk_xtime(tk); in do_settimeofday64()
1312 if (timespec64_compare(&tk->wall_to_monotonic, &ts_delta) > 0) { in do_settimeofday64()
1317 tk_set_wall_to_mono(tk, timespec64_sub(tk->wall_to_monotonic, ts_delta)); in do_settimeofday64()
1319 tk_set_xtime(tk, ts); in do_settimeofday64()
1321 timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); in do_settimeofday64()
1344 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_inject_offset() local
1355 timekeeping_forward_now(tk); in timekeeping_inject_offset()
1358 tmp = timespec64_add(tk_xtime(tk), *ts); in timekeeping_inject_offset()
1359 if (timespec64_compare(&tk->wall_to_monotonic, ts) > 0 || in timekeeping_inject_offset()
1365 tk_xtime_add(tk, ts); in timekeeping_inject_offset()
1366 tk_set_wall_to_mono(tk, timespec64_sub(tk->wall_to_monotonic, *ts)); in timekeeping_inject_offset()
1369 timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); in timekeeping_inject_offset()
1417 static void __timekeeping_set_tai_offset(struct timekeeper *tk, s32 tai_offset) in __timekeeping_set_tai_offset() argument
1419 tk->tai_offset = tai_offset; in __timekeeping_set_tai_offset()
1420 tk->offs_tai = ktime_add(tk->offs_real, ktime_set(tai_offset, 0)); in __timekeeping_set_tai_offset()
1430 struct timekeeper *tk = &tk_core.timekeeper; in change_clocksource() local
1451 timekeeping_forward_now(tk); in change_clocksource()
1454 old = tk->tkr_mono.clock; in change_clocksource()
1455 tk_setup_internals(tk, new); in change_clocksource()
1458 timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); in change_clocksource()
1482 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_notify() local
1484 if (tk->tkr_mono.clock == clock) in timekeeping_notify()
1488 return tk->tkr_mono.clock == clock ? 0 : -1; in timekeeping_notify()
1499 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_raw_ts64() local
1505 ts->tv_sec = tk->raw_sec; in ktime_get_raw_ts64()
1506 nsecs = timekeeping_get_ns(&tk->tkr_raw); in ktime_get_raw_ts64()
1521 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_valid_for_hres() local
1528 ret = tk->tkr_mono.clock->flags & CLOCK_SOURCE_VALID_FOR_HRES; in timekeeping_valid_for_hres()
1540 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_max_deferment() local
1547 ret = tk->tkr_mono.clock->max_idle_ns; in timekeeping_max_deferment()
1615 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_init() local
1644 tk_setup_internals(tk, clock); in timekeeping_init()
1646 tk_set_xtime(tk, &wall_time); in timekeeping_init()
1647 tk->raw_sec = 0; in timekeeping_init()
1649 tk_set_wall_to_mono(tk, wall_to_mono); in timekeeping_init()
1651 timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); in timekeeping_init()
1668 static void __timekeeping_inject_sleeptime(struct timekeeper *tk, in __timekeeping_inject_sleeptime() argument
1677 tk_xtime_add(tk, delta); in __timekeeping_inject_sleeptime()
1678 tk_set_wall_to_mono(tk, timespec64_sub(tk->wall_to_monotonic, *delta)); in __timekeeping_inject_sleeptime()
1679 tk_update_sleep_time(tk, timespec64_to_ktime(*delta)); in __timekeeping_inject_sleeptime()
1732 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_inject_sleeptime64() local
1740 timekeeping_forward_now(tk); in timekeeping_inject_sleeptime64()
1742 __timekeeping_inject_sleeptime(tk, delta); in timekeeping_inject_sleeptime64()
1744 timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); in timekeeping_inject_sleeptime64()
1759 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_resume() local
1760 struct clocksource *clock = tk->tkr_mono.clock; in timekeeping_resume()
1786 cycle_now = tk_clock_read(&tk->tkr_mono); in timekeeping_resume()
1798 __timekeeping_inject_sleeptime(tk, &ts_delta); in timekeeping_resume()
1802 tk->tkr_mono.cycle_last = cycle_now; in timekeeping_resume()
1803 tk->tkr_raw.cycle_last = cycle_now; in timekeeping_resume()
1805 tk->ntp_error = 0; in timekeeping_resume()
1807 timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); in timekeeping_resume()
1821 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_suspend() local
1842 timekeeping_forward_now(tk); in timekeeping_suspend()
1850 curr_clock = tk->tkr_mono.clock; in timekeeping_suspend()
1851 cycle_now = tk->tkr_mono.cycle_last; in timekeeping_suspend()
1861 delta = timespec64_sub(tk_xtime(tk), timekeeping_suspend_time); in timekeeping_suspend()
1876 timekeeping_update(tk, TK_MIRROR); in timekeeping_suspend()
1877 halt_fast_timekeeper(tk); in timekeeping_suspend()
1904 static __always_inline void timekeeping_apply_adjustment(struct timekeeper *tk, in timekeeping_apply_adjustment() argument
1908 s64 interval = tk->cycle_interval; in timekeeping_apply_adjustment()
1967 if ((mult_adj > 0) && (tk->tkr_mono.mult + mult_adj < mult_adj)) { in timekeeping_apply_adjustment()
1973 tk->tkr_mono.mult += mult_adj; in timekeeping_apply_adjustment()
1974 tk->xtime_interval += interval; in timekeeping_apply_adjustment()
1975 tk->tkr_mono.xtime_nsec -= offset; in timekeeping_apply_adjustment()
1982 static void timekeeping_adjust(struct timekeeper *tk, s64 offset) in timekeeping_adjust() argument
1990 if (likely(tk->ntp_tick == ntp_tick_length())) { in timekeeping_adjust()
1991 mult = tk->tkr_mono.mult - tk->ntp_err_mult; in timekeeping_adjust()
1993 tk->ntp_tick = ntp_tick_length(); in timekeeping_adjust()
1994 mult = div64_u64((tk->ntp_tick >> tk->ntp_error_shift) - in timekeeping_adjust()
1995 tk->xtime_remainder, tk->cycle_interval); in timekeeping_adjust()
2004 tk->ntp_err_mult = tk->ntp_error > 0 ? 1 : 0; in timekeeping_adjust()
2005 mult += tk->ntp_err_mult; in timekeeping_adjust()
2007 timekeeping_apply_adjustment(tk, offset, mult - tk->tkr_mono.mult); in timekeeping_adjust()
2009 if (unlikely(tk->tkr_mono.clock->maxadj && in timekeeping_adjust()
2010 (abs(tk->tkr_mono.mult - tk->tkr_mono.clock->mult) in timekeeping_adjust()
2011 > tk->tkr_mono.clock->maxadj))) { in timekeeping_adjust()
2014 tk->tkr_mono.clock->name, (long)tk->tkr_mono.mult, in timekeeping_adjust()
2015 (long)tk->tkr_mono.clock->mult + tk->tkr_mono.clock->maxadj); in timekeeping_adjust()
2028 if (unlikely((s64)tk->tkr_mono.xtime_nsec < 0)) { in timekeeping_adjust()
2029 tk->tkr_mono.xtime_nsec += (u64)NSEC_PER_SEC << in timekeeping_adjust()
2030 tk->tkr_mono.shift; in timekeeping_adjust()
2031 tk->xtime_sec--; in timekeeping_adjust()
2032 tk->skip_second_overflow = 1; in timekeeping_adjust()
2043 static inline unsigned int accumulate_nsecs_to_secs(struct timekeeper *tk) in accumulate_nsecs_to_secs() argument
2045 u64 nsecps = (u64)NSEC_PER_SEC << tk->tkr_mono.shift; in accumulate_nsecs_to_secs()
2048 while (tk->tkr_mono.xtime_nsec >= nsecps) { in accumulate_nsecs_to_secs()
2051 tk->tkr_mono.xtime_nsec -= nsecps; in accumulate_nsecs_to_secs()
2052 tk->xtime_sec++; in accumulate_nsecs_to_secs()
2058 if (unlikely(tk->skip_second_overflow)) { in accumulate_nsecs_to_secs()
2059 tk->skip_second_overflow = 0; in accumulate_nsecs_to_secs()
2064 leap = second_overflow(tk->xtime_sec); in accumulate_nsecs_to_secs()
2068 tk->xtime_sec += leap; in accumulate_nsecs_to_secs()
2072 tk_set_wall_to_mono(tk, in accumulate_nsecs_to_secs()
2073 timespec64_sub(tk->wall_to_monotonic, ts)); in accumulate_nsecs_to_secs()
2075 __timekeeping_set_tai_offset(tk, tk->tai_offset - leap); in accumulate_nsecs_to_secs()
2092 static u64 logarithmic_accumulation(struct timekeeper *tk, u64 offset, in logarithmic_accumulation() argument
2095 u64 interval = tk->cycle_interval << shift; in logarithmic_accumulation()
2104 tk->tkr_mono.cycle_last += interval; in logarithmic_accumulation()
2105 tk->tkr_raw.cycle_last += interval; in logarithmic_accumulation()
2107 tk->tkr_mono.xtime_nsec += tk->xtime_interval << shift; in logarithmic_accumulation()
2108 *clock_set |= accumulate_nsecs_to_secs(tk); in logarithmic_accumulation()
2111 tk->tkr_raw.xtime_nsec += tk->raw_interval << shift; in logarithmic_accumulation()
2112 snsec_per_sec = (u64)NSEC_PER_SEC << tk->tkr_raw.shift; in logarithmic_accumulation()
2113 while (tk->tkr_raw.xtime_nsec >= snsec_per_sec) { in logarithmic_accumulation()
2114 tk->tkr_raw.xtime_nsec -= snsec_per_sec; in logarithmic_accumulation()
2115 tk->raw_sec++; in logarithmic_accumulation()
2119 tk->ntp_error += tk->ntp_tick << shift; in logarithmic_accumulation()
2120 tk->ntp_error -= (tk->xtime_interval + tk->xtime_remainder) << in logarithmic_accumulation()
2121 (tk->ntp_error_shift + shift); in logarithmic_accumulation()
2133 struct timekeeper *tk = &shadow_timekeeper; in timekeeping_advance() local
2145 offset = clocksource_delta(tk_clock_read(&tk->tkr_mono), in timekeeping_advance()
2146 tk->tkr_mono.cycle_last, tk->tkr_mono.mask); in timekeeping_advance()
2153 timekeeping_check_update(tk, offset); in timekeeping_advance()
2163 shift = ilog2(offset) - ilog2(tk->cycle_interval); in timekeeping_advance()
2168 while (offset >= tk->cycle_interval) { in timekeeping_advance()
2169 offset = logarithmic_accumulation(tk, offset, shift, in timekeeping_advance()
2171 if (offset < tk->cycle_interval<<shift) in timekeeping_advance()
2176 timekeeping_adjust(tk, offset); in timekeeping_advance()
2182 clock_set |= accumulate_nsecs_to_secs(tk); in timekeeping_advance()
2195 timekeeping_update(tk, clock_set); in timekeeping_advance()
2196 memcpy(real_tk, tk, sizeof(*tk)); in timekeeping_advance()
2228 struct timekeeper *tk = &tk_core.timekeeper; in getboottime64() local
2229 ktime_t t = ktime_sub(tk->offs_real, tk->offs_boot); in getboottime64()
2237 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_coarse_real_ts64() local
2243 *ts = tk_xtime(tk); in ktime_get_coarse_real_ts64()
2250 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_coarse_ts64() local
2257 now = tk_xtime(tk); in ktime_get_coarse_ts64()
2258 mono = tk->wall_to_monotonic; in ktime_get_coarse_ts64()
2291 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_update_offsets_now() local
2299 base = tk->tkr_mono.base; in ktime_get_update_offsets_now()
2300 nsecs = timekeeping_get_ns(&tk->tkr_mono); in ktime_get_update_offsets_now()
2303 if (*cwsseq != tk->clock_was_set_seq) { in ktime_get_update_offsets_now()
2304 *cwsseq = tk->clock_was_set_seq; in ktime_get_update_offsets_now()
2305 *offs_real = tk->offs_real; in ktime_get_update_offsets_now()
2306 *offs_boot = tk->offs_boot; in ktime_get_update_offsets_now()
2307 *offs_tai = tk->offs_tai; in ktime_get_update_offsets_now()
2311 if (unlikely(base >= tk->next_leap_ktime)) in ktime_get_update_offsets_now()
2312 *offs_real = ktime_sub(tk->offs_real, ktime_set(1, 0)); in ktime_get_update_offsets_now()
2390 struct timekeeper *tk = &tk_core.timekeeper; in do_adjtimex() local
2423 orig_tai = tai = tk->tai_offset; in do_adjtimex()
2427 __timekeeping_set_tai_offset(tk, tai); in do_adjtimex()
2428 timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); in do_adjtimex()
2431 tk_update_leap_state(tk); in do_adjtimex()