Lines Matching refs:tk

117 static inline void tk_normalize_xtime(struct timekeeper *tk)  in tk_normalize_xtime()  argument
119 while (tk->tkr_mono.xtime_nsec >= ((u64)NSEC_PER_SEC << tk->tkr_mono.shift)) { in tk_normalize_xtime()
120 tk->tkr_mono.xtime_nsec -= (u64)NSEC_PER_SEC << tk->tkr_mono.shift; in tk_normalize_xtime()
121 tk->xtime_sec++; in tk_normalize_xtime()
123 while (tk->tkr_raw.xtime_nsec >= ((u64)NSEC_PER_SEC << tk->tkr_raw.shift)) { in tk_normalize_xtime()
124 tk->tkr_raw.xtime_nsec -= (u64)NSEC_PER_SEC << tk->tkr_raw.shift; in tk_normalize_xtime()
125 tk->raw_sec++; in tk_normalize_xtime()
129 static inline struct timespec64 tk_xtime(const struct timekeeper *tk) in tk_xtime() argument
133 ts.tv_sec = tk->xtime_sec; in tk_xtime()
134 ts.tv_nsec = (long)(tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift); in tk_xtime()
138 static void tk_set_xtime(struct timekeeper *tk, const struct timespec64 *ts) in tk_set_xtime() argument
140 tk->xtime_sec = ts->tv_sec; in tk_set_xtime()
141 tk->tkr_mono.xtime_nsec = (u64)ts->tv_nsec << tk->tkr_mono.shift; in tk_set_xtime()
144 static void tk_xtime_add(struct timekeeper *tk, const struct timespec64 *ts) in tk_xtime_add() argument
146 tk->xtime_sec += ts->tv_sec; in tk_xtime_add()
147 tk->tkr_mono.xtime_nsec += (u64)ts->tv_nsec << tk->tkr_mono.shift; in tk_xtime_add()
148 tk_normalize_xtime(tk); in tk_xtime_add()
151 static void tk_set_wall_to_mono(struct timekeeper *tk, struct timespec64 wtm) in tk_set_wall_to_mono() argument
159 set_normalized_timespec64(&tmp, -tk->wall_to_monotonic.tv_sec, in tk_set_wall_to_mono()
160 -tk->wall_to_monotonic.tv_nsec); in tk_set_wall_to_mono()
161 WARN_ON_ONCE(tk->offs_real != timespec64_to_ktime(tmp)); in tk_set_wall_to_mono()
162 tk->wall_to_monotonic = wtm; in tk_set_wall_to_mono()
164 tk->offs_real = timespec64_to_ktime(tmp); in tk_set_wall_to_mono()
165 tk->offs_tai = ktime_add(tk->offs_real, ktime_set(tk->tai_offset, 0)); in tk_set_wall_to_mono()
168 static inline void tk_update_sleep_time(struct timekeeper *tk, ktime_t delta) in tk_update_sleep_time() argument
170 tk->offs_boot = ktime_add(tk->offs_boot, delta); in tk_update_sleep_time()
175 tk->monotonic_to_boot = ktime_to_timespec64(tk->offs_boot); in tk_update_sleep_time()
201 static void timekeeping_check_update(struct timekeeper *tk, u64 offset) in timekeeping_check_update() argument
204 u64 max_cycles = tk->tkr_mono.clock->max_cycles; in timekeeping_check_update()
205 const char *name = tk->tkr_mono.clock->name; in timekeeping_check_update()
219 if (tk->underflow_seen) { in timekeeping_check_update()
220 if (jiffies - tk->last_warning > WARNING_FREQ) { in timekeeping_check_update()
224 tk->last_warning = jiffies; in timekeeping_check_update()
226 tk->underflow_seen = 0; in timekeeping_check_update()
229 if (tk->overflow_seen) { in timekeeping_check_update()
230 if (jiffies - tk->last_warning > WARNING_FREQ) { in timekeeping_check_update()
234 tk->last_warning = jiffies; in timekeeping_check_update()
236 tk->overflow_seen = 0; in timekeeping_check_update()
242 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_get_delta() local
268 tk->underflow_seen = 1; in timekeeping_get_delta()
274 tk->overflow_seen = 1; in timekeeping_get_delta()
281 static inline void timekeeping_check_update(struct timekeeper *tk, u64 offset) in timekeeping_check_update() argument
309 static void tk_setup_internals(struct timekeeper *tk, struct clocksource *clock) in tk_setup_internals() argument
315 ++tk->cs_was_changed_seq; in tk_setup_internals()
316 old_clock = tk->tkr_mono.clock; in tk_setup_internals()
317 tk->tkr_mono.clock = clock; in tk_setup_internals()
318 tk->tkr_mono.mask = clock->mask; in tk_setup_internals()
319 tk->tkr_mono.cycle_last = tk_clock_read(&tk->tkr_mono); in tk_setup_internals()
321 tk->tkr_raw.clock = clock; in tk_setup_internals()
322 tk->tkr_raw.mask = clock->mask; in tk_setup_internals()
323 tk->tkr_raw.cycle_last = tk->tkr_mono.cycle_last; in tk_setup_internals()
335 tk->cycle_interval = interval; in tk_setup_internals()
338 tk->xtime_interval = interval * clock->mult; in tk_setup_internals()
339 tk->xtime_remainder = ntpinterval - tk->xtime_interval; in tk_setup_internals()
340 tk->raw_interval = interval * clock->mult; in tk_setup_internals()
346 tk->tkr_mono.xtime_nsec >>= -shift_change; in tk_setup_internals()
347 tk->tkr_raw.xtime_nsec >>= -shift_change; in tk_setup_internals()
349 tk->tkr_mono.xtime_nsec <<= shift_change; in tk_setup_internals()
350 tk->tkr_raw.xtime_nsec <<= shift_change; in tk_setup_internals()
354 tk->tkr_mono.shift = clock->shift; in tk_setup_internals()
355 tk->tkr_raw.shift = clock->shift; in tk_setup_internals()
357 tk->ntp_error = 0; in tk_setup_internals()
358 tk->ntp_error_shift = NTP_SCALE_SHIFT - clock->shift; in tk_setup_internals()
359 tk->ntp_tick = ntpinterval << tk->ntp_error_shift; in tk_setup_internals()
366 tk->tkr_mono.mult = clock->mult; in tk_setup_internals()
367 tk->tkr_raw.mult = clock->mult; in tk_setup_internals()
368 tk->ntp_err_mult = 0; in tk_setup_internals()
369 tk->skip_second_overflow = 0; in tk_setup_internals()
534 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_boot_fast_ns() local
536 return (ktime_get_mono_fast_ns() + ktime_to_ns(data_race(tk->offs_boot))); in ktime_get_boot_fast_ns()
551 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_tai_fast_ns() local
553 return (ktime_get_mono_fast_ns() + ktime_to_ns(data_race(tk->offs_tai))); in ktime_get_tai_fast_ns()
635 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_fast_timestamps() local
638 snapshot->boot = snapshot->mono + ktime_to_ns(data_race(tk->offs_boot)); in ktime_get_fast_timestamps()
651 static void halt_fast_timekeeper(const struct timekeeper *tk) in halt_fast_timekeeper() argument
654 const struct tk_read_base *tkr = &tk->tkr_mono; in halt_fast_timekeeper()
659 tkr_dummy.base_real = tkr->base + tk->offs_real; in halt_fast_timekeeper()
662 tkr = &tk->tkr_raw; in halt_fast_timekeeper()
670 static void update_pvclock_gtod(struct timekeeper *tk, bool was_set) in update_pvclock_gtod() argument
672 raw_notifier_call_chain(&pvclock_gtod_chain, was_set, tk); in update_pvclock_gtod()
681 struct timekeeper *tk = &tk_core.timekeeper; in pvclock_gtod_register_notifier() local
687 update_pvclock_gtod(tk, true); in pvclock_gtod_register_notifier()
715 static inline void tk_update_leap_state(struct timekeeper *tk) in tk_update_leap_state() argument
717 tk->next_leap_ktime = ntp_get_next_leap(); in tk_update_leap_state()
718 if (tk->next_leap_ktime != KTIME_MAX) in tk_update_leap_state()
720 tk->next_leap_ktime = ktime_sub(tk->next_leap_ktime, tk->offs_real); in tk_update_leap_state()
726 static inline void tk_update_ktime_data(struct timekeeper *tk) in tk_update_ktime_data() argument
738 seconds = (u64)(tk->xtime_sec + tk->wall_to_monotonic.tv_sec); in tk_update_ktime_data()
739 nsec = (u32) tk->wall_to_monotonic.tv_nsec; in tk_update_ktime_data()
740 tk->tkr_mono.base = ns_to_ktime(seconds * NSEC_PER_SEC + nsec); in tk_update_ktime_data()
747 nsec += (u32)(tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift); in tk_update_ktime_data()
750 tk->ktime_sec = seconds; in tk_update_ktime_data()
753 tk->tkr_raw.base = ns_to_ktime(tk->raw_sec * NSEC_PER_SEC); in tk_update_ktime_data()
757 static void timekeeping_update(struct timekeeper *tk, unsigned int action) in timekeeping_update() argument
760 tk->ntp_error = 0; in timekeeping_update()
764 tk_update_leap_state(tk); in timekeeping_update()
765 tk_update_ktime_data(tk); in timekeeping_update()
767 update_vsyscall(tk); in timekeeping_update()
768 update_pvclock_gtod(tk, action & TK_CLOCK_WAS_SET); in timekeeping_update()
770 tk->tkr_mono.base_real = tk->tkr_mono.base + tk->offs_real; in timekeeping_update()
771 update_fast_timekeeper(&tk->tkr_mono, &tk_fast_mono); in timekeeping_update()
772 update_fast_timekeeper(&tk->tkr_raw, &tk_fast_raw); in timekeeping_update()
775 tk->clock_was_set_seq++; in timekeeping_update()
794 static void timekeeping_forward_now(struct timekeeper *tk) in timekeeping_forward_now() argument
798 cycle_now = tk_clock_read(&tk->tkr_mono); in timekeeping_forward_now()
799 delta = clocksource_delta(cycle_now, tk->tkr_mono.cycle_last, tk->tkr_mono.mask); in timekeeping_forward_now()
800 tk->tkr_mono.cycle_last = cycle_now; in timekeeping_forward_now()
801 tk->tkr_raw.cycle_last = cycle_now; in timekeeping_forward_now()
803 tk->tkr_mono.xtime_nsec += delta * tk->tkr_mono.mult; in timekeeping_forward_now()
804 tk->tkr_raw.xtime_nsec += delta * tk->tkr_raw.mult; in timekeeping_forward_now()
806 tk_normalize_xtime(tk); in timekeeping_forward_now()
817 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_real_ts64() local
826 ts->tv_sec = tk->xtime_sec; in ktime_get_real_ts64()
827 nsecs = timekeeping_get_ns(&tk->tkr_mono); in ktime_get_real_ts64()
838 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get() local
847 base = tk->tkr_mono.base; in ktime_get()
848 nsecs = timekeeping_get_ns(&tk->tkr_mono); in ktime_get()
858 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_resolution_ns() local
866 nsecs = tk->tkr_mono.mult >> tk->tkr_mono.shift; in ktime_get_resolution_ns()
881 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_with_offset() local
890 base = ktime_add(tk->tkr_mono.base, *offset); in ktime_get_with_offset()
891 nsecs = timekeeping_get_ns(&tk->tkr_mono); in ktime_get_with_offset()
902 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_coarse_with_offset() local
911 base = ktime_add(tk->tkr_mono.base, *offset); in ktime_get_coarse_with_offset()
912 nsecs = tk->tkr_mono.xtime_nsec >> tk->tkr_mono.shift; in ktime_get_coarse_with_offset()
945 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_raw() local
952 base = tk->tkr_raw.base; in ktime_get_raw()
953 nsecs = timekeeping_get_ns(&tk->tkr_raw); in ktime_get_raw()
971 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_ts64() local
980 ts->tv_sec = tk->xtime_sec; in ktime_get_ts64()
981 nsec = timekeeping_get_ns(&tk->tkr_mono); in ktime_get_ts64()
982 tomono = tk->wall_to_monotonic; in ktime_get_ts64()
1003 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_seconds() local
1006 return tk->ktime_sec; in ktime_get_seconds()
1022 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_real_seconds() local
1027 return tk->xtime_sec; in ktime_get_real_seconds()
1031 seconds = tk->xtime_sec; in ktime_get_real_seconds()
1046 struct timekeeper *tk = &tk_core.timekeeper; in __ktime_get_real_seconds() local
1048 return tk->xtime_sec; in __ktime_get_real_seconds()
1057 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_snapshot() local
1069 now = tk_clock_read(&tk->tkr_mono); in ktime_get_snapshot()
1070 systime_snapshot->cs_id = tk->tkr_mono.clock->id; in ktime_get_snapshot()
1071 systime_snapshot->cs_was_changed_seq = tk->cs_was_changed_seq; in ktime_get_snapshot()
1072 systime_snapshot->clock_was_set_seq = tk->clock_was_set_seq; in ktime_get_snapshot()
1073 base_real = ktime_add(tk->tkr_mono.base, in ktime_get_snapshot()
1075 base_raw = tk->tkr_raw.base; in ktime_get_snapshot()
1076 nsec_real = timekeeping_cycles_to_ns(&tk->tkr_mono, now); in ktime_get_snapshot()
1077 nsec_raw = timekeeping_cycles_to_ns(&tk->tkr_raw, now); in ktime_get_snapshot()
1126 struct timekeeper *tk = &tk_core.timekeeper; in adjust_historical_crosststamp() local
1160 (corr_raw, tk->tkr_mono.mult, tk->tkr_raw.mult); in adjust_historical_crosststamp()
1214 struct timekeeper *tk = &tk_core.timekeeper; in get_device_system_crosststamp() local
1239 if (tk->tkr_mono.clock != system_counterval.cs) in get_device_system_crosststamp()
1247 now = tk_clock_read(&tk->tkr_mono); in get_device_system_crosststamp()
1248 interval_start = tk->tkr_mono.cycle_last; in get_device_system_crosststamp()
1250 clock_was_set_seq = tk->clock_was_set_seq; in get_device_system_crosststamp()
1251 cs_was_changed_seq = tk->cs_was_changed_seq; in get_device_system_crosststamp()
1258 base_real = ktime_add(tk->tkr_mono.base, in get_device_system_crosststamp()
1260 base_raw = tk->tkr_raw.base; in get_device_system_crosststamp()
1262 nsec_real = timekeeping_cycles_to_ns(&tk->tkr_mono, in get_device_system_crosststamp()
1264 nsec_raw = timekeeping_cycles_to_ns(&tk->tkr_raw, in get_device_system_crosststamp()
1314 struct timekeeper *tk = &tk_core.timekeeper; in do_settimeofday64() local
1325 timekeeping_forward_now(tk); in do_settimeofday64()
1327 xt = tk_xtime(tk); in do_settimeofday64()
1330 if (timespec64_compare(&tk->wall_to_monotonic, &ts_delta) > 0) { in do_settimeofday64()
1335 tk_set_wall_to_mono(tk, timespec64_sub(tk->wall_to_monotonic, ts_delta)); in do_settimeofday64()
1337 tk_set_xtime(tk, ts); in do_settimeofday64()
1339 timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); in do_settimeofday64()
1364 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_inject_offset() local
1375 timekeeping_forward_now(tk); in timekeeping_inject_offset()
1378 tmp = timespec64_add(tk_xtime(tk), *ts); in timekeeping_inject_offset()
1379 if (timespec64_compare(&tk->wall_to_monotonic, ts) > 0 || in timekeeping_inject_offset()
1385 tk_xtime_add(tk, ts); in timekeeping_inject_offset()
1386 tk_set_wall_to_mono(tk, timespec64_sub(tk->wall_to_monotonic, *ts)); in timekeeping_inject_offset()
1389 timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); in timekeeping_inject_offset()
1437 static void __timekeeping_set_tai_offset(struct timekeeper *tk, s32 tai_offset) in __timekeeping_set_tai_offset() argument
1439 tk->tai_offset = tai_offset; in __timekeeping_set_tai_offset()
1440 tk->offs_tai = ktime_add(tk->offs_real, ktime_set(tai_offset, 0)); in __timekeeping_set_tai_offset()
1450 struct timekeeper *tk = &tk_core.timekeeper; in change_clocksource() local
1471 timekeeping_forward_now(tk); in change_clocksource()
1474 old = tk->tkr_mono.clock; in change_clocksource()
1475 tk_setup_internals(tk, new); in change_clocksource()
1478 timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); in change_clocksource()
1502 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_notify() local
1504 if (tk->tkr_mono.clock == clock) in timekeeping_notify()
1508 return tk->tkr_mono.clock == clock ? 0 : -1; in timekeeping_notify()
1519 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_raw_ts64() local
1525 ts->tv_sec = tk->raw_sec; in ktime_get_raw_ts64()
1526 nsecs = timekeeping_get_ns(&tk->tkr_raw); in ktime_get_raw_ts64()
1541 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_valid_for_hres() local
1548 ret = tk->tkr_mono.clock->flags & CLOCK_SOURCE_VALID_FOR_HRES; in timekeeping_valid_for_hres()
1560 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_max_deferment() local
1567 ret = tk->tkr_mono.clock->max_idle_ns; in timekeeping_max_deferment()
1635 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_init() local
1664 tk_setup_internals(tk, clock); in timekeeping_init()
1666 tk_set_xtime(tk, &wall_time); in timekeeping_init()
1667 tk->raw_sec = 0; in timekeeping_init()
1669 tk_set_wall_to_mono(tk, wall_to_mono); in timekeeping_init()
1671 timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); in timekeeping_init()
1688 static void __timekeeping_inject_sleeptime(struct timekeeper *tk, in __timekeeping_inject_sleeptime() argument
1697 tk_xtime_add(tk, delta); in __timekeeping_inject_sleeptime()
1698 tk_set_wall_to_mono(tk, timespec64_sub(tk->wall_to_monotonic, *delta)); in __timekeeping_inject_sleeptime()
1699 tk_update_sleep_time(tk, timespec64_to_ktime(*delta)); in __timekeeping_inject_sleeptime()
1752 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_inject_sleeptime64() local
1760 timekeeping_forward_now(tk); in timekeeping_inject_sleeptime64()
1762 __timekeeping_inject_sleeptime(tk, delta); in timekeeping_inject_sleeptime64()
1764 timekeeping_update(tk, TK_CLEAR_NTP | TK_MIRROR | TK_CLOCK_WAS_SET); in timekeeping_inject_sleeptime64()
1779 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_resume() local
1780 struct clocksource *clock = tk->tkr_mono.clock; in timekeeping_resume()
1806 cycle_now = tk_clock_read(&tk->tkr_mono); in timekeeping_resume()
1818 __timekeeping_inject_sleeptime(tk, &ts_delta); in timekeeping_resume()
1822 tk->tkr_mono.cycle_last = cycle_now; in timekeeping_resume()
1823 tk->tkr_raw.cycle_last = cycle_now; in timekeeping_resume()
1825 tk->ntp_error = 0; in timekeeping_resume()
1827 timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); in timekeeping_resume()
1841 struct timekeeper *tk = &tk_core.timekeeper; in timekeeping_suspend() local
1862 timekeeping_forward_now(tk); in timekeeping_suspend()
1870 curr_clock = tk->tkr_mono.clock; in timekeeping_suspend()
1871 cycle_now = tk->tkr_mono.cycle_last; in timekeeping_suspend()
1881 delta = timespec64_sub(tk_xtime(tk), timekeeping_suspend_time); in timekeeping_suspend()
1896 timekeeping_update(tk, TK_MIRROR); in timekeeping_suspend()
1897 halt_fast_timekeeper(tk); in timekeeping_suspend()
1924 static __always_inline void timekeeping_apply_adjustment(struct timekeeper *tk, in timekeeping_apply_adjustment() argument
1928 s64 interval = tk->cycle_interval; in timekeeping_apply_adjustment()
1987 if ((mult_adj > 0) && (tk->tkr_mono.mult + mult_adj < mult_adj)) { in timekeeping_apply_adjustment()
1993 tk->tkr_mono.mult += mult_adj; in timekeeping_apply_adjustment()
1994 tk->xtime_interval += interval; in timekeeping_apply_adjustment()
1995 tk->tkr_mono.xtime_nsec -= offset; in timekeeping_apply_adjustment()
2002 static void timekeeping_adjust(struct timekeeper *tk, s64 offset) in timekeeping_adjust() argument
2010 if (likely(tk->ntp_tick == ntp_tick_length())) { in timekeeping_adjust()
2011 mult = tk->tkr_mono.mult - tk->ntp_err_mult; in timekeeping_adjust()
2013 tk->ntp_tick = ntp_tick_length(); in timekeeping_adjust()
2014 mult = div64_u64((tk->ntp_tick >> tk->ntp_error_shift) - in timekeeping_adjust()
2015 tk->xtime_remainder, tk->cycle_interval); in timekeeping_adjust()
2024 tk->ntp_err_mult = tk->ntp_error > 0 ? 1 : 0; in timekeeping_adjust()
2025 mult += tk->ntp_err_mult; in timekeeping_adjust()
2027 timekeeping_apply_adjustment(tk, offset, mult - tk->tkr_mono.mult); in timekeeping_adjust()
2029 if (unlikely(tk->tkr_mono.clock->maxadj && in timekeeping_adjust()
2030 (abs(tk->tkr_mono.mult - tk->tkr_mono.clock->mult) in timekeeping_adjust()
2031 > tk->tkr_mono.clock->maxadj))) { in timekeeping_adjust()
2034 tk->tkr_mono.clock->name, (long)tk->tkr_mono.mult, in timekeeping_adjust()
2035 (long)tk->tkr_mono.clock->mult + tk->tkr_mono.clock->maxadj); in timekeeping_adjust()
2048 if (unlikely((s64)tk->tkr_mono.xtime_nsec < 0)) { in timekeeping_adjust()
2049 tk->tkr_mono.xtime_nsec += (u64)NSEC_PER_SEC << in timekeeping_adjust()
2050 tk->tkr_mono.shift; in timekeeping_adjust()
2051 tk->xtime_sec--; in timekeeping_adjust()
2052 tk->skip_second_overflow = 1; in timekeeping_adjust()
2063 static inline unsigned int accumulate_nsecs_to_secs(struct timekeeper *tk) in accumulate_nsecs_to_secs() argument
2065 u64 nsecps = (u64)NSEC_PER_SEC << tk->tkr_mono.shift; in accumulate_nsecs_to_secs()
2068 while (tk->tkr_mono.xtime_nsec >= nsecps) { in accumulate_nsecs_to_secs()
2071 tk->tkr_mono.xtime_nsec -= nsecps; in accumulate_nsecs_to_secs()
2072 tk->xtime_sec++; in accumulate_nsecs_to_secs()
2078 if (unlikely(tk->skip_second_overflow)) { in accumulate_nsecs_to_secs()
2079 tk->skip_second_overflow = 0; in accumulate_nsecs_to_secs()
2084 leap = second_overflow(tk->xtime_sec); in accumulate_nsecs_to_secs()
2088 tk->xtime_sec += leap; in accumulate_nsecs_to_secs()
2092 tk_set_wall_to_mono(tk, in accumulate_nsecs_to_secs()
2093 timespec64_sub(tk->wall_to_monotonic, ts)); in accumulate_nsecs_to_secs()
2095 __timekeeping_set_tai_offset(tk, tk->tai_offset - leap); in accumulate_nsecs_to_secs()
2112 static u64 logarithmic_accumulation(struct timekeeper *tk, u64 offset, in logarithmic_accumulation() argument
2115 u64 interval = tk->cycle_interval << shift; in logarithmic_accumulation()
2124 tk->tkr_mono.cycle_last += interval; in logarithmic_accumulation()
2125 tk->tkr_raw.cycle_last += interval; in logarithmic_accumulation()
2127 tk->tkr_mono.xtime_nsec += tk->xtime_interval << shift; in logarithmic_accumulation()
2128 *clock_set |= accumulate_nsecs_to_secs(tk); in logarithmic_accumulation()
2131 tk->tkr_raw.xtime_nsec += tk->raw_interval << shift; in logarithmic_accumulation()
2132 snsec_per_sec = (u64)NSEC_PER_SEC << tk->tkr_raw.shift; in logarithmic_accumulation()
2133 while (tk->tkr_raw.xtime_nsec >= snsec_per_sec) { in logarithmic_accumulation()
2134 tk->tkr_raw.xtime_nsec -= snsec_per_sec; in logarithmic_accumulation()
2135 tk->raw_sec++; in logarithmic_accumulation()
2139 tk->ntp_error += tk->ntp_tick << shift; in logarithmic_accumulation()
2140 tk->ntp_error -= (tk->xtime_interval + tk->xtime_remainder) << in logarithmic_accumulation()
2141 (tk->ntp_error_shift + shift); in logarithmic_accumulation()
2153 struct timekeeper *tk = &shadow_timekeeper; in timekeeping_advance() local
2165 offset = clocksource_delta(tk_clock_read(&tk->tkr_mono), in timekeeping_advance()
2166 tk->tkr_mono.cycle_last, tk->tkr_mono.mask); in timekeeping_advance()
2173 timekeeping_check_update(tk, offset); in timekeeping_advance()
2183 shift = ilog2(offset) - ilog2(tk->cycle_interval); in timekeeping_advance()
2188 while (offset >= tk->cycle_interval) { in timekeeping_advance()
2189 offset = logarithmic_accumulation(tk, offset, shift, in timekeeping_advance()
2191 if (offset < tk->cycle_interval<<shift) in timekeeping_advance()
2196 timekeeping_adjust(tk, offset); in timekeeping_advance()
2202 clock_set |= accumulate_nsecs_to_secs(tk); in timekeeping_advance()
2215 timekeeping_update(tk, clock_set); in timekeeping_advance()
2216 memcpy(real_tk, tk, sizeof(*tk)); in timekeeping_advance()
2248 struct timekeeper *tk = &tk_core.timekeeper; in getboottime64() local
2249 ktime_t t = ktime_sub(tk->offs_real, tk->offs_boot); in getboottime64()
2257 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_coarse_real_ts64() local
2263 *ts = tk_xtime(tk); in ktime_get_coarse_real_ts64()
2270 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_coarse_ts64() local
2277 now = tk_xtime(tk); in ktime_get_coarse_ts64()
2278 mono = tk->wall_to_monotonic; in ktime_get_coarse_ts64()
2311 struct timekeeper *tk = &tk_core.timekeeper; in ktime_get_update_offsets_now() local
2319 base = tk->tkr_mono.base; in ktime_get_update_offsets_now()
2320 nsecs = timekeeping_get_ns(&tk->tkr_mono); in ktime_get_update_offsets_now()
2323 if (*cwsseq != tk->clock_was_set_seq) { in ktime_get_update_offsets_now()
2324 *cwsseq = tk->clock_was_set_seq; in ktime_get_update_offsets_now()
2325 *offs_real = tk->offs_real; in ktime_get_update_offsets_now()
2326 *offs_boot = tk->offs_boot; in ktime_get_update_offsets_now()
2327 *offs_tai = tk->offs_tai; in ktime_get_update_offsets_now()
2331 if (unlikely(base >= tk->next_leap_ktime)) in ktime_get_update_offsets_now()
2332 *offs_real = ktime_sub(tk->offs_real, ktime_set(1, 0)); in ktime_get_update_offsets_now()
2424 struct timekeeper *tk = &tk_core.timekeeper; in do_adjtimex() local
2459 orig_tai = tai = tk->tai_offset; in do_adjtimex()
2463 __timekeeping_set_tai_offset(tk, tai); in do_adjtimex()
2464 timekeeping_update(tk, TK_MIRROR | TK_CLOCK_WAS_SET); in do_adjtimex()
2467 tk_update_leap_state(tk); in do_adjtimex()