Lines Matching +full:no +full:- +full:tick +full:- +full:in +full:- +full:suspend
1 // SPDX-License-Identifier: GPL-2.0
3 * This file contains the base functions to manage periodic tick
6 * Copyright(C) 2005-2006, Thomas Gleixner <tglx@linutronix.de>
7 * Copyright(C) 2005-2007, Red Hat, Inc., Ingo Molnar
8 * Copyright(C) 2006-2007, Timesys Corp., Thomas Gleixner
23 #include "tick-internal.h"
26 * Tick devices
30 * Tick next event: keeps track of the tick time. It's updated by the
31 * CPU which handles the tick and protected by jiffies_lock. There is
32 * no requirement to write hold the jiffies seqcount for it.
45 * 2) Hand off the duty in the NOHZ idle case by setting the value to
57 static int tick_do_timer_boot_cpu __read_mostly = -1;
69 * tick_is_oneshot_available - check for a oneshot capable event device
75 if (!dev || !(dev->features & CLOCK_EVT_FEAT_ONESHOT)) in tick_is_oneshot_available()
77 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) in tick_is_oneshot_available()
83 * Periodic tick
91 /* Keep track of the next tick event */ in tick_periodic()
110 ktime_t next = dev->next_event; in tick_handle_periodic()
117 * update_process_times() -> run_local_timers() -> in tick_handle_periodic()
120 if (dev->event_handler != tick_handle_periodic) in tick_handle_periodic()
136 * Have to be careful here. If we're in oneshot mode, in tick_handle_periodic()
137 * before we call tick_periodic() in a loop, we need in tick_handle_periodic()
139 * Otherwise we could get trapped in an infinite in tick_handle_periodic()
150 * Setup the device for a periodic tick
160 if ((dev->features & CLOCK_EVT_FEAT_PERIODIC) && in tick_setup_periodic()
183 * Setup the tick device
195 if (!td->evtdev) { in tick_setup_device()
197 * If no cpu took the do_timer update, assign it to in tick_setup_device()
205 * The boot CPU may be nohz_full, in which case the in tick_setup_device()
212 } else if (tick_do_timer_boot_cpu != -1 && !tick_nohz_full_cpu(cpu)) { in tick_setup_device()
213 tick_do_timer_boot_cpu = -1; in tick_setup_device()
215 * The boot CPU will stay in periodic (NOHZ disabled) in tick_setup_device()
221 * check in tick_periodic() but this race is harmless. in tick_setup_device()
228 * Startup in periodic mode first. in tick_setup_device()
230 td->mode = TICKDEV_MODE_PERIODIC; in tick_setup_device()
232 handler = td->evtdev->event_handler; in tick_setup_device()
233 next_event = td->evtdev->next_event; in tick_setup_device()
234 td->evtdev->event_handler = clockevents_handle_noop; in tick_setup_device()
237 td->evtdev = newdev; in tick_setup_device()
243 if (!cpumask_equal(newdev->cpumask, cpumask)) in tick_setup_device()
244 irq_set_affinity(newdev->irq, cpumask); in tick_setup_device()
249 * This allows us to handle this x86 misfeature in a generic in tick_setup_device()
256 if (td->mode == TICKDEV_MODE_PERIODIC) in tick_setup_device()
267 clockevents_exchange_device(td->evtdev, newdev); in tick_install_replacement()
269 if (newdev->features & CLOCK_EVT_FEAT_ONESHOT) in tick_install_replacement()
276 if (!cpumask_test_cpu(cpu, newdev->cpumask)) in tick_check_percpu()
278 if (cpumask_equal(newdev->cpumask, cpumask_of(cpu))) in tick_check_percpu()
281 if (newdev->irq >= 0 && !irq_can_set_affinity(newdev->irq)) in tick_check_percpu()
284 if (curdev && cpumask_equal(curdev->cpumask, cpumask_of(cpu))) in tick_check_percpu()
293 if (!(newdev->features & CLOCK_EVT_FEAT_ONESHOT)) { in tick_check_preferred()
294 if (curdev && (curdev->features & CLOCK_EVT_FEAT_ONESHOT)) in tick_check_preferred()
302 * rating than a non-CPU local device in tick_check_preferred()
305 newdev->rating > curdev->rating || in tick_check_preferred()
306 !cpumask_equal(curdev->cpumask, newdev->cpumask); in tick_check_preferred()
334 curdev = td->evtdev; in tick_check_new_device()
339 if (!try_module_get(newdev->owner)) in tick_check_new_device()
353 if (newdev->features & CLOCK_EVT_FEAT_ONESHOT) in tick_check_new_device()
365 * tick_broadcast_oneshot_control - Enter/exit broadcast oneshot mode
369 * Returns 0 on success, -EBUSY if the cpu is used to broadcast wakeups.
379 if (!(td->evtdev->features & CLOCK_EVT_FEAT_C3STOP)) in tick_broadcast_oneshot_control()
390 * Called with interrupts disabled. No locking required. If
409 struct clock_event_device *dev = td->evtdev; in tick_shutdown()
411 td->mode = TICKDEV_MODE_PERIODIC; in tick_shutdown()
419 dev->event_handler = clockevents_handle_noop; in tick_shutdown()
420 td->evtdev = NULL; in tick_shutdown()
426 * tick_suspend_local - Suspend the local tick device
430 * No locks required. Nothing can change the per cpu device.
436 clockevents_shutdown(td->evtdev); in tick_suspend_local()
440 * tick_resume_local - Resume the local tick device
444 * No locks required. Nothing can change the per cpu device.
451 clockevents_tick_resume(td->evtdev); in tick_resume_local()
453 if (td->mode == TICKDEV_MODE_PERIODIC) in tick_resume_local()
454 tick_setup_periodic(td->evtdev, 0); in tick_resume_local()
468 * tick_suspend - Suspend the tick and the broadcast device
474 * No locks required. Nothing can change the per cpu device.
483 * tick_resume - Resume the tick and the broadcast device
488 * No locks required. Nothing can change the per cpu device.
501 * tick_freeze - Suspend the local tick and (possibly) timekeeping.
504 * suspend timekeeping. Otherwise suspend the local tick.
528 * tick_unfreeze - Resume the local tick and (possibly) timekeeping.
531 * timekeeping. Otherwise resume the local tick.
551 tick_freeze_depth--; in tick_unfreeze()
558 * tick_init - initialize the tick control