Lines Matching +full:cs +full:- +full:0

1 // SPDX-License-Identifier: GPL-2.0+
20 #include "tick-internal.h"
23 static noinline u64 cycles_to_nsec_safe(struct clocksource *cs, u64 start, u64 end) in cycles_to_nsec_safe() argument
25 u64 delta = clocksource_delta(end, start, cs->mask); in cycles_to_nsec_safe()
27 if (likely(delta < cs->max_cycles)) in cycles_to_nsec_safe()
28 return clocksource_cyc2ns(delta, cs->mult, cs->shift); in cycles_to_nsec_safe()
30 return mul_u64_u32_shr(delta, cs->mult, cs->shift); in cycles_to_nsec_safe()
34 * clocks_calc_mult_shift - calculate mult/shift factors for scaled math of clocks
69 sftacc--; in clocks_calc_mult_shift()
76 for (sft = 32; sft > 0; sft--) { in clocks_calc_mult_shift()
80 if ((tmp >> sftacc) == 0) in clocks_calc_mult_shift()
88 /*[Clocksource internal variables]---------
98 * Name of the user-specified clocksource.
116 * Also a default for cs->uncertainty_margin when registering clocks.
124 * a lower bound for cs->uncertainty_margin values when registering clocks.
161 static void __clocksource_change_rating(struct clocksource *cs, int rating);
181 static void __clocksource_unstable(struct clocksource *cs) in __clocksource_unstable() argument
183 cs->flags &= ~(CLOCK_SOURCE_VALID_FOR_HRES | CLOCK_SOURCE_WATCHDOG); in __clocksource_unstable()
184 cs->flags |= CLOCK_SOURCE_UNSTABLE; in __clocksource_unstable()
188 * re-rate and re-select. in __clocksource_unstable()
190 if (list_empty(&cs->list)) { in __clocksource_unstable()
191 cs->rating = 0; in __clocksource_unstable()
195 if (cs->mark_unstable) in __clocksource_unstable()
196 cs->mark_unstable(cs); in __clocksource_unstable()
204 * clocksource_mark_unstable - mark clocksource unstable via watchdog
205 * @cs: clocksource to be marked unstable
208 * it defers demotion and re-selection to a kthread.
210 void clocksource_mark_unstable(struct clocksource *cs) in clocksource_mark_unstable() argument
215 if (!(cs->flags & CLOCK_SOURCE_UNSTABLE)) { in clocksource_mark_unstable()
216 if (!list_empty(&cs->list) && list_empty(&cs->wd_list)) in clocksource_mark_unstable()
217 list_add(&cs->wd_list, &watchdog_list); in clocksource_mark_unstable()
218 __clocksource_unstable(cs); in clocksource_mark_unstable()
232 static enum wd_read_status cs_watchdog_read(struct clocksource *cs, u64 *csnow, u64 *wdnow) in cs_watchdog_read() argument
239 for (nretries = 0; nretries <= max_retries; nretries++) { in cs_watchdog_read()
241 *wdnow = watchdog->read(watchdog); in cs_watchdog_read()
242 *csnow = cs->read(cs); in cs_watchdog_read()
243 wd_end = watchdog->read(watchdog); in cs_watchdog_read()
244 wd_end2 = watchdog->read(watchdog); in cs_watchdog_read()
251 smp_processor_id(), watchdog->name, nretries); in cs_watchdog_read()
261 * If consecutive WD read-back delay > WATCHDOG_MAX_SKEW/2, in cs_watchdog_read()
270 …warn("timekeeping watchdog on CPU%d: wd-%s-wd excessive read-back delay of %lldns vs. limit of %ld… in cs_watchdog_read()
271 smp_processor_id(), cs->name, wd_delay, WATCHDOG_MAX_SKEW, wd_seq_delay, nretries, cs->name); in cs_watchdog_read()
275 pr_info("timekeeping watchdog on CPU%d: %s wd-wd read-back delay of %lldns\n", in cs_watchdog_read()
276 smp_processor_id(), watchdog->name, wd_seq_delay); in cs_watchdog_read()
277 pr_info("wd-%s-wd read-back delay of %lldns, clock-skew test skipped!\n", in cs_watchdog_read()
278 cs->name, wd_delay); in cs_watchdog_read()
291 if (n < 0) { in clocksource_verify_choose_cpus()
300 if (n == 0 || num_online_cpus() <= 1) in clocksource_verify_choose_cpus()
324 cpu = cpumask_next(cpu - 1, cpu_online_mask); in clocksource_verify_choose_cpus()
337 struct clocksource *cs = (struct clocksource *)csin; in clocksource_verify_one_cpu() local
339 csnow_mid = cs->read(cs); in clocksource_verify_one_cpu()
342 void clocksource_verify_percpu(struct clocksource *cs) in clocksource_verify_percpu() argument
344 int64_t cs_nsec, cs_nsec_max = 0, cs_nsec_min = LLONG_MAX; in clocksource_verify_percpu()
349 if (verify_n_cpus == 0) in clocksource_verify_percpu()
359 pr_warn("Not enough CPUs to check clocksource '%s'.\n", cs->name); in clocksource_verify_percpu()
363 …pr_warn("Checking clocksource %s synchronization from CPU %d to CPUs %*pbl.\n", cs->name, testcpu,… in clocksource_verify_percpu()
367 csnow_begin = cs->read(cs); in clocksource_verify_percpu()
368 smp_call_function_single(cpu, clocksource_verify_one_cpu, cs, 1); in clocksource_verify_percpu()
369 csnow_end = cs->read(cs); in clocksource_verify_percpu()
370 delta = (s64)((csnow_mid - csnow_begin) & cs->mask); in clocksource_verify_percpu()
371 if (delta < 0) in clocksource_verify_percpu()
373 delta = (csnow_end - csnow_mid) & cs->mask; in clocksource_verify_percpu()
374 if (delta < 0) in clocksource_verify_percpu()
376 cs_nsec = cycles_to_nsec_safe(cs, csnow_begin, csnow_end); in clocksource_verify_percpu()
386 cpumask_pr_args(&cpus_ahead), testcpu, cs->name); in clocksource_verify_percpu()
389 cpumask_pr_args(&cpus_behind), testcpu, cs->name); in clocksource_verify_percpu()
391 pr_warn(" CPU %d check durations %lldns - %lldns for clocksource %s.\n", in clocksource_verify_percpu()
392 testcpu, cs_nsec_min, cs_nsec_max, cs->name); in clocksource_verify_percpu()
398 struct clocksource *cs; in clocksource_reset_watchdog() local
400 list_for_each_entry(cs, &watchdog_list, wd_list) in clocksource_reset_watchdog()
401 cs->flags &= ~CLOCK_SOURCE_WATCHDOG; in clocksource_reset_watchdog()
410 struct clocksource *cs; in clocksource_watchdog() local
412 unsigned long extra_wait = 0; in clocksource_watchdog()
421 list_for_each_entry(cs, &watchdog_list, wd_list) { in clocksource_watchdog()
424 if (cs->flags & CLOCK_SOURCE_UNSTABLE) { in clocksource_watchdog()
430 read_ret = cs_watchdog_read(cs, &csnow, &wdnow); in clocksource_watchdog()
434 __clocksource_unstable(cs); in clocksource_watchdog()
448 * cs->last could keep unchanged for 5 minutes, reset in clocksource_watchdog()
457 if (!(cs->flags & CLOCK_SOURCE_WATCHDOG) || in clocksource_watchdog()
459 cs->flags |= CLOCK_SOURCE_WATCHDOG; in clocksource_watchdog()
460 cs->wd_last = wdnow; in clocksource_watchdog()
461 cs->cs_last = csnow; in clocksource_watchdog()
465 wd_nsec = cycles_to_nsec_safe(watchdog, cs->wd_last, wdnow); in clocksource_watchdog()
466 cs_nsec = cycles_to_nsec_safe(cs, cs->cs_last, csnow); in clocksource_watchdog()
467 wdlast = cs->wd_last; /* save these in case we print them */ in clocksource_watchdog()
468 cslast = cs->cs_last; in clocksource_watchdog()
469 cs->cs_last = csnow; in clocksource_watchdog()
470 cs->wd_last = wdnow; in clocksource_watchdog()
497 md = cs->uncertainty_margin + watchdog->uncertainty_margin; in clocksource_watchdog()
498 if (abs(cs_nsec - wd_nsec) > md) { in clocksource_watchdog()
504 smp_processor_id(), cs->name); in clocksource_watchdog()
506 watchdog->name, wd_nsec, wdnow, wdlast, watchdog->mask); in clocksource_watchdog()
508 cs->name, cs_nsec, csnow, cslast, cs->mask); in clocksource_watchdog()
509 cs_wd_msec = div_s64_rem(cs_nsec - wd_nsec, 1000 * 1000, &wd_rem); in clocksource_watchdog()
512 cs->name, cs_nsec - wd_nsec, cs_wd_msec, watchdog->name, wd_nsec, wd_msec); in clocksource_watchdog()
513 if (curr_clocksource == cs) in clocksource_watchdog()
514 pr_warn(" '%s' is current clocksource.\n", cs->name); in clocksource_watchdog()
516 … '%s' (not '%s') is current clocksource.\n", curr_clocksource->name, cs->name); in clocksource_watchdog()
519 __clocksource_unstable(cs); in clocksource_watchdog()
523 if (cs == curr_clocksource && cs->tick_stable) in clocksource_watchdog()
524 cs->tick_stable(cs); in clocksource_watchdog()
526 if (!(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES) && in clocksource_watchdog()
527 (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) && in clocksource_watchdog()
528 (watchdog->flags & CLOCK_SOURCE_IS_CONTINUOUS)) { in clocksource_watchdog()
529 /* Mark it valid for high-res. */ in clocksource_watchdog()
530 cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; in clocksource_watchdog()
547 if (cs != curr_clocksource) { in clocksource_watchdog()
548 cs->flags |= CLOCK_SOURCE_RESELECT; in clocksource_watchdog()
587 timer_setup(&watchdog_timer, clocksource_watchdog, 0); in clocksource_start_watchdog()
598 watchdog_running = 0; in clocksource_stop_watchdog()
606 static void clocksource_enqueue_watchdog(struct clocksource *cs) in clocksource_enqueue_watchdog() argument
608 INIT_LIST_HEAD(&cs->wd_list); in clocksource_enqueue_watchdog()
610 if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) { in clocksource_enqueue_watchdog()
611 /* cs is a clocksource to be watched. */ in clocksource_enqueue_watchdog()
612 list_add(&cs->wd_list, &watchdog_list); in clocksource_enqueue_watchdog()
613 cs->flags &= ~CLOCK_SOURCE_WATCHDOG; in clocksource_enqueue_watchdog()
615 /* cs is a watchdog. */ in clocksource_enqueue_watchdog()
616 if (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) in clocksource_enqueue_watchdog()
617 cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; in clocksource_enqueue_watchdog()
623 struct clocksource *cs, *old_wd; in clocksource_select_watchdog() local
632 list_for_each_entry(cs, &clocksource_list, list) { in clocksource_select_watchdog()
633 /* cs is a clocksource to be watched. */ in clocksource_select_watchdog()
634 if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) in clocksource_select_watchdog()
638 if (fallback && cs == old_wd) in clocksource_select_watchdog()
642 if (!watchdog || cs->rating > watchdog->rating) in clocksource_select_watchdog()
643 watchdog = cs; in clocksource_select_watchdog()
658 static void clocksource_dequeue_watchdog(struct clocksource *cs) in clocksource_dequeue_watchdog() argument
660 if (cs != watchdog) { in clocksource_dequeue_watchdog()
661 if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) { in clocksource_dequeue_watchdog()
662 /* cs is a watched clocksource. */ in clocksource_dequeue_watchdog()
663 list_del_init(&cs->wd_list); in clocksource_dequeue_watchdog()
672 struct clocksource *cs, *tmp; in __clocksource_watchdog_kthread() local
674 int select = 0; in __clocksource_watchdog_kthread()
676 /* Do any required per-CPU skew verification. */ in __clocksource_watchdog_kthread()
678 curr_clocksource->flags & CLOCK_SOURCE_UNSTABLE && in __clocksource_watchdog_kthread()
679 curr_clocksource->flags & CLOCK_SOURCE_VERIFY_PERCPU) in __clocksource_watchdog_kthread()
683 list_for_each_entry_safe(cs, tmp, &watchdog_list, wd_list) { in __clocksource_watchdog_kthread()
684 if (cs->flags & CLOCK_SOURCE_UNSTABLE) { in __clocksource_watchdog_kthread()
685 list_del_init(&cs->wd_list); in __clocksource_watchdog_kthread()
686 __clocksource_change_rating(cs, 0); in __clocksource_watchdog_kthread()
689 if (cs->flags & CLOCK_SOURCE_RESELECT) { in __clocksource_watchdog_kthread()
690 cs->flags &= ~CLOCK_SOURCE_RESELECT; in __clocksource_watchdog_kthread()
707 return 0; in clocksource_watchdog_kthread()
710 static bool clocksource_is_watchdog(struct clocksource *cs) in clocksource_is_watchdog() argument
712 return cs == watchdog; in clocksource_is_watchdog()
717 static void clocksource_enqueue_watchdog(struct clocksource *cs) in clocksource_enqueue_watchdog() argument
719 if (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) in clocksource_enqueue_watchdog()
720 cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; in clocksource_enqueue_watchdog()
724 static inline void clocksource_dequeue_watchdog(struct clocksource *cs) { } in clocksource_dequeue_watchdog() argument
726 static inline int __clocksource_watchdog_kthread(void) { return 0; } in __clocksource_watchdog_kthread()
727 static bool clocksource_is_watchdog(struct clocksource *cs) { return false; } in clocksource_is_watchdog() argument
728 void clocksource_mark_unstable(struct clocksource *cs) { } in clocksource_mark_unstable() argument
735 static bool clocksource_is_suspend(struct clocksource *cs) in clocksource_is_suspend() argument
737 return cs == suspend_clocksource; in clocksource_is_suspend()
740 static void __clocksource_suspend_select(struct clocksource *cs) in __clocksource_suspend_select() argument
745 if (!(cs->flags & CLOCK_SOURCE_SUSPEND_NONSTOP)) in __clocksource_suspend_select()
753 if (cs->suspend || cs->resume) { in __clocksource_suspend_select()
755 cs->name); in __clocksource_suspend_select()
759 if (!suspend_clocksource || cs->rating > suspend_clocksource->rating) in __clocksource_suspend_select()
760 suspend_clocksource = cs; in __clocksource_suspend_select()
764 * clocksource_suspend_select - Select the best clocksource for suspend timing
769 struct clocksource *cs, *old_suspend; in clocksource_suspend_select() local
775 list_for_each_entry(cs, &clocksource_list, list) { in clocksource_suspend_select()
777 if (fallback && cs == old_suspend) in clocksource_suspend_select()
780 __clocksource_suspend_select(cs); in clocksource_suspend_select()
785 * clocksource_start_suspend_timing - Start measuring the suspend timing
786 * @cs: current clocksource from timekeeping
793 * that means processes are frozen, non-boot cpus and interrupts are disabled
797 void clocksource_start_suspend_timing(struct clocksource *cs, u64 start_cycles) in clocksource_start_suspend_timing() argument
807 if (clocksource_is_suspend(cs)) { in clocksource_start_suspend_timing()
812 if (suspend_clocksource->enable && in clocksource_start_suspend_timing()
813 suspend_clocksource->enable(suspend_clocksource)) { in clocksource_start_suspend_timing()
814 pr_warn_once("Failed to enable the non-suspend-able clocksource.\n"); in clocksource_start_suspend_timing()
818 suspend_start = suspend_clocksource->read(suspend_clocksource); in clocksource_start_suspend_timing()
822 * clocksource_stop_suspend_timing - Stop measuring the suspend timing
823 * @cs: current clocksource from timekeeping
828 * Returns nanoseconds since suspend started, 0 if no usable suspend clocksource.
835 u64 clocksource_stop_suspend_timing(struct clocksource *cs, u64 cycle_now) in clocksource_stop_suspend_timing() argument
837 u64 now, nsec = 0; in clocksource_stop_suspend_timing()
840 return 0; in clocksource_stop_suspend_timing()
847 if (clocksource_is_suspend(cs)) in clocksource_stop_suspend_timing()
850 now = suspend_clocksource->read(suspend_clocksource); in clocksource_stop_suspend_timing()
859 if (!clocksource_is_suspend(cs) && suspend_clocksource->disable) in clocksource_stop_suspend_timing()
860 suspend_clocksource->disable(suspend_clocksource); in clocksource_stop_suspend_timing()
866 * clocksource_suspend - suspend the clocksource(s)
870 struct clocksource *cs; in clocksource_suspend() local
872 list_for_each_entry_reverse(cs, &clocksource_list, list) in clocksource_suspend()
873 if (cs->suspend) in clocksource_suspend()
874 cs->suspend(cs); in clocksource_suspend()
878 * clocksource_resume - resume the clocksource(s)
882 struct clocksource *cs; in clocksource_resume() local
884 list_for_each_entry(cs, &clocksource_list, list) in clocksource_resume()
885 if (cs->resume) in clocksource_resume()
886 cs->resume(cs); in clocksource_resume()
892 * clocksource_touch_watchdog - Update watchdog
904 * clocksource_max_adjustment- Returns max adjustment amount
905 * @cs: Pointer to clocksource
908 static u32 clocksource_max_adjustment(struct clocksource *cs) in clocksource_max_adjustment() argument
914 ret = (u64)cs->mult * 11; in clocksource_max_adjustment()
920 * clocks_calc_max_nsecs - Returns maximum nanoseconds that can be converted
940 * cyc2ns() function without overflowing a 64-bit result. in clocks_calc_max_nsecs()
952 max_nsecs = clocksource_cyc2ns(max_cycles, mult - maxadj, shift); in clocks_calc_max_nsecs()
965 * clocksource_update_max_deferment - Updates the clocksource max_idle_ns & max_cycles
966 * @cs: Pointer to clocksource to be updated
969 static inline void clocksource_update_max_deferment(struct clocksource *cs) in clocksource_update_max_deferment() argument
971 cs->max_idle_ns = clocks_calc_max_nsecs(cs->mult, cs->shift, in clocksource_update_max_deferment()
972 cs->maxadj, cs->mask, in clocksource_update_max_deferment()
973 &cs->max_cycles); in clocksource_update_max_deferment()
978 struct clocksource *cs; in clocksource_find_best() local
988 list_for_each_entry(cs, &clocksource_list, list) { in clocksource_find_best()
989 if (skipcur && cs == curr_clocksource) in clocksource_find_best()
991 if (oneshot && !(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES)) in clocksource_find_best()
993 return cs; in clocksource_find_best()
1001 struct clocksource *best, *cs; in __clocksource_select() local
1012 list_for_each_entry(cs, &clocksource_list, list) { in __clocksource_select()
1013 if (skipcur && cs == curr_clocksource) in __clocksource_select()
1015 if (strcmp(cs->name, override_name) != 0) in __clocksource_select()
1018 * Check to make sure we don't switch to a non-highres in __clocksource_select()
1022 if (!(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES) && oneshot) { in __clocksource_select()
1024 if (cs->flags & CLOCK_SOURCE_UNSTABLE) { in __clocksource_select()
1025 …pr_warn("Override clocksource %s is unstable and not HRT compatible - cannot switch while in HRT/N… in __clocksource_select()
1026 cs->name); in __clocksource_select()
1027 override_name[0] = 0; in __clocksource_select()
1033 pr_info("Override clocksource %s is not currently HRT compatible - deferring\n", in __clocksource_select()
1034 cs->name); in __clocksource_select()
1038 best = cs; in __clocksource_select()
1044 pr_info("Switched to clocksource %s\n", best->name); in __clocksource_select()
1050 * clocksource_select - Select the best clocksource available
1068 * clocksource_done_booting - Called near the end of core bootup
1085 return 0; in clocksource_done_booting()
1092 static void clocksource_enqueue(struct clocksource *cs) in clocksource_enqueue() argument
1099 if (tmp->rating < cs->rating) in clocksource_enqueue()
1101 entry = &tmp->list; in clocksource_enqueue()
1103 list_add(&cs->list, entry); in clocksource_enqueue()
1107 * __clocksource_update_freq_scale - Used update clocksource with new freq
1108 * @cs: clocksource to be registered
1112 * This should only be called from the clocksource->enable() method.
1118 void __clocksource_update_freq_scale(struct clocksource *cs, u32 scale, u32 freq) in __clocksource_update_freq_scale() argument
1123 * Default clocksources are *special* and self-define their mult/shift. in __clocksource_update_freq_scale()
1129 * wrapping around. For clocksources which have a mask > 32-bit in __clocksource_update_freq_scale()
1133 * clocksource with mask >= 40-bit and f >= 4GHz. That maps to in __clocksource_update_freq_scale()
1136 sec = cs->mask; in __clocksource_update_freq_scale()
1141 else if (sec > 600 && cs->mask > UINT_MAX) in __clocksource_update_freq_scale()
1144 clocks_calc_mult_shift(&cs->mult, &cs->shift, freq, in __clocksource_update_freq_scale()
1150 * If both scale and freq are non-zero, calculate the clock in __clocksource_update_freq_scale()
1153 * take the tens-of-milliseconds WATCHDOG_THRESHOLD value for the in __clocksource_update_freq_scale()
1158 if (scale && freq && !cs->uncertainty_margin) { in __clocksource_update_freq_scale()
1159 cs->uncertainty_margin = NSEC_PER_SEC / (scale * freq); in __clocksource_update_freq_scale()
1160 if (cs->uncertainty_margin < 2 * WATCHDOG_MAX_SKEW) in __clocksource_update_freq_scale()
1161 cs->uncertainty_margin = 2 * WATCHDOG_MAX_SKEW; in __clocksource_update_freq_scale()
1162 } else if (!cs->uncertainty_margin) { in __clocksource_update_freq_scale()
1163 cs->uncertainty_margin = WATCHDOG_THRESHOLD; in __clocksource_update_freq_scale()
1165 WARN_ON_ONCE(cs->uncertainty_margin < 2 * WATCHDOG_MAX_SKEW); in __clocksource_update_freq_scale()
1171 cs->maxadj = clocksource_max_adjustment(cs); in __clocksource_update_freq_scale()
1172 while (freq && ((cs->mult + cs->maxadj < cs->mult) in __clocksource_update_freq_scale()
1173 || (cs->mult - cs->maxadj > cs->mult))) { in __clocksource_update_freq_scale()
1174 cs->mult >>= 1; in __clocksource_update_freq_scale()
1175 cs->shift--; in __clocksource_update_freq_scale()
1176 cs->maxadj = clocksource_max_adjustment(cs); in __clocksource_update_freq_scale()
1180 * Only warn for *special* clocksources that self-define in __clocksource_update_freq_scale()
1183 WARN_ONCE(cs->mult + cs->maxadj < cs->mult, in __clocksource_update_freq_scale()
1185 cs->name); in __clocksource_update_freq_scale()
1187 clocksource_update_max_deferment(cs); in __clocksource_update_freq_scale()
1189 pr_info("%s: mask: 0x%llx max_cycles: 0x%llx, max_idle_ns: %lld ns\n", in __clocksource_update_freq_scale()
1190 cs->name, cs->mask, cs->max_cycles, cs->max_idle_ns); in __clocksource_update_freq_scale()
1195 * __clocksource_register_scale - Used to install new clocksources
1196 * @cs: clocksource to be registered
1200 * Returns -EBUSY if registration fails, zero otherwise.
1205 int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq) in __clocksource_register_scale() argument
1209 clocksource_arch_init(cs); in __clocksource_register_scale()
1211 if (WARN_ON_ONCE((unsigned int)cs->id >= CSID_MAX)) in __clocksource_register_scale()
1212 cs->id = CSID_GENERIC; in __clocksource_register_scale()
1213 if (cs->vdso_clock_mode < 0 || in __clocksource_register_scale()
1214 cs->vdso_clock_mode >= VDSO_CLOCKMODE_MAX) { in __clocksource_register_scale()
1216 cs->name, cs->vdso_clock_mode); in __clocksource_register_scale()
1217 cs->vdso_clock_mode = VDSO_CLOCKMODE_NONE; in __clocksource_register_scale()
1221 __clocksource_update_freq_scale(cs, scale, freq); in __clocksource_register_scale()
1227 clocksource_enqueue(cs); in __clocksource_register_scale()
1228 clocksource_enqueue_watchdog(cs); in __clocksource_register_scale()
1233 __clocksource_suspend_select(cs); in __clocksource_register_scale()
1235 return 0; in __clocksource_register_scale()
1239 static void __clocksource_change_rating(struct clocksource *cs, int rating) in __clocksource_change_rating() argument
1241 list_del(&cs->list); in __clocksource_change_rating()
1242 cs->rating = rating; in __clocksource_change_rating()
1243 clocksource_enqueue(cs); in __clocksource_change_rating()
1247 * clocksource_change_rating - Change the rating of a registered clocksource
1248 * @cs: clocksource to be changed
1251 void clocksource_change_rating(struct clocksource *cs, int rating) in clocksource_change_rating() argument
1257 __clocksource_change_rating(cs, rating); in clocksource_change_rating()
1268 * Unbind clocksource @cs. Called with clocksource_mutex held
1270 static int clocksource_unbind(struct clocksource *cs) in clocksource_unbind() argument
1274 if (clocksource_is_watchdog(cs)) { in clocksource_unbind()
1277 if (clocksource_is_watchdog(cs)) in clocksource_unbind()
1278 return -EBUSY; in clocksource_unbind()
1281 if (cs == curr_clocksource) { in clocksource_unbind()
1284 if (curr_clocksource == cs) in clocksource_unbind()
1285 return -EBUSY; in clocksource_unbind()
1288 if (clocksource_is_suspend(cs)) { in clocksource_unbind()
1298 clocksource_dequeue_watchdog(cs); in clocksource_unbind()
1299 list_del_init(&cs->list); in clocksource_unbind()
1302 return 0; in clocksource_unbind()
1306 * clocksource_unregister - remove a registered clocksource
1307 * @cs: clocksource to be unregistered
1309 int clocksource_unregister(struct clocksource *cs) in clocksource_unregister() argument
1311 int ret = 0; in clocksource_unregister()
1314 if (!list_empty(&cs->list)) in clocksource_unregister()
1315 ret = clocksource_unbind(cs); in clocksource_unregister()
1323 * current_clocksource_show - sysfs interface for current clocksource
1334 ssize_t count = 0; in current_clocksource_show()
1337 count = snprintf(buf, PAGE_SIZE, "%s\n", curr_clocksource->name); in current_clocksource_show()
1347 /* strings from sysfs write are not 0 terminated! */ in sysfs_get_uname()
1349 return -EINVAL; in sysfs_get_uname()
1352 if (buf[cnt-1] == '\n') in sysfs_get_uname()
1353 cnt--; in sysfs_get_uname()
1354 if (cnt > 0) in sysfs_get_uname()
1356 dst[cnt] = 0; in sysfs_get_uname()
1361 * current_clocksource_store - interface for manually overriding clocksource
1379 if (ret >= 0) in current_clocksource_store()
1389 * unbind_clocksource_store - interface for manually unbinding clocksource
1401 struct clocksource *cs; in unbind_clocksource_store() local
1406 if (ret < 0) in unbind_clocksource_store()
1409 ret = -ENODEV; in unbind_clocksource_store()
1411 list_for_each_entry(cs, &clocksource_list, list) { in unbind_clocksource_store()
1412 if (strcmp(cs->name, name)) in unbind_clocksource_store()
1414 ret = clocksource_unbind(cs); in unbind_clocksource_store()
1424 * available_clocksource_show - sysfs interface for listing clocksource
1436 ssize_t count = 0; in available_clocksource_show()
1441 * Don't show non-HRES clocksource if the tick code is in available_clocksource_show()
1445 (src->flags & CLOCK_SOURCE_VALID_FOR_HRES)) in available_clocksource_show()
1447 max((ssize_t)PAGE_SIZE - count, (ssize_t)0), in available_clocksource_show()
1448 "%s ", src->name); in available_clocksource_show()
1453 max((ssize_t)PAGE_SIZE - count, (ssize_t)0), "\n"); in available_clocksource_show()
1473 .id = 0,
1492 * boot_override_clocksource - boot clock override
1510 * boot_override_clock - Compatibility layer for deprecated boot option
1519 pr_warn("clock=pmtmr is deprecated - use clocksource=acpi_pm\n"); in boot_override_clock()
1522 pr_warn("clock= boot option is deprecated - use clocksource=xyz\n"); in boot_override_clock()