Lines Matching refs:cs

149 static void __clocksource_change_rating(struct clocksource *cs, int rating);
169 static void __clocksource_unstable(struct clocksource *cs) in __clocksource_unstable() argument
171 cs->flags &= ~(CLOCK_SOURCE_VALID_FOR_HRES | CLOCK_SOURCE_WATCHDOG); in __clocksource_unstable()
172 cs->flags |= CLOCK_SOURCE_UNSTABLE; in __clocksource_unstable()
178 if (list_empty(&cs->list)) { in __clocksource_unstable()
179 cs->rating = 0; in __clocksource_unstable()
183 if (cs->mark_unstable) in __clocksource_unstable()
184 cs->mark_unstable(cs); in __clocksource_unstable()
198 void clocksource_mark_unstable(struct clocksource *cs) in clocksource_mark_unstable() argument
203 if (!(cs->flags & CLOCK_SOURCE_UNSTABLE)) { in clocksource_mark_unstable()
204 if (!list_empty(&cs->list) && list_empty(&cs->wd_list)) in clocksource_mark_unstable()
205 list_add(&cs->wd_list, &watchdog_list); in clocksource_mark_unstable()
206 __clocksource_unstable(cs); in clocksource_mark_unstable()
223 static enum wd_read_status cs_watchdog_read(struct clocksource *cs, u64 *csnow, u64 *wdnow) in cs_watchdog_read() argument
232 *csnow = cs->read(cs); in cs_watchdog_read()
264 smp_processor_id(), cs->name, wd_delay, WATCHDOG_MAX_SKEW, wd_seq_delay, nretries, cs->name); in cs_watchdog_read()
271 cs->name, wd_delay); in cs_watchdog_read()
330 struct clocksource *cs = (struct clocksource *)csin; in clocksource_verify_one_cpu() local
332 csnow_mid = cs->read(cs); in clocksource_verify_one_cpu()
335 void clocksource_verify_percpu(struct clocksource *cs) in clocksource_verify_percpu() argument
352 pr_warn("Not enough CPUs to check clocksource '%s'.\n", cs->name); in clocksource_verify_percpu()
356 …pr_warn("Checking clocksource %s synchronization from CPU %d to CPUs %*pbl.\n", cs->name, testcpu,… in clocksource_verify_percpu()
360 csnow_begin = cs->read(cs); in clocksource_verify_percpu()
361 smp_call_function_single(cpu, clocksource_verify_one_cpu, cs, 1); in clocksource_verify_percpu()
362 csnow_end = cs->read(cs); in clocksource_verify_percpu()
363 delta = (s64)((csnow_mid - csnow_begin) & cs->mask); in clocksource_verify_percpu()
366 delta = (csnow_end - csnow_mid) & cs->mask; in clocksource_verify_percpu()
369 delta = clocksource_delta(csnow_end, csnow_begin, cs->mask); in clocksource_verify_percpu()
370 cs_nsec = clocksource_cyc2ns(delta, cs->mult, cs->shift); in clocksource_verify_percpu()
380 cpumask_pr_args(&cpus_ahead), testcpu, cs->name); in clocksource_verify_percpu()
383 cpumask_pr_args(&cpus_behind), testcpu, cs->name); in clocksource_verify_percpu()
386 testcpu, cs_nsec_min, cs_nsec_max, cs->name); in clocksource_verify_percpu()
392 struct clocksource *cs; in clocksource_reset_watchdog() local
394 list_for_each_entry(cs, &watchdog_list, wd_list) in clocksource_reset_watchdog()
395 cs->flags &= ~CLOCK_SOURCE_WATCHDOG; in clocksource_reset_watchdog()
404 struct clocksource *cs; in clocksource_watchdog() local
415 list_for_each_entry(cs, &watchdog_list, wd_list) { in clocksource_watchdog()
418 if (cs->flags & CLOCK_SOURCE_UNSTABLE) { in clocksource_watchdog()
424 read_ret = cs_watchdog_read(cs, &csnow, &wdnow); in clocksource_watchdog()
428 __clocksource_unstable(cs); in clocksource_watchdog()
451 if (!(cs->flags & CLOCK_SOURCE_WATCHDOG) || in clocksource_watchdog()
453 cs->flags |= CLOCK_SOURCE_WATCHDOG; in clocksource_watchdog()
454 cs->wd_last = wdnow; in clocksource_watchdog()
455 cs->cs_last = csnow; in clocksource_watchdog()
459 delta = clocksource_delta(wdnow, cs->wd_last, watchdog->mask); in clocksource_watchdog()
463 delta = clocksource_delta(csnow, cs->cs_last, cs->mask); in clocksource_watchdog()
464 cs_nsec = clocksource_cyc2ns(delta, cs->mult, cs->shift); in clocksource_watchdog()
465 wdlast = cs->wd_last; /* save these in case we print them */ in clocksource_watchdog()
466 cslast = cs->cs_last; in clocksource_watchdog()
467 cs->cs_last = csnow; in clocksource_watchdog()
468 cs->wd_last = wdnow; in clocksource_watchdog()
474 md = cs->uncertainty_margin + watchdog->uncertainty_margin; in clocksource_watchdog()
481 smp_processor_id(), cs->name); in clocksource_watchdog()
485 cs->name, cs_nsec, csnow, cslast, cs->mask); in clocksource_watchdog()
489 cs->name, cs_nsec - wd_nsec, cs_wd_msec, watchdog->name, wd_nsec, wd_msec); in clocksource_watchdog()
490 if (curr_clocksource == cs) in clocksource_watchdog()
491 pr_warn(" '%s' is current clocksource.\n", cs->name); in clocksource_watchdog()
493 … '%s' (not '%s') is current clocksource.\n", curr_clocksource->name, cs->name); in clocksource_watchdog()
496 __clocksource_unstable(cs); in clocksource_watchdog()
500 if (cs == curr_clocksource && cs->tick_stable) in clocksource_watchdog()
501 cs->tick_stable(cs); in clocksource_watchdog()
503 if (!(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES) && in clocksource_watchdog()
504 (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) && in clocksource_watchdog()
507 cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; in clocksource_watchdog()
524 if (cs != curr_clocksource) { in clocksource_watchdog()
525 cs->flags |= CLOCK_SOURCE_RESELECT; in clocksource_watchdog()
583 static void clocksource_enqueue_watchdog(struct clocksource *cs) in clocksource_enqueue_watchdog() argument
585 INIT_LIST_HEAD(&cs->wd_list); in clocksource_enqueue_watchdog()
587 if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) { in clocksource_enqueue_watchdog()
589 list_add(&cs->wd_list, &watchdog_list); in clocksource_enqueue_watchdog()
590 cs->flags &= ~CLOCK_SOURCE_WATCHDOG; in clocksource_enqueue_watchdog()
593 if (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) in clocksource_enqueue_watchdog()
594 cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; in clocksource_enqueue_watchdog()
600 struct clocksource *cs, *old_wd; in clocksource_select_watchdog() local
609 list_for_each_entry(cs, &clocksource_list, list) { in clocksource_select_watchdog()
611 if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) in clocksource_select_watchdog()
615 if (fallback && cs == old_wd) in clocksource_select_watchdog()
619 if (!watchdog || cs->rating > watchdog->rating) in clocksource_select_watchdog()
620 watchdog = cs; in clocksource_select_watchdog()
635 static void clocksource_dequeue_watchdog(struct clocksource *cs) in clocksource_dequeue_watchdog() argument
637 if (cs != watchdog) { in clocksource_dequeue_watchdog()
638 if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) { in clocksource_dequeue_watchdog()
640 list_del_init(&cs->wd_list); in clocksource_dequeue_watchdog()
649 struct clocksource *cs, *tmp; in __clocksource_watchdog_kthread() local
660 list_for_each_entry_safe(cs, tmp, &watchdog_list, wd_list) { in __clocksource_watchdog_kthread()
661 if (cs->flags & CLOCK_SOURCE_UNSTABLE) { in __clocksource_watchdog_kthread()
662 list_del_init(&cs->wd_list); in __clocksource_watchdog_kthread()
663 __clocksource_change_rating(cs, 0); in __clocksource_watchdog_kthread()
666 if (cs->flags & CLOCK_SOURCE_RESELECT) { in __clocksource_watchdog_kthread()
667 cs->flags &= ~CLOCK_SOURCE_RESELECT; in __clocksource_watchdog_kthread()
687 static bool clocksource_is_watchdog(struct clocksource *cs) in clocksource_is_watchdog() argument
689 return cs == watchdog; in clocksource_is_watchdog()
694 static void clocksource_enqueue_watchdog(struct clocksource *cs) in clocksource_enqueue_watchdog() argument
696 if (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) in clocksource_enqueue_watchdog()
697 cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; in clocksource_enqueue_watchdog()
701 static inline void clocksource_dequeue_watchdog(struct clocksource *cs) { } in clocksource_dequeue_watchdog() argument
704 static bool clocksource_is_watchdog(struct clocksource *cs) { return false; } in clocksource_is_watchdog() argument
705 void clocksource_mark_unstable(struct clocksource *cs) { } in clocksource_mark_unstable() argument
712 static bool clocksource_is_suspend(struct clocksource *cs) in clocksource_is_suspend() argument
714 return cs == suspend_clocksource; in clocksource_is_suspend()
717 static void __clocksource_suspend_select(struct clocksource *cs) in __clocksource_suspend_select() argument
722 if (!(cs->flags & CLOCK_SOURCE_SUSPEND_NONSTOP)) in __clocksource_suspend_select()
730 if (cs->suspend || cs->resume) { in __clocksource_suspend_select()
732 cs->name); in __clocksource_suspend_select()
736 if (!suspend_clocksource || cs->rating > suspend_clocksource->rating) in __clocksource_suspend_select()
737 suspend_clocksource = cs; in __clocksource_suspend_select()
746 struct clocksource *cs, *old_suspend; in clocksource_suspend_select() local
752 list_for_each_entry(cs, &clocksource_list, list) { in clocksource_suspend_select()
754 if (fallback && cs == old_suspend) in clocksource_suspend_select()
757 __clocksource_suspend_select(cs); in clocksource_suspend_select()
774 void clocksource_start_suspend_timing(struct clocksource *cs, u64 start_cycles) in clocksource_start_suspend_timing() argument
784 if (clocksource_is_suspend(cs)) { in clocksource_start_suspend_timing()
812 u64 clocksource_stop_suspend_timing(struct clocksource *cs, u64 cycle_now) in clocksource_stop_suspend_timing() argument
824 if (clocksource_is_suspend(cs)) in clocksource_stop_suspend_timing()
840 if (!clocksource_is_suspend(cs) && suspend_clocksource->disable) in clocksource_stop_suspend_timing()
851 struct clocksource *cs; in clocksource_suspend() local
853 list_for_each_entry_reverse(cs, &clocksource_list, list) in clocksource_suspend()
854 if (cs->suspend) in clocksource_suspend()
855 cs->suspend(cs); in clocksource_suspend()
863 struct clocksource *cs; in clocksource_resume() local
865 list_for_each_entry(cs, &clocksource_list, list) in clocksource_resume()
866 if (cs->resume) in clocksource_resume()
867 cs->resume(cs); in clocksource_resume()
889 static u32 clocksource_max_adjustment(struct clocksource *cs) in clocksource_max_adjustment() argument
895 ret = (u64)cs->mult * 11; in clocksource_max_adjustment()
950 static inline void clocksource_update_max_deferment(struct clocksource *cs) in clocksource_update_max_deferment() argument
952 cs->max_idle_ns = clocks_calc_max_nsecs(cs->mult, cs->shift, in clocksource_update_max_deferment()
953 cs->maxadj, cs->mask, in clocksource_update_max_deferment()
954 &cs->max_cycles); in clocksource_update_max_deferment()
959 struct clocksource *cs; in clocksource_find_best() local
969 list_for_each_entry(cs, &clocksource_list, list) { in clocksource_find_best()
970 if (skipcur && cs == curr_clocksource) in clocksource_find_best()
972 if (oneshot && !(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES)) in clocksource_find_best()
974 return cs; in clocksource_find_best()
982 struct clocksource *best, *cs; in __clocksource_select() local
993 list_for_each_entry(cs, &clocksource_list, list) { in __clocksource_select()
994 if (skipcur && cs == curr_clocksource) in __clocksource_select()
996 if (strcmp(cs->name, override_name) != 0) in __clocksource_select()
1003 if (!(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES) && oneshot) { in __clocksource_select()
1005 if (cs->flags & CLOCK_SOURCE_UNSTABLE) { in __clocksource_select()
1007 cs->name); in __clocksource_select()
1015 cs->name); in __clocksource_select()
1019 best = cs; in __clocksource_select()
1073 static void clocksource_enqueue(struct clocksource *cs) in clocksource_enqueue() argument
1080 if (tmp->rating < cs->rating) in clocksource_enqueue()
1084 list_add(&cs->list, entry); in clocksource_enqueue()
1099 void __clocksource_update_freq_scale(struct clocksource *cs, u32 scale, u32 freq) in __clocksource_update_freq_scale() argument
1117 sec = cs->mask; in __clocksource_update_freq_scale()
1122 else if (sec > 600 && cs->mask > UINT_MAX) in __clocksource_update_freq_scale()
1125 clocks_calc_mult_shift(&cs->mult, &cs->shift, freq, in __clocksource_update_freq_scale()
1139 if (scale && freq && !cs->uncertainty_margin) { in __clocksource_update_freq_scale()
1140 cs->uncertainty_margin = NSEC_PER_SEC / (scale * freq); in __clocksource_update_freq_scale()
1141 if (cs->uncertainty_margin < 2 * WATCHDOG_MAX_SKEW) in __clocksource_update_freq_scale()
1142 cs->uncertainty_margin = 2 * WATCHDOG_MAX_SKEW; in __clocksource_update_freq_scale()
1143 } else if (!cs->uncertainty_margin) { in __clocksource_update_freq_scale()
1144 cs->uncertainty_margin = WATCHDOG_THRESHOLD; in __clocksource_update_freq_scale()
1146 WARN_ON_ONCE(cs->uncertainty_margin < 2 * WATCHDOG_MAX_SKEW); in __clocksource_update_freq_scale()
1152 cs->maxadj = clocksource_max_adjustment(cs); in __clocksource_update_freq_scale()
1153 while (freq && ((cs->mult + cs->maxadj < cs->mult) in __clocksource_update_freq_scale()
1154 || (cs->mult - cs->maxadj > cs->mult))) { in __clocksource_update_freq_scale()
1155 cs->mult >>= 1; in __clocksource_update_freq_scale()
1156 cs->shift--; in __clocksource_update_freq_scale()
1157 cs->maxadj = clocksource_max_adjustment(cs); in __clocksource_update_freq_scale()
1164 WARN_ONCE(cs->mult + cs->maxadj < cs->mult, in __clocksource_update_freq_scale()
1166 cs->name); in __clocksource_update_freq_scale()
1168 clocksource_update_max_deferment(cs); in __clocksource_update_freq_scale()
1171 cs->name, cs->mask, cs->max_cycles, cs->max_idle_ns); in __clocksource_update_freq_scale()
1186 int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq) in __clocksource_register_scale() argument
1190 clocksource_arch_init(cs); in __clocksource_register_scale()
1192 if (WARN_ON_ONCE((unsigned int)cs->id >= CSID_MAX)) in __clocksource_register_scale()
1193 cs->id = CSID_GENERIC; in __clocksource_register_scale()
1194 if (cs->vdso_clock_mode < 0 || in __clocksource_register_scale()
1195 cs->vdso_clock_mode >= VDSO_CLOCKMODE_MAX) { in __clocksource_register_scale()
1197 cs->name, cs->vdso_clock_mode); in __clocksource_register_scale()
1198 cs->vdso_clock_mode = VDSO_CLOCKMODE_NONE; in __clocksource_register_scale()
1202 __clocksource_update_freq_scale(cs, scale, freq); in __clocksource_register_scale()
1208 clocksource_enqueue(cs); in __clocksource_register_scale()
1209 clocksource_enqueue_watchdog(cs); in __clocksource_register_scale()
1214 __clocksource_suspend_select(cs); in __clocksource_register_scale()
1220 static void __clocksource_change_rating(struct clocksource *cs, int rating) in __clocksource_change_rating() argument
1222 list_del(&cs->list); in __clocksource_change_rating()
1223 cs->rating = rating; in __clocksource_change_rating()
1224 clocksource_enqueue(cs); in __clocksource_change_rating()
1232 void clocksource_change_rating(struct clocksource *cs, int rating) in clocksource_change_rating() argument
1238 __clocksource_change_rating(cs, rating); in clocksource_change_rating()
1251 static int clocksource_unbind(struct clocksource *cs) in clocksource_unbind() argument
1255 if (clocksource_is_watchdog(cs)) { in clocksource_unbind()
1258 if (clocksource_is_watchdog(cs)) in clocksource_unbind()
1262 if (cs == curr_clocksource) { in clocksource_unbind()
1265 if (curr_clocksource == cs) in clocksource_unbind()
1269 if (clocksource_is_suspend(cs)) { in clocksource_unbind()
1279 clocksource_dequeue_watchdog(cs); in clocksource_unbind()
1280 list_del_init(&cs->list); in clocksource_unbind()
1290 int clocksource_unregister(struct clocksource *cs) in clocksource_unregister() argument
1295 if (!list_empty(&cs->list)) in clocksource_unregister()
1296 ret = clocksource_unbind(cs); in clocksource_unregister()
1382 struct clocksource *cs; in unbind_clocksource_store() local
1392 list_for_each_entry(cs, &clocksource_list, list) { in unbind_clocksource_store()
1393 if (strcmp(cs->name, name)) in unbind_clocksource_store()
1395 ret = clocksource_unbind(cs); in unbind_clocksource_store()