• Home
  • Raw
  • Download

Lines Matching +full:no +full:- +full:tick +full:- +full:in +full:- +full:suspend

13  * This program is distributed in the hope that it will be useful,
33 #include <linux/tick.h>
36 #include "tick-internal.h"
40 * clocks_calc_mult_shift - calculate mult/shift factors for scaled math of clocks
45 * @maxsec: guaranteed runtime conversion range in seconds
50 * @to and @from are frequency values in HZ. For clock sources @to is
54 * The @maxsec conversion range argument controls the time frame in
56 * calculated mult and shift factors. This guarantees that no 64bit
75 sftacc--; in clocks_calc_mult_shift()
82 for (sft = 32; sft > 0; sft--) { in clocks_calc_mult_shift()
94 /*[Clocksource internal variables]---------
98 * used to calculate the suspend time.
104 * Name of the user-specified clocksource.
154 * of the kernel, so there is no point in creating a more permanent in clocksource_watchdog_work()
165 cs->flags &= ~(CLOCK_SOURCE_VALID_FOR_HRES | CLOCK_SOURCE_WATCHDOG); in __clocksource_unstable()
166 cs->flags |= CLOCK_SOURCE_UNSTABLE; in __clocksource_unstable()
170 * re-rate and re-select. in __clocksource_unstable()
172 if (list_empty(&cs->list)) { in __clocksource_unstable()
173 cs->rating = 0; in __clocksource_unstable()
177 if (cs->mark_unstable) in __clocksource_unstable()
178 cs->mark_unstable(cs); in __clocksource_unstable()
186 * clocksource_mark_unstable - mark clocksource unstable via watchdog
190 * it defers demotion and re-selection to a kthread.
197 if (!(cs->flags & CLOCK_SOURCE_UNSTABLE)) { in clocksource_mark_unstable()
198 if (!list_empty(&cs->list) && list_empty(&cs->wd_list)) in clocksource_mark_unstable()
199 list_add(&cs->wd_list, &watchdog_list); in clocksource_mark_unstable()
221 if (cs->flags & CLOCK_SOURCE_UNSTABLE) { in clocksource_watchdog()
228 csnow = cs->read(cs); in clocksource_watchdog()
229 wdnow = watchdog->read(watchdog); in clocksource_watchdog()
233 if (!(cs->flags & CLOCK_SOURCE_WATCHDOG) || in clocksource_watchdog()
235 cs->flags |= CLOCK_SOURCE_WATCHDOG; in clocksource_watchdog()
236 cs->wd_last = wdnow; in clocksource_watchdog()
237 cs->cs_last = csnow; in clocksource_watchdog()
241 delta = clocksource_delta(wdnow, cs->wd_last, watchdog->mask); in clocksource_watchdog()
242 wd_nsec = clocksource_cyc2ns(delta, watchdog->mult, in clocksource_watchdog()
243 watchdog->shift); in clocksource_watchdog()
245 delta = clocksource_delta(csnow, cs->cs_last, cs->mask); in clocksource_watchdog()
246 cs_nsec = clocksource_cyc2ns(delta, cs->mult, cs->shift); in clocksource_watchdog()
247 wdlast = cs->wd_last; /* save these in case we print them */ in clocksource_watchdog()
248 cslast = cs->cs_last; in clocksource_watchdog()
249 cs->cs_last = csnow; in clocksource_watchdog()
250 cs->wd_last = wdnow; in clocksource_watchdog()
256 if (abs(cs_nsec - wd_nsec) > WATCHDOG_THRESHOLD) { in clocksource_watchdog()
258 smp_processor_id(), cs->name); in clocksource_watchdog()
260 watchdog->name, wdnow, wdlast, watchdog->mask); in clocksource_watchdog()
262 cs->name, csnow, cslast, cs->mask); in clocksource_watchdog()
267 if (cs == curr_clocksource && cs->tick_stable) in clocksource_watchdog()
268 cs->tick_stable(cs); in clocksource_watchdog()
270 if (!(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES) && in clocksource_watchdog()
271 (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) && in clocksource_watchdog()
272 (watchdog->flags & CLOCK_SOURCE_IS_CONTINUOUS)) { in clocksource_watchdog()
273 /* Mark it valid for high-res. */ in clocksource_watchdog()
274 cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; in clocksource_watchdog()
288 * clocksource let the tick code know about in clocksource_watchdog()
292 cs->flags |= CLOCK_SOURCE_RESELECT; in clocksource_watchdog()
350 cs->flags &= ~CLOCK_SOURCE_WATCHDOG; in clocksource_reset_watchdog()
360 INIT_LIST_HEAD(&cs->wd_list); in clocksource_enqueue_watchdog()
362 if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) { in clocksource_enqueue_watchdog()
364 list_add(&cs->wd_list, &watchdog_list); in clocksource_enqueue_watchdog()
365 cs->flags &= ~CLOCK_SOURCE_WATCHDOG; in clocksource_enqueue_watchdog()
368 if (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) in clocksource_enqueue_watchdog()
369 cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; in clocksource_enqueue_watchdog()
386 if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) in clocksource_select_watchdog()
394 if (!watchdog || cs->rating > watchdog->rating) in clocksource_select_watchdog()
413 if (cs->flags & CLOCK_SOURCE_MUST_VERIFY) { in clocksource_dequeue_watchdog()
415 list_del_init(&cs->wd_list); in clocksource_dequeue_watchdog()
430 if (cs->flags & CLOCK_SOURCE_UNSTABLE) { in __clocksource_watchdog_kthread()
431 list_del_init(&cs->wd_list); in __clocksource_watchdog_kthread()
435 if (cs->flags & CLOCK_SOURCE_RESELECT) { in __clocksource_watchdog_kthread()
436 cs->flags &= ~CLOCK_SOURCE_RESELECT; in __clocksource_watchdog_kthread()
465 if (cs->flags & CLOCK_SOURCE_IS_CONTINUOUS) in clocksource_enqueue_watchdog()
466 cs->flags |= CLOCK_SOURCE_VALID_FOR_HRES; in clocksource_enqueue_watchdog()
489 * Skip the clocksource which will be stopped in suspend state. in __clocksource_suspend_select()
491 if (!(cs->flags & CLOCK_SOURCE_SUSPEND_NONSTOP)) in __clocksource_suspend_select()
495 * The nonstop clocksource can be selected as the suspend clocksource to in __clocksource_suspend_select()
496 * calculate the suspend time, so it should not supply suspend/resume in __clocksource_suspend_select()
497 * interfaces to suspend the nonstop clocksource when system suspends. in __clocksource_suspend_select()
499 if (cs->suspend || cs->resume) { in __clocksource_suspend_select()
500 pr_warn("Nonstop clocksource %s should not supply suspend/resume interfaces\n", in __clocksource_suspend_select()
501 cs->name); in __clocksource_suspend_select()
505 if (!suspend_clocksource || cs->rating > suspend_clocksource->rating) in __clocksource_suspend_select()
510 * clocksource_suspend_select - Select the best clocksource for suspend timing
531 * clocksource_start_suspend_timing - Start measuring the suspend timing
535 * This function will save the start cycle values of suspend timer to calculate
536 * the suspend time when resuming system.
538 * This function is called late in the suspend process from timekeeping_suspend(),
539 * that means processes are freezed, non-boot cpus and interrupts are disabled
540 * now. It is therefore possible to start the suspend timer without taking the
549 * If current clocksource is the suspend timer, we should use the in clocksource_start_suspend_timing()
551 * from suspend timer. in clocksource_start_suspend_timing()
558 if (suspend_clocksource->enable && in clocksource_start_suspend_timing()
559 suspend_clocksource->enable(suspend_clocksource)) { in clocksource_start_suspend_timing()
560 pr_warn_once("Failed to enable the non-suspend-able clocksource.\n"); in clocksource_start_suspend_timing()
564 suspend_start = suspend_clocksource->read(suspend_clocksource); in clocksource_start_suspend_timing()
568 * clocksource_stop_suspend_timing - Stop measuring the suspend timing
572 * This function will calculate the suspend time from suspend timer.
574 * Returns nanoseconds since suspend started, 0 if no usable suspend clocksource.
576 * This function is called early in the resume process from timekeeping_resume(),
577 * that means there is only one cpu, no processes are running and the interrupts
578 * are disabled. It is therefore possible to stop the suspend timer without
589 * If current clocksource is the suspend timer, we should use the in clocksource_stop_suspend_timing()
591 * avoid same reading from suspend timer. in clocksource_stop_suspend_timing()
596 now = suspend_clocksource->read(suspend_clocksource); in clocksource_stop_suspend_timing()
600 suspend_clocksource->mask); in clocksource_stop_suspend_timing()
601 nsec = mul_u64_u32_shr(delta, suspend_clocksource->mult, in clocksource_stop_suspend_timing()
602 suspend_clocksource->shift); in clocksource_stop_suspend_timing()
606 * Disable the suspend timer to save power if current clocksource is in clocksource_stop_suspend_timing()
607 * not the suspend timer. in clocksource_stop_suspend_timing()
609 if (!clocksource_is_suspend(cs) && suspend_clocksource->disable) in clocksource_stop_suspend_timing()
610 suspend_clocksource->disable(suspend_clocksource); in clocksource_stop_suspend_timing()
616 * clocksource_suspend - suspend the clocksource(s)
623 if (cs->suspend) in clocksource_suspend()
624 cs->suspend(cs); in clocksource_suspend()
628 * clocksource_resume - resume the clocksource(s)
635 if (cs->resume) in clocksource_resume()
636 cs->resume(cs); in clocksource_resume()
642 * clocksource_touch_watchdog - Update watchdog
646 * was stopped in code which holds watchdog_lock.
654 * clocksource_max_adjustment- Returns max adjustment amount
664 ret = (u64)cs->mult * 11; in clocksource_max_adjustment()
670 * clocks_calc_max_nsecs - Returns maximum nanoseconds that can be converted
678 * NOTE: This function includes a safety margin of 50%, in other words, we
681 * delayed timers or bad hardware, which might result in time intervals that
690 * cyc2ns() function without overflowing a 64-bit result. in clocks_calc_max_nsecs()
702 max_nsecs = clocksource_cyc2ns(max_cycles, mult - maxadj, shift); in clocks_calc_max_nsecs()
715 * clocksource_update_max_deferment - Updates the clocksource max_idle_ns & max_cycles
721 cs->max_idle_ns = clocks_calc_max_nsecs(cs->mult, cs->shift, in clocksource_update_max_deferment()
722 cs->maxadj, cs->mask, in clocksource_update_max_deferment()
723 &cs->max_cycles); in clocksource_update_max_deferment()
743 if (oneshot && !(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES)) in clocksource_find_best()
767 if (strcmp(cs->name, override_name) != 0) in __clocksource_select()
770 * Check to make sure we don't switch to a non-highres in __clocksource_select()
771 * capable clocksource if the tick code is in oneshot in __clocksource_select()
774 if (!(cs->flags & CLOCK_SOURCE_VALID_FOR_HRES) && oneshot) { in __clocksource_select()
776 if (cs->flags & CLOCK_SOURCE_UNSTABLE) { in __clocksource_select()
777 …pr_warn("Override clocksource %s is unstable and not HRT compatible - cannot switch while in HRT/N… in __clocksource_select()
778 cs->name); in __clocksource_select()
785 pr_info("Override clocksource %s is not currently HRT compatible - deferring\n", in __clocksource_select()
786 cs->name); in __clocksource_select()
796 pr_info("Switched to clocksource %s\n", best->name); in __clocksource_select()
802 * clocksource_select - Select the best clocksource available
826 * clocksource_done_booting - Called near the end of core bootup
857 if (tmp->rating < cs->rating) in clocksource_enqueue()
859 entry = &tmp->list; in clocksource_enqueue()
861 list_add(&cs->list, entry); in clocksource_enqueue()
865 * __clocksource_update_freq_scale - Used update clocksource with new freq
870 * This should only be called from the clocksource->enable() method.
881 * Default clocksources are *special* and self-define their mult/shift. in __clocksource_update_freq_scale()
887 * wrapping around. For clocksources which have a mask > 32-bit in __clocksource_update_freq_scale()
890 * amount. That results in a shift value of 24 for a in __clocksource_update_freq_scale()
891 * clocksource with mask >= 40-bit and f >= 4GHz. That maps to in __clocksource_update_freq_scale()
894 sec = cs->mask; in __clocksource_update_freq_scale()
899 else if (sec > 600 && cs->mask > UINT_MAX) in __clocksource_update_freq_scale()
902 clocks_calc_mult_shift(&cs->mult, &cs->shift, freq, in __clocksource_update_freq_scale()
909 cs->maxadj = clocksource_max_adjustment(cs); in __clocksource_update_freq_scale()
910 while (freq && ((cs->mult + cs->maxadj < cs->mult) in __clocksource_update_freq_scale()
911 || (cs->mult - cs->maxadj > cs->mult))) { in __clocksource_update_freq_scale()
912 cs->mult >>= 1; in __clocksource_update_freq_scale()
913 cs->shift--; in __clocksource_update_freq_scale()
914 cs->maxadj = clocksource_max_adjustment(cs); in __clocksource_update_freq_scale()
918 * Only warn for *special* clocksources that self-define in __clocksource_update_freq_scale()
921 WARN_ONCE(cs->mult + cs->maxadj < cs->mult, in __clocksource_update_freq_scale()
923 cs->name); in __clocksource_update_freq_scale()
928 cs->name, cs->mask, cs->max_cycles, cs->max_idle_ns); in __clocksource_update_freq_scale()
933 * __clocksource_register_scale - Used to install new clocksources
938 * Returns -EBUSY if registration fails, zero otherwise.
968 list_del(&cs->list); in __clocksource_change_rating()
969 cs->rating = rating; in __clocksource_change_rating()
974 * clocksource_change_rating - Change the rating of a registered clocksource
1005 return -EBUSY; in clocksource_unbind()
1012 return -EBUSY; in clocksource_unbind()
1017 * Select and try to install a replacement suspend clocksource. in clocksource_unbind()
1018 * If no replacement suspend clocksource, we will just let the in clocksource_unbind()
1019 * clocksource go and have no suspend clocksource. in clocksource_unbind()
1026 list_del_init(&cs->list); in clocksource_unbind()
1033 * clocksource_unregister - remove a registered clocksource
1041 if (!list_empty(&cs->list)) in clocksource_unregister()
1050 * current_clocksource_show - sysfs interface for current clocksource
1064 count = snprintf(buf, PAGE_SIZE, "%s\n", curr_clocksource->name); in current_clocksource_show()
1076 return -EINVAL; in sysfs_get_uname()
1079 if (buf[cnt-1] == '\n') in sysfs_get_uname()
1080 cnt--; in sysfs_get_uname()
1088 * current_clocksource_store - interface for manually overriding clocksource
1116 * unbind_clocksource_store - interface for manually unbinding clocksource
1136 ret = -ENODEV; in unbind_clocksource_store()
1139 if (strcmp(cs->name, name)) in unbind_clocksource_store()
1151 * available_clocksource_show - sysfs interface for listing clocksource
1168 * Don't show non-HRES clocksource if the tick code is in available_clocksource_show()
1169 * in one shot mode (highres=on or nohz=on) in available_clocksource_show()
1172 (src->flags & CLOCK_SOURCE_VALID_FOR_HRES)) in available_clocksource_show()
1174 max((ssize_t)PAGE_SIZE - count, (ssize_t)0), in available_clocksource_show()
1175 "%s ", src->name); in available_clocksource_show()
1180 max((ssize_t)PAGE_SIZE - count, (ssize_t)0), "\n"); in available_clocksource_show()
1219 * boot_override_clocksource - boot clock override
1237 * boot_override_clock - Compatibility layer for deprecated boot option
1246 pr_warn("clock=pmtmr is deprecated - use clocksource=acpi_pm\n"); in boot_override_clock()
1249 pr_warn("clock= boot option is deprecated - use clocksource=xyz\n"); in boot_override_clock()