Lines Matching refs:cs
122 static void __clocksource_change_rating(struct clocksource *cs, int rating);
139 static void __clocksource_unstable(struct clocksource *cs) in __clocksource_unstable() argument
141 cs->flags &= ~(CLOCK_SOURCE_VALID_FOR_HRES | CLOCK_SOURCE_WATCHDOG); in __clocksource_unstable()
142 cs->flags |= CLOCK_SOURCE_UNSTABLE; in __clocksource_unstable()
156 void clocksource_mark_unstable(struct clocksource *cs) in clocksource_mark_unstable() argument
161 if (!(cs->flags & CLOCK_SOURCE_UNSTABLE)) { in clocksource_mark_unstable()
162 if (list_empty(&cs->wd_list)) in clocksource_mark_unstable()
163 list_add(&cs->wd_list, &watchdog_list); in clocksource_mark_unstable()
164 __clocksource_unstable(cs); in clocksource_mark_unstable()
171 struct clocksource *cs; in clocksource_watchdog() local
182 list_for_each_entry(cs, &watchdog_list, wd_list) { in clocksource_watchdog()
185 if (cs->flags & CLOCK_SOURCE_UNSTABLE) { in clocksource_watchdog()
192 csnow = cs->read(cs); in clocksource_watchdog()
197 if (!(cs->flags & CLOCK_SOURCE_WATCHDOG) || in clocksource_watchdog()
199 cs->flags |= CLOCK_SOURCE_WATCHDOG; in clocksource_watchdog()
200 cs->wd_last = wdnow; in clocksource_watchdog()
201 cs->cs_last = csnow; in clocksource_watchdog()
205 delta = clocksource_delta(wdnow, cs->wd_last, watchdog->mask); in clocksource_watchdog()
209 delta = clocksource_delta(csnow, cs->cs_last, cs->mask); in clocksource_watchdog()
210 cs_nsec = clocksource_cyc2ns(delta, cs->mult, cs->shift); in clocksource_watchdog()
211 wdlast = cs->wd_last; /* save these in case we print them */ in clocksource_watchdog()
212 cslast = cs->cs_last; in clocksource_watchdog()
213 cs->cs_last = csnow; in clocksource_watchdog()
214 cs->wd_last = wdnow; in clocksource_watchdog()
222 cs->name); in clocksource_watchdog()
226 cs->name, csnow, cslast, cs->mask); in clocksource_watchdog()
227 __clocksource_unstable(cs); in clocksource_watchdog()
231 if (!(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES) && in clocksource_watchdog()
232 (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) && in clocksource_watchdog()
235 cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; in clocksource_watchdog()
252 if (cs != curr_clocksource) { in clocksource_watchdog()
253 cs->flags |= CLOCK_SOURCE_RESELECT; in clocksource_watchdog()
302 struct clocksource *cs; in clocksource_reset_watchdog() local
304 list_for_each_entry(cs, &watchdog_list, wd_list) in clocksource_reset_watchdog()
305 cs->flags &= ~CLOCK_SOURCE_WATCHDOG; in clocksource_reset_watchdog()
313 static void clocksource_enqueue_watchdog(struct clocksource *cs) in clocksource_enqueue_watchdog() argument
318 if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) { in clocksource_enqueue_watchdog()
320 list_add(&cs->wd_list, &watchdog_list); in clocksource_enqueue_watchdog()
321 cs->flags &= ~CLOCK_SOURCE_WATCHDOG; in clocksource_enqueue_watchdog()
324 if (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) in clocksource_enqueue_watchdog()
325 cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; in clocksource_enqueue_watchdog()
327 if (!watchdog || cs->rating > watchdog->rating) { in clocksource_enqueue_watchdog()
328 watchdog = cs; in clocksource_enqueue_watchdog()
338 static void clocksource_dequeue_watchdog(struct clocksource *cs) in clocksource_dequeue_watchdog() argument
343 if (cs != watchdog) { in clocksource_dequeue_watchdog()
344 if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) { in clocksource_dequeue_watchdog()
346 list_del_init(&cs->wd_list); in clocksource_dequeue_watchdog()
356 struct clocksource *cs, *tmp; in __clocksource_watchdog_kthread() local
362 list_for_each_entry_safe(cs, tmp, &watchdog_list, wd_list) { in __clocksource_watchdog_kthread()
363 if (cs->flags & CLOCK_SOURCE_UNSTABLE) { in __clocksource_watchdog_kthread()
364 list_del_init(&cs->wd_list); in __clocksource_watchdog_kthread()
365 list_add(&cs->wd_list, &unstable); in __clocksource_watchdog_kthread()
368 if (cs->flags & CLOCK_SOURCE_RESELECT) { in __clocksource_watchdog_kthread()
369 cs->flags &= ~CLOCK_SOURCE_RESELECT; in __clocksource_watchdog_kthread()
378 list_for_each_entry_safe(cs, tmp, &unstable, wd_list) { in __clocksource_watchdog_kthread()
379 list_del_init(&cs->wd_list); in __clocksource_watchdog_kthread()
380 __clocksource_change_rating(cs, 0); in __clocksource_watchdog_kthread()
394 static bool clocksource_is_watchdog(struct clocksource *cs) in clocksource_is_watchdog() argument
396 return cs == watchdog; in clocksource_is_watchdog()
401 static void clocksource_enqueue_watchdog(struct clocksource *cs) in clocksource_enqueue_watchdog() argument
403 if (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) in clocksource_enqueue_watchdog()
404 cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; in clocksource_enqueue_watchdog()
407 static inline void clocksource_dequeue_watchdog(struct clocksource *cs) { } in clocksource_dequeue_watchdog() argument
410 static bool clocksource_is_watchdog(struct clocksource *cs) { return false; } in clocksource_is_watchdog() argument
411 void clocksource_mark_unstable(struct clocksource *cs) { } in clocksource_mark_unstable() argument
420 struct clocksource *cs; in clocksource_suspend() local
422 list_for_each_entry_reverse(cs, &clocksource_list, list) in clocksource_suspend()
423 if (cs->suspend) in clocksource_suspend()
424 cs->suspend(cs); in clocksource_suspend()
432 struct clocksource *cs; in clocksource_resume() local
434 list_for_each_entry(cs, &clocksource_list, list) in clocksource_resume()
435 if (cs->resume) in clocksource_resume()
436 cs->resume(cs); in clocksource_resume()
458 static u32 clocksource_max_adjustment(struct clocksource *cs) in clocksource_max_adjustment() argument
464 ret = (u64)cs->mult * 11; in clocksource_max_adjustment()
519 static inline void clocksource_update_max_deferment(struct clocksource *cs) in clocksource_update_max_deferment() argument
521 cs->max_idle_ns = clocks_calc_max_nsecs(cs->mult, cs->shift, in clocksource_update_max_deferment()
522 cs->maxadj, cs->mask, in clocksource_update_max_deferment()
523 &cs->max_cycles); in clocksource_update_max_deferment()
530 struct clocksource *cs; in clocksource_find_best() local
540 list_for_each_entry(cs, &clocksource_list, list) { in clocksource_find_best()
541 if (skipcur && cs == curr_clocksource) in clocksource_find_best()
543 if (oneshot && !(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES)) in clocksource_find_best()
545 return cs; in clocksource_find_best()
553 struct clocksource *best, *cs; in __clocksource_select() local
561 list_for_each_entry(cs, &clocksource_list, list) { in __clocksource_select()
562 if (skipcur && cs == curr_clocksource) in __clocksource_select()
564 if (strcmp(cs->name, override_name) != 0) in __clocksource_select()
571 if (!(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES) && oneshot) { in __clocksource_select()
574 cs->name); in __clocksource_select()
578 best = cs; in __clocksource_select()
637 static void clocksource_enqueue(struct clocksource *cs) in clocksource_enqueue() argument
644 if (tmp->rating >= cs->rating) in clocksource_enqueue()
646 list_add(&cs->list, entry); in clocksource_enqueue()
661 void __clocksource_update_freq_scale(struct clocksource *cs, u32 scale, u32 freq) in __clocksource_update_freq_scale() argument
679 sec = cs->mask; in __clocksource_update_freq_scale()
684 else if (sec > 600 && cs->mask > UINT_MAX) in __clocksource_update_freq_scale()
687 clocks_calc_mult_shift(&cs->mult, &cs->shift, freq, in __clocksource_update_freq_scale()
694 cs->maxadj = clocksource_max_adjustment(cs); in __clocksource_update_freq_scale()
695 while (freq && ((cs->mult + cs->maxadj < cs->mult) in __clocksource_update_freq_scale()
696 || (cs->mult - cs->maxadj > cs->mult))) { in __clocksource_update_freq_scale()
697 cs->mult >>= 1; in __clocksource_update_freq_scale()
698 cs->shift--; in __clocksource_update_freq_scale()
699 cs->maxadj = clocksource_max_adjustment(cs); in __clocksource_update_freq_scale()
706 WARN_ONCE(cs->mult + cs->maxadj < cs->mult, in __clocksource_update_freq_scale()
708 cs->name); in __clocksource_update_freq_scale()
710 clocksource_update_max_deferment(cs); in __clocksource_update_freq_scale()
713 cs->name, cs->mask, cs->max_cycles, cs->max_idle_ns); in __clocksource_update_freq_scale()
728 int __clocksource_register_scale(struct clocksource *cs, u32 scale, u32 freq) in __clocksource_register_scale() argument
732 __clocksource_update_freq_scale(cs, scale, freq); in __clocksource_register_scale()
736 clocksource_enqueue(cs); in __clocksource_register_scale()
737 clocksource_enqueue_watchdog(cs); in __clocksource_register_scale()
744 static void __clocksource_change_rating(struct clocksource *cs, int rating) in __clocksource_change_rating() argument
746 list_del(&cs->list); in __clocksource_change_rating()
747 cs->rating = rating; in __clocksource_change_rating()
748 clocksource_enqueue(cs); in __clocksource_change_rating()
756 void clocksource_change_rating(struct clocksource *cs, int rating) in clocksource_change_rating() argument
759 __clocksource_change_rating(cs, rating); in clocksource_change_rating()
768 static int clocksource_unbind(struct clocksource *cs) in clocksource_unbind() argument
774 if (clocksource_is_watchdog(cs)) in clocksource_unbind()
777 if (cs == curr_clocksource) { in clocksource_unbind()
780 if (curr_clocksource == cs) in clocksource_unbind()
783 clocksource_dequeue_watchdog(cs); in clocksource_unbind()
784 list_del_init(&cs->list); in clocksource_unbind()
792 int clocksource_unregister(struct clocksource *cs) in clocksource_unregister() argument
797 if (!list_empty(&cs->list)) in clocksource_unregister()
798 ret = clocksource_unbind(cs); in clocksource_unregister()
883 struct clocksource *cs; in sysfs_unbind_clocksource() local
893 list_for_each_entry(cs, &clocksource_list, list) { in sysfs_unbind_clocksource()
894 if (strcmp(cs->name, name)) in sysfs_unbind_clocksource()
896 ret = clocksource_unbind(cs); in sysfs_unbind_clocksource()