Lines Matching refs:cs
135 static void __clocksource_change_rating(struct clocksource *cs, int rating);
160 static void __clocksource_unstable(struct clocksource *cs) in __clocksource_unstable() argument
162 cs->flags &= ~(CLOCK_SOURCE_VALID_FOR_HRES | CLOCK_SOURCE_WATCHDOG); in __clocksource_unstable()
163 cs->flags |= CLOCK_SOURCE_UNSTABLE; in __clocksource_unstable()
169 if (list_empty(&cs->list)) { in __clocksource_unstable()
170 cs->rating = 0; in __clocksource_unstable()
174 if (cs->mark_unstable) in __clocksource_unstable()
175 cs->mark_unstable(cs); in __clocksource_unstable()
189 void clocksource_mark_unstable(struct clocksource *cs) in clocksource_mark_unstable() argument
194 if (!(cs->flags & CLOCK_SOURCE_UNSTABLE)) { in clocksource_mark_unstable()
195 if (!list_empty(&cs->list) && list_empty(&cs->wd_list)) in clocksource_mark_unstable()
196 list_add(&cs->wd_list, &watchdog_list); in clocksource_mark_unstable()
197 __clocksource_unstable(cs); in clocksource_mark_unstable()
208 static bool cs_watchdog_read(struct clocksource *cs, u64 *csnow, u64 *wdnow) in cs_watchdog_read() argument
217 *csnow = cs->read(cs); in cs_watchdog_read()
293 struct clocksource *cs = (struct clocksource *)csin; in clocksource_verify_one_cpu() local
295 csnow_mid = cs->read(cs); in clocksource_verify_one_cpu()
298 void clocksource_verify_percpu(struct clocksource *cs) in clocksource_verify_percpu() argument
315 pr_warn("Not enough CPUs to check clocksource '%s'.\n", cs->name); in clocksource_verify_percpu()
319 …pr_warn("Checking clocksource %s synchronization from CPU %d to CPUs %*pbl.\n", cs->name, testcpu,… in clocksource_verify_percpu()
323 csnow_begin = cs->read(cs); in clocksource_verify_percpu()
324 smp_call_function_single(cpu, clocksource_verify_one_cpu, cs, 1); in clocksource_verify_percpu()
325 csnow_end = cs->read(cs); in clocksource_verify_percpu()
326 delta = (s64)((csnow_mid - csnow_begin) & cs->mask); in clocksource_verify_percpu()
329 delta = (csnow_end - csnow_mid) & cs->mask; in clocksource_verify_percpu()
332 delta = clocksource_delta(csnow_end, csnow_begin, cs->mask); in clocksource_verify_percpu()
333 cs_nsec = clocksource_cyc2ns(delta, cs->mult, cs->shift); in clocksource_verify_percpu()
343 cpumask_pr_args(&cpus_ahead), testcpu, cs->name); in clocksource_verify_percpu()
346 cpumask_pr_args(&cpus_behind), testcpu, cs->name); in clocksource_verify_percpu()
349 testcpu, cs_nsec_min, cs_nsec_max, cs->name); in clocksource_verify_percpu()
358 struct clocksource *cs; in clocksource_watchdog() local
367 list_for_each_entry(cs, &watchdog_list, wd_list) { in clocksource_watchdog()
370 if (cs->flags & CLOCK_SOURCE_UNSTABLE) { in clocksource_watchdog()
376 if (!cs_watchdog_read(cs, &csnow, &wdnow)) { in clocksource_watchdog()
378 __clocksource_unstable(cs); in clocksource_watchdog()
383 if (!(cs->flags & CLOCK_SOURCE_WATCHDOG) || in clocksource_watchdog()
385 cs->flags |= CLOCK_SOURCE_WATCHDOG; in clocksource_watchdog()
386 cs->wd_last = wdnow; in clocksource_watchdog()
387 cs->cs_last = csnow; in clocksource_watchdog()
391 delta = clocksource_delta(wdnow, cs->wd_last, watchdog->mask); in clocksource_watchdog()
395 delta = clocksource_delta(csnow, cs->cs_last, cs->mask); in clocksource_watchdog()
396 cs_nsec = clocksource_cyc2ns(delta, cs->mult, cs->shift); in clocksource_watchdog()
397 wdlast = cs->wd_last; /* save these in case we print them */ in clocksource_watchdog()
398 cslast = cs->cs_last; in clocksource_watchdog()
399 cs->cs_last = csnow; in clocksource_watchdog()
400 cs->wd_last = wdnow; in clocksource_watchdog()
406 md = cs->uncertainty_margin + watchdog->uncertainty_margin; in clocksource_watchdog()
409 smp_processor_id(), cs->name); in clocksource_watchdog()
413 cs->name, cs_nsec, csnow, cslast, cs->mask); in clocksource_watchdog()
414 if (curr_clocksource == cs) in clocksource_watchdog()
415 pr_warn(" '%s' is current clocksource.\n", cs->name); in clocksource_watchdog()
417 … '%s' (not '%s') is current clocksource.\n", curr_clocksource->name, cs->name); in clocksource_watchdog()
420 __clocksource_unstable(cs); in clocksource_watchdog()
424 if (cs == curr_clocksource && cs->tick_stable) in clocksource_watchdog()
425 cs->tick_stable(cs); in clocksource_watchdog()
427 if (!(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES) && in clocksource_watchdog()
428 (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) && in clocksource_watchdog()
431 cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; in clocksource_watchdog()
448 if (cs != curr_clocksource) { in clocksource_watchdog()
449 cs->flags |= CLOCK_SOURCE_RESELECT; in clocksource_watchdog()
504 struct clocksource *cs; in clocksource_reset_watchdog() local
506 list_for_each_entry(cs, &watchdog_list, wd_list) in clocksource_reset_watchdog()
507 cs->flags &= ~CLOCK_SOURCE_WATCHDOG; in clocksource_reset_watchdog()
515 static void clocksource_enqueue_watchdog(struct clocksource *cs) in clocksource_enqueue_watchdog() argument
517 INIT_LIST_HEAD(&cs->wd_list); in clocksource_enqueue_watchdog()
519 if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) { in clocksource_enqueue_watchdog()
521 list_add(&cs->wd_list, &watchdog_list); in clocksource_enqueue_watchdog()
522 cs->flags &= ~CLOCK_SOURCE_WATCHDOG; in clocksource_enqueue_watchdog()
525 if (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) in clocksource_enqueue_watchdog()
526 cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; in clocksource_enqueue_watchdog()
532 struct clocksource *cs, *old_wd; in clocksource_select_watchdog() local
541 list_for_each_entry(cs, &clocksource_list, list) { in clocksource_select_watchdog()
543 if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) in clocksource_select_watchdog()
547 if (fallback && cs == old_wd) in clocksource_select_watchdog()
551 if (!watchdog || cs->rating > watchdog->rating) in clocksource_select_watchdog()
552 watchdog = cs; in clocksource_select_watchdog()
567 static void clocksource_dequeue_watchdog(struct clocksource *cs) in clocksource_dequeue_watchdog() argument
569 if (cs != watchdog) { in clocksource_dequeue_watchdog()
570 if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) { in clocksource_dequeue_watchdog()
572 list_del_init(&cs->wd_list); in clocksource_dequeue_watchdog()
581 struct clocksource *cs, *tmp; in __clocksource_watchdog_kthread() local
592 list_for_each_entry_safe(cs, tmp, &watchdog_list, wd_list) { in __clocksource_watchdog_kthread()
593 if (cs->flags & CLOCK_SOURCE_UNSTABLE) { in __clocksource_watchdog_kthread()
594 list_del_init(&cs->wd_list); in __clocksource_watchdog_kthread()
595 __clocksource_change_rating(cs, 0); in __clocksource_watchdog_kthread()
598 if (cs->flags & CLOCK_SOURCE_RESELECT) { in __clocksource_watchdog_kthread()
599 cs->flags &= ~CLOCK_SOURCE_RESELECT; in __clocksource_watchdog_kthread()
619 static bool clocksource_is_watchdog(struct clocksource *cs) in clocksource_is_watchdog() argument
621 return cs == watchdog; in clocksource_is_watchdog()
626 static void clocksource_enqueue_watchdog(struct clocksource *cs) in clocksource_enqueue_watchdog() argument
628 if (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) in clocksource_enqueue_watchdog()
629 cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; in clocksource_enqueue_watchdog()
633 static inline void clocksource_dequeue_watchdog(struct clocksource *cs) { } in clocksource_dequeue_watchdog() argument
636 static bool clocksource_is_watchdog(struct clocksource *cs) { return false; } in clocksource_is_watchdog() argument
637 void clocksource_mark_unstable(struct clocksource *cs) { } in clocksource_mark_unstable() argument
644 static bool clocksource_is_suspend(struct clocksource *cs) in clocksource_is_suspend() argument
646 return cs == suspend_clocksource; in clocksource_is_suspend()
649 static void __clocksource_suspend_select(struct clocksource *cs) in __clocksource_suspend_select() argument
654 if (!(cs->flags & CLOCK_SOURCE_SUSPEND_NONSTOP)) in __clocksource_suspend_select()
662 if (cs->suspend || cs->resume) { in __clocksource_suspend_select()
664 cs->name); in __clocksource_suspend_select()
668 if (!suspend_clocksource || cs->rating > suspend_clocksource->rating) in __clocksource_suspend_select()
669 suspend_clocksource = cs; in __clocksource_suspend_select()
678 struct clocksource *cs, *old_suspend; in clocksource_suspend_select() local
684 list_for_each_entry(cs, &clocksource_list, list) { in clocksource_suspend_select()
686 if (fallback && cs == old_suspend) in clocksource_suspend_select()
689 __clocksource_suspend_select(cs); in clocksource_suspend_select()
706 void clocksource_start_suspend_timing(struct clocksource *cs, u64 start_cycles) in clocksource_start_suspend_timing() argument
716 if (clocksource_is_suspend(cs)) { in clocksource_start_suspend_timing()
744 u64 clocksource_stop_suspend_timing(struct clocksource *cs, u64 cycle_now) in clocksource_stop_suspend_timing() argument
756 if (clocksource_is_suspend(cs)) in clocksource_stop_suspend_timing()
772 if (!clocksource_is_suspend(cs) && suspend_clocksource->disable) in clocksource_stop_suspend_timing()
783 struct clocksource *cs; in clocksource_suspend() local
785 list_for_each_entry_reverse(cs, &clocksource_list, list) in clocksource_suspend()
786 if (cs->suspend) in clocksource_suspend()
787 cs->suspend(cs); in clocksource_suspend()
795 struct clocksource *cs; in clocksource_resume() local
797 list_for_each_entry(cs, &clocksource_list, list) in clocksource_resume()
798 if (cs->resume) in clocksource_resume()
799 cs->resume(cs); in clocksource_resume()
821 static u32 clocksource_max_adjustment(struct clocksource *cs) in clocksource_max_adjustment() argument
827 ret = (u64)cs->mult * 11; in clocksource_max_adjustment()
882 static inline void clocksource_update_max_deferment(struct clocksource *cs) in clocksource_update_max_deferment() argument
884 cs->max_idle_ns = clocks_calc_max_nsecs(cs->mult, cs->shift, in clocksource_update_max_deferment()
885 cs->maxadj, cs->mask, in clocksource_update_max_deferment()
886 &cs->max_cycles); in clocksource_update_max_deferment()
891 struct clocksource *cs; in clocksource_find_best() local
901 list_for_each_entry(cs, &clocksource_list, list) { in clocksource_find_best()
902 if (skipcur && cs == curr_clocksource) in clocksource_find_best()
904 if (oneshot && !(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES)) in clocksource_find_best()
906 return cs; in clocksource_find_best()
914 struct clocksource *best, *cs; in __clocksource_select() local
925 list_for_each_entry(cs, &clocksource_list, list) { in __clocksource_select()
926 if (skipcur && cs == curr_clocksource) in __clocksource_select()
928 if (strcmp(cs->name, override_name) != 0) in __clocksource_select()
935 if (!(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES) && oneshot) { in __clocksource_select()
937 if (cs->flags & CLOCK_SOURCE_UNSTABLE) { in __clocksource_select()
939 cs->name); in __clocksource_select()
947 cs->name); in __clocksource_select()
951 best = cs; in __clocksource_select()
1005 static void clocksource_enqueue(struct clocksource *cs) in clocksource_enqueue() argument
1012 if (tmp->rating < cs->rating) in clocksource_enqueue()
1016 list_add(&cs->list, entry); in clocksource_enqueue()
1031 void __clocksource_update_freq_scale(struct clocksource *cs, u32 scale, u32 freq) in __clocksource_update_freq_scale() argument
1049 sec = cs->mask; in __clocksource_update_freq_scale()
1054 else if (sec > 600 && cs->mask > UINT_MAX) in __clocksource_update_freq_scale()
1057 clocks_calc_mult_shift(&cs->mult, &cs->shift, freq, in __clocksource_update_freq_scale()
1071 if (scale && freq && !cs->uncertainty_margin) { in __clocksource_update_freq_scale()
1072 cs->uncertainty_margin = NSEC_PER_SEC / (scale * freq); in __clocksource_update_freq_scale()
1073 if (cs->uncertainty_margin < 2 * WATCHDOG_MAX_SKEW) in __clocksource_update_freq_scale()
1074 cs->uncertainty_margin = 2 * WATCHDOG_MAX_SKEW; in __clocksource_update_freq_scale()
1075 } else if (!cs->uncertainty_margin) { in __clocksource_update_freq_scale()
1076 cs->uncertainty_margin = WATCHDOG_THRESHOLD; in __clocksource_update_freq_scale()
1078 WARN_ON_ONCE(cs->uncertainty_margin < 2 * WATCHDOG_MAX_SKEW); in __clocksource_update_freq_scale()
1084 cs->maxadj = clocksource_max_adjustment(cs); in __clocksource_update_freq_scale()
1085 while (freq && ((cs->mult + cs->maxadj < cs->mult) in __clocksource_update_freq_scale()
1086 || (cs->mult - cs->maxadj > cs->mult))) { in __clocksource_update_freq_scale()
1087 cs->mult >>= 1; in __clocksource_update_freq_scale()
1088 cs->shift--; in __clocksource_update_freq_scale()
1089 cs->maxadj = clocksource_max_adjustment(cs); in __clocksource_update_freq_scale()
1096 WARN_ONCE(cs->mult + cs->maxadj < cs->mult, in __clocksource_update_freq_scale()
1098 cs->name); in __clocksource_update_freq_scale()
1100 clocksource_update_max_deferment(cs); in __clocksource_update_freq_scale()
1103 cs->name, cs->mask, cs->max_cycles, cs->max_idle_ns); in __clocksource_update_freq_scale()
1118 int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq) in __clocksource_register_scale() argument
1122 clocksource_arch_init(cs); in __clocksource_register_scale()
1124 if (WARN_ON_ONCE((unsigned int)cs->id >= CSID_MAX)) in __clocksource_register_scale()
1125 cs->id = CSID_GENERIC; in __clocksource_register_scale()
1126 if (cs->vdso_clock_mode < 0 || in __clocksource_register_scale()
1127 cs->vdso_clock_mode >= VDSO_CLOCKMODE_MAX) { in __clocksource_register_scale()
1129 cs->name, cs->vdso_clock_mode); in __clocksource_register_scale()
1130 cs->vdso_clock_mode = VDSO_CLOCKMODE_NONE; in __clocksource_register_scale()
1134 __clocksource_update_freq_scale(cs, scale, freq); in __clocksource_register_scale()
1140 clocksource_enqueue(cs); in __clocksource_register_scale()
1141 clocksource_enqueue_watchdog(cs); in __clocksource_register_scale()
1146 __clocksource_suspend_select(cs); in __clocksource_register_scale()
1152 static void __clocksource_change_rating(struct clocksource *cs, int rating) in __clocksource_change_rating() argument
1154 list_del(&cs->list); in __clocksource_change_rating()
1155 cs->rating = rating; in __clocksource_change_rating()
1156 clocksource_enqueue(cs); in __clocksource_change_rating()
1164 void clocksource_change_rating(struct clocksource *cs, int rating) in clocksource_change_rating() argument
1170 __clocksource_change_rating(cs, rating); in clocksource_change_rating()
1183 static int clocksource_unbind(struct clocksource *cs) in clocksource_unbind() argument
1187 if (clocksource_is_watchdog(cs)) { in clocksource_unbind()
1190 if (clocksource_is_watchdog(cs)) in clocksource_unbind()
1194 if (cs == curr_clocksource) { in clocksource_unbind()
1197 if (curr_clocksource == cs) in clocksource_unbind()
1201 if (clocksource_is_suspend(cs)) { in clocksource_unbind()
1211 clocksource_dequeue_watchdog(cs); in clocksource_unbind()
1212 list_del_init(&cs->list); in clocksource_unbind()
1222 int clocksource_unregister(struct clocksource *cs) in clocksource_unregister() argument
1227 if (!list_empty(&cs->list)) in clocksource_unregister()
1228 ret = clocksource_unbind(cs); in clocksource_unregister()
1314 struct clocksource *cs; in unbind_clocksource_store() local
1324 list_for_each_entry(cs, &clocksource_list, list) { in unbind_clocksource_store()
1325 if (strcmp(cs->name, name)) in unbind_clocksource_store()
1327 ret = clocksource_unbind(cs); in unbind_clocksource_store()