Lines Matching refs:cs
136 static void __clocksource_change_rating(struct clocksource *cs, int rating);
162 static void __clocksource_unstable(struct clocksource *cs) in __clocksource_unstable() argument
164 cs->flags &= ~(CLOCK_SOURCE_VALID_FOR_HRES | CLOCK_SOURCE_WATCHDOG); in __clocksource_unstable()
165 cs->flags |= CLOCK_SOURCE_UNSTABLE; in __clocksource_unstable()
171 if (list_empty(&cs->list)) { in __clocksource_unstable()
172 cs->rating = 0; in __clocksource_unstable()
176 if (cs->mark_unstable) in __clocksource_unstable()
177 cs->mark_unstable(cs); in __clocksource_unstable()
191 void clocksource_mark_unstable(struct clocksource *cs) in clocksource_mark_unstable() argument
196 if (!(cs->flags & CLOCK_SOURCE_UNSTABLE)) { in clocksource_mark_unstable()
197 if (!list_empty(&cs->list) && list_empty(&cs->wd_list)) in clocksource_mark_unstable()
198 list_add(&cs->wd_list, &watchdog_list); in clocksource_mark_unstable()
199 __clocksource_unstable(cs); in clocksource_mark_unstable()
216 static enum wd_read_status cs_watchdog_read(struct clocksource *cs, u64 *csnow, u64 *wdnow) in cs_watchdog_read() argument
225 *csnow = cs->read(cs); in cs_watchdog_read()
264 cs->name, wd_delay); in cs_watchdog_read()
323 struct clocksource *cs = (struct clocksource *)csin; in clocksource_verify_one_cpu() local
325 csnow_mid = cs->read(cs); in clocksource_verify_one_cpu()
328 void clocksource_verify_percpu(struct clocksource *cs) in clocksource_verify_percpu() argument
345 pr_warn("Not enough CPUs to check clocksource '%s'.\n", cs->name); in clocksource_verify_percpu()
349 …pr_warn("Checking clocksource %s synchronization from CPU %d to CPUs %*pbl.\n", cs->name, testcpu,… in clocksource_verify_percpu()
353 csnow_begin = cs->read(cs); in clocksource_verify_percpu()
354 smp_call_function_single(cpu, clocksource_verify_one_cpu, cs, 1); in clocksource_verify_percpu()
355 csnow_end = cs->read(cs); in clocksource_verify_percpu()
356 delta = (s64)((csnow_mid - csnow_begin) & cs->mask); in clocksource_verify_percpu()
359 delta = (csnow_end - csnow_mid) & cs->mask; in clocksource_verify_percpu()
362 delta = clocksource_delta(csnow_end, csnow_begin, cs->mask); in clocksource_verify_percpu()
363 cs_nsec = clocksource_cyc2ns(delta, cs->mult, cs->shift); in clocksource_verify_percpu()
373 cpumask_pr_args(&cpus_ahead), testcpu, cs->name); in clocksource_verify_percpu()
376 cpumask_pr_args(&cpus_behind), testcpu, cs->name); in clocksource_verify_percpu()
379 testcpu, cs_nsec_min, cs_nsec_max, cs->name); in clocksource_verify_percpu()
385 struct clocksource *cs; in clocksource_reset_watchdog() local
387 list_for_each_entry(cs, &watchdog_list, wd_list) in clocksource_reset_watchdog()
388 cs->flags &= ~CLOCK_SOURCE_WATCHDOG; in clocksource_reset_watchdog()
397 struct clocksource *cs; in clocksource_watchdog() local
408 list_for_each_entry(cs, &watchdog_list, wd_list) { in clocksource_watchdog()
411 if (cs->flags & CLOCK_SOURCE_UNSTABLE) { in clocksource_watchdog()
417 read_ret = cs_watchdog_read(cs, &csnow, &wdnow); in clocksource_watchdog()
421 __clocksource_unstable(cs); in clocksource_watchdog()
444 if (!(cs->flags & CLOCK_SOURCE_WATCHDOG) || in clocksource_watchdog()
446 cs->flags |= CLOCK_SOURCE_WATCHDOG; in clocksource_watchdog()
447 cs->wd_last = wdnow; in clocksource_watchdog()
448 cs->cs_last = csnow; in clocksource_watchdog()
452 delta = clocksource_delta(wdnow, cs->wd_last, watchdog->mask); in clocksource_watchdog()
456 delta = clocksource_delta(csnow, cs->cs_last, cs->mask); in clocksource_watchdog()
457 cs_nsec = clocksource_cyc2ns(delta, cs->mult, cs->shift); in clocksource_watchdog()
458 wdlast = cs->wd_last; /* save these in case we print them */ in clocksource_watchdog()
459 cslast = cs->cs_last; in clocksource_watchdog()
460 cs->cs_last = csnow; in clocksource_watchdog()
461 cs->wd_last = wdnow; in clocksource_watchdog()
488 md = cs->uncertainty_margin + watchdog->uncertainty_margin; in clocksource_watchdog()
491 smp_processor_id(), cs->name); in clocksource_watchdog()
495 cs->name, cs_nsec, csnow, cslast, cs->mask); in clocksource_watchdog()
496 if (curr_clocksource == cs) in clocksource_watchdog()
497 pr_warn(" '%s' is current clocksource.\n", cs->name); in clocksource_watchdog()
499 … '%s' (not '%s') is current clocksource.\n", curr_clocksource->name, cs->name); in clocksource_watchdog()
502 __clocksource_unstable(cs); in clocksource_watchdog()
506 if (cs == curr_clocksource && cs->tick_stable) in clocksource_watchdog()
507 cs->tick_stable(cs); in clocksource_watchdog()
509 if (!(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES) && in clocksource_watchdog()
510 (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) && in clocksource_watchdog()
513 cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; in clocksource_watchdog()
530 if (cs != curr_clocksource) { in clocksource_watchdog()
531 cs->flags |= CLOCK_SOURCE_RESELECT; in clocksource_watchdog()
589 static void clocksource_enqueue_watchdog(struct clocksource *cs) in clocksource_enqueue_watchdog() argument
591 INIT_LIST_HEAD(&cs->wd_list); in clocksource_enqueue_watchdog()
593 if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) { in clocksource_enqueue_watchdog()
595 list_add(&cs->wd_list, &watchdog_list); in clocksource_enqueue_watchdog()
596 cs->flags &= ~CLOCK_SOURCE_WATCHDOG; in clocksource_enqueue_watchdog()
599 if (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) in clocksource_enqueue_watchdog()
600 cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; in clocksource_enqueue_watchdog()
606 struct clocksource *cs, *old_wd; in clocksource_select_watchdog() local
615 list_for_each_entry(cs, &clocksource_list, list) { in clocksource_select_watchdog()
617 if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) in clocksource_select_watchdog()
621 if (fallback && cs == old_wd) in clocksource_select_watchdog()
625 if (!watchdog || cs->rating > watchdog->rating) in clocksource_select_watchdog()
626 watchdog = cs; in clocksource_select_watchdog()
641 static void clocksource_dequeue_watchdog(struct clocksource *cs) in clocksource_dequeue_watchdog() argument
643 if (cs != watchdog) { in clocksource_dequeue_watchdog()
644 if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) { in clocksource_dequeue_watchdog()
646 list_del_init(&cs->wd_list); in clocksource_dequeue_watchdog()
655 struct clocksource *cs, *tmp; in __clocksource_watchdog_kthread() local
666 list_for_each_entry_safe(cs, tmp, &watchdog_list, wd_list) { in __clocksource_watchdog_kthread()
667 if (cs->flags & CLOCK_SOURCE_UNSTABLE) { in __clocksource_watchdog_kthread()
668 list_del_init(&cs->wd_list); in __clocksource_watchdog_kthread()
669 __clocksource_change_rating(cs, 0); in __clocksource_watchdog_kthread()
672 if (cs->flags & CLOCK_SOURCE_RESELECT) { in __clocksource_watchdog_kthread()
673 cs->flags &= ~CLOCK_SOURCE_RESELECT; in __clocksource_watchdog_kthread()
693 static bool clocksource_is_watchdog(struct clocksource *cs) in clocksource_is_watchdog() argument
695 return cs == watchdog; in clocksource_is_watchdog()
700 static void clocksource_enqueue_watchdog(struct clocksource *cs) in clocksource_enqueue_watchdog() argument
702 if (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) in clocksource_enqueue_watchdog()
703 cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; in clocksource_enqueue_watchdog()
707 static inline void clocksource_dequeue_watchdog(struct clocksource *cs) { } in clocksource_dequeue_watchdog() argument
710 static bool clocksource_is_watchdog(struct clocksource *cs) { return false; } in clocksource_is_watchdog() argument
711 void clocksource_mark_unstable(struct clocksource *cs) { } in clocksource_mark_unstable() argument
718 static bool clocksource_is_suspend(struct clocksource *cs) in clocksource_is_suspend() argument
720 return cs == suspend_clocksource; in clocksource_is_suspend()
723 static void __clocksource_suspend_select(struct clocksource *cs) in __clocksource_suspend_select() argument
728 if (!(cs->flags & CLOCK_SOURCE_SUSPEND_NONSTOP)) in __clocksource_suspend_select()
736 if (cs->suspend || cs->resume) { in __clocksource_suspend_select()
738 cs->name); in __clocksource_suspend_select()
742 if (!suspend_clocksource || cs->rating > suspend_clocksource->rating) in __clocksource_suspend_select()
743 suspend_clocksource = cs; in __clocksource_suspend_select()
752 struct clocksource *cs, *old_suspend; in clocksource_suspend_select() local
758 list_for_each_entry(cs, &clocksource_list, list) { in clocksource_suspend_select()
760 if (fallback && cs == old_suspend) in clocksource_suspend_select()
763 __clocksource_suspend_select(cs); in clocksource_suspend_select()
780 void clocksource_start_suspend_timing(struct clocksource *cs, u64 start_cycles) in clocksource_start_suspend_timing() argument
790 if (clocksource_is_suspend(cs)) { in clocksource_start_suspend_timing()
818 u64 clocksource_stop_suspend_timing(struct clocksource *cs, u64 cycle_now) in clocksource_stop_suspend_timing() argument
830 if (clocksource_is_suspend(cs)) in clocksource_stop_suspend_timing()
846 if (!clocksource_is_suspend(cs) && suspend_clocksource->disable) in clocksource_stop_suspend_timing()
857 struct clocksource *cs; in clocksource_suspend() local
859 list_for_each_entry_reverse(cs, &clocksource_list, list) in clocksource_suspend()
860 if (cs->suspend) in clocksource_suspend()
861 cs->suspend(cs); in clocksource_suspend()
869 struct clocksource *cs; in clocksource_resume() local
871 list_for_each_entry(cs, &clocksource_list, list) in clocksource_resume()
872 if (cs->resume) in clocksource_resume()
873 cs->resume(cs); in clocksource_resume()
895 static u32 clocksource_max_adjustment(struct clocksource *cs) in clocksource_max_adjustment() argument
901 ret = (u64)cs->mult * 11; in clocksource_max_adjustment()
956 static inline void clocksource_update_max_deferment(struct clocksource *cs) in clocksource_update_max_deferment() argument
958 cs->max_idle_ns = clocks_calc_max_nsecs(cs->mult, cs->shift, in clocksource_update_max_deferment()
959 cs->maxadj, cs->mask, in clocksource_update_max_deferment()
960 &cs->max_cycles); in clocksource_update_max_deferment()
965 struct clocksource *cs; in clocksource_find_best() local
975 list_for_each_entry(cs, &clocksource_list, list) { in clocksource_find_best()
976 if (skipcur && cs == curr_clocksource) in clocksource_find_best()
978 if (oneshot && !(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES)) in clocksource_find_best()
980 return cs; in clocksource_find_best()
988 struct clocksource *best, *cs; in __clocksource_select() local
999 list_for_each_entry(cs, &clocksource_list, list) { in __clocksource_select()
1000 if (skipcur && cs == curr_clocksource) in __clocksource_select()
1002 if (strcmp(cs->name, override_name) != 0) in __clocksource_select()
1009 if (!(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES) && oneshot) { in __clocksource_select()
1011 if (cs->flags & CLOCK_SOURCE_UNSTABLE) { in __clocksource_select()
1013 cs->name); in __clocksource_select()
1021 cs->name); in __clocksource_select()
1025 best = cs; in __clocksource_select()
1079 static void clocksource_enqueue(struct clocksource *cs) in clocksource_enqueue() argument
1086 if (tmp->rating < cs->rating) in clocksource_enqueue()
1090 list_add(&cs->list, entry); in clocksource_enqueue()
1105 void __clocksource_update_freq_scale(struct clocksource *cs, u32 scale, u32 freq) in __clocksource_update_freq_scale() argument
1123 sec = cs->mask; in __clocksource_update_freq_scale()
1128 else if (sec > 600 && cs->mask > UINT_MAX) in __clocksource_update_freq_scale()
1131 clocks_calc_mult_shift(&cs->mult, &cs->shift, freq, in __clocksource_update_freq_scale()
1145 if (scale && freq && !cs->uncertainty_margin) { in __clocksource_update_freq_scale()
1146 cs->uncertainty_margin = NSEC_PER_SEC / (scale * freq); in __clocksource_update_freq_scale()
1147 if (cs->uncertainty_margin < 2 * WATCHDOG_MAX_SKEW) in __clocksource_update_freq_scale()
1148 cs->uncertainty_margin = 2 * WATCHDOG_MAX_SKEW; in __clocksource_update_freq_scale()
1149 } else if (!cs->uncertainty_margin) { in __clocksource_update_freq_scale()
1150 cs->uncertainty_margin = WATCHDOG_THRESHOLD; in __clocksource_update_freq_scale()
1152 WARN_ON_ONCE(cs->uncertainty_margin < 2 * WATCHDOG_MAX_SKEW); in __clocksource_update_freq_scale()
1158 cs->maxadj = clocksource_max_adjustment(cs); in __clocksource_update_freq_scale()
1159 while (freq && ((cs->mult + cs->maxadj < cs->mult) in __clocksource_update_freq_scale()
1160 || (cs->mult - cs->maxadj > cs->mult))) { in __clocksource_update_freq_scale()
1161 cs->mult >>= 1; in __clocksource_update_freq_scale()
1162 cs->shift--; in __clocksource_update_freq_scale()
1163 cs->maxadj = clocksource_max_adjustment(cs); in __clocksource_update_freq_scale()
1170 WARN_ONCE(cs->mult + cs->maxadj < cs->mult, in __clocksource_update_freq_scale()
1172 cs->name); in __clocksource_update_freq_scale()
1174 clocksource_update_max_deferment(cs); in __clocksource_update_freq_scale()
1177 cs->name, cs->mask, cs->max_cycles, cs->max_idle_ns); in __clocksource_update_freq_scale()
1192 int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq) in __clocksource_register_scale() argument
1196 clocksource_arch_init(cs); in __clocksource_register_scale()
1198 if (WARN_ON_ONCE((unsigned int)cs->id >= CSID_MAX)) in __clocksource_register_scale()
1199 cs->id = CSID_GENERIC; in __clocksource_register_scale()
1200 if (cs->vdso_clock_mode < 0 || in __clocksource_register_scale()
1201 cs->vdso_clock_mode >= VDSO_CLOCKMODE_MAX) { in __clocksource_register_scale()
1203 cs->name, cs->vdso_clock_mode); in __clocksource_register_scale()
1204 cs->vdso_clock_mode = VDSO_CLOCKMODE_NONE; in __clocksource_register_scale()
1208 __clocksource_update_freq_scale(cs, scale, freq); in __clocksource_register_scale()
1214 clocksource_enqueue(cs); in __clocksource_register_scale()
1215 clocksource_enqueue_watchdog(cs); in __clocksource_register_scale()
1220 __clocksource_suspend_select(cs); in __clocksource_register_scale()
1226 static void __clocksource_change_rating(struct clocksource *cs, int rating) in __clocksource_change_rating() argument
1228 list_del(&cs->list); in __clocksource_change_rating()
1229 cs->rating = rating; in __clocksource_change_rating()
1230 clocksource_enqueue(cs); in __clocksource_change_rating()
1238 void clocksource_change_rating(struct clocksource *cs, int rating) in clocksource_change_rating() argument
1244 __clocksource_change_rating(cs, rating); in clocksource_change_rating()
1257 static int clocksource_unbind(struct clocksource *cs) in clocksource_unbind() argument
1261 if (clocksource_is_watchdog(cs)) { in clocksource_unbind()
1264 if (clocksource_is_watchdog(cs)) in clocksource_unbind()
1268 if (cs == curr_clocksource) { in clocksource_unbind()
1271 if (curr_clocksource == cs) in clocksource_unbind()
1275 if (clocksource_is_suspend(cs)) { in clocksource_unbind()
1285 clocksource_dequeue_watchdog(cs); in clocksource_unbind()
1286 list_del_init(&cs->list); in clocksource_unbind()
1296 int clocksource_unregister(struct clocksource *cs) in clocksource_unregister() argument
1301 if (!list_empty(&cs->list)) in clocksource_unregister()
1302 ret = clocksource_unbind(cs); in clocksource_unregister()
1388 struct clocksource *cs; in unbind_clocksource_store() local
1398 list_for_each_entry(cs, &clocksource_list, list) { in unbind_clocksource_store()
1399 if (strcmp(cs->name, name)) in unbind_clocksource_store()
1401 ret = clocksource_unbind(cs); in unbind_clocksource_store()