1906568c9SThomas Gleixner /* 2906568c9SThomas Gleixner * linux/kernel/time/tick-common.c 3906568c9SThomas Gleixner * 4906568c9SThomas Gleixner * This file contains the base functions to manage periodic tick 5906568c9SThomas Gleixner * related events. 6906568c9SThomas Gleixner * 7906568c9SThomas Gleixner * Copyright(C) 2005-2006, Thomas Gleixner <tglx@linutronix.de> 8906568c9SThomas Gleixner * Copyright(C) 2005-2007, Red Hat, Inc., Ingo Molnar 9906568c9SThomas Gleixner * Copyright(C) 2006-2007, Timesys Corp., Thomas Gleixner 10906568c9SThomas Gleixner * 11906568c9SThomas Gleixner * This code is licenced under the GPL version 2. For details see 12906568c9SThomas Gleixner * kernel-base/COPYING. 13906568c9SThomas Gleixner */ 14906568c9SThomas Gleixner #include <linux/cpu.h> 15906568c9SThomas Gleixner #include <linux/err.h> 16906568c9SThomas Gleixner #include <linux/hrtimer.h> 17d7b90689SRussell King #include <linux/interrupt.h> 18906568c9SThomas Gleixner #include <linux/percpu.h> 19906568c9SThomas Gleixner #include <linux/profile.h> 20906568c9SThomas Gleixner #include <linux/sched.h> 21906568c9SThomas Gleixner 22d7b90689SRussell King #include <asm/irq_regs.h> 23d7b90689SRussell King 24f8381cbaSThomas Gleixner #include "tick-internal.h" 25f8381cbaSThomas Gleixner 26906568c9SThomas Gleixner /* 27906568c9SThomas Gleixner * Tick devices 28906568c9SThomas Gleixner */ 29f8381cbaSThomas Gleixner DEFINE_PER_CPU(struct tick_device, tick_cpu_device); 30906568c9SThomas Gleixner /* 31906568c9SThomas Gleixner * Tick next event: keeps track of the tick time 32906568c9SThomas Gleixner */ 33f8381cbaSThomas Gleixner ktime_t tick_next_period; 34f8381cbaSThomas Gleixner ktime_t tick_period; 356441402bSThomas Gleixner int tick_do_timer_cpu __read_mostly = TICK_DO_TIMER_BOOT; 36b5f91da0SThomas Gleixner static DEFINE_RAW_SPINLOCK(tick_device_lock); 37906568c9SThomas Gleixner 38289f480aSIngo Molnar /* 39289f480aSIngo Molnar * Debugging: see timer_list.c 40289f480aSIngo Molnar */ 41289f480aSIngo Molnar struct tick_device *tick_get_device(int cpu) 42289f480aSIngo Molnar { 43289f480aSIngo Molnar return &per_cpu(tick_cpu_device, cpu); 44289f480aSIngo Molnar } 45289f480aSIngo Molnar 4679bf2bb3SThomas Gleixner /** 4779bf2bb3SThomas Gleixner * tick_is_oneshot_available - check for a oneshot capable event device 4879bf2bb3SThomas Gleixner */ 4979bf2bb3SThomas Gleixner int tick_is_oneshot_available(void) 5079bf2bb3SThomas Gleixner { 51909ea964SChristoph Lameter struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev); 5279bf2bb3SThomas Gleixner 533a142a06SThomas Gleixner if (!dev || !(dev->features & CLOCK_EVT_FEAT_ONESHOT)) 543a142a06SThomas Gleixner return 0; 553a142a06SThomas Gleixner if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) 563a142a06SThomas Gleixner return 1; 573a142a06SThomas Gleixner return tick_broadcast_oneshot_available(); 5879bf2bb3SThomas Gleixner } 5979bf2bb3SThomas Gleixner 60906568c9SThomas Gleixner /* 61906568c9SThomas Gleixner * Periodic tick 62906568c9SThomas Gleixner */ 63906568c9SThomas Gleixner static void tick_periodic(int cpu) 64906568c9SThomas Gleixner { 65906568c9SThomas Gleixner if (tick_do_timer_cpu == cpu) { 66*d6ad4187SJohn Stultz write_seqlock(&jiffies_lock); 67906568c9SThomas Gleixner 68906568c9SThomas Gleixner /* Keep track of the next tick event */ 69906568c9SThomas Gleixner tick_next_period = ktime_add(tick_next_period, tick_period); 70906568c9SThomas Gleixner 71906568c9SThomas Gleixner do_timer(1); 72*d6ad4187SJohn Stultz write_sequnlock(&jiffies_lock); 73906568c9SThomas Gleixner } 74906568c9SThomas Gleixner 75906568c9SThomas Gleixner update_process_times(user_mode(get_irq_regs())); 76906568c9SThomas Gleixner profile_tick(CPU_PROFILING); 77906568c9SThomas Gleixner } 78906568c9SThomas Gleixner 79906568c9SThomas Gleixner /* 80906568c9SThomas Gleixner * Event handler for periodic ticks 81906568c9SThomas Gleixner */ 82906568c9SThomas Gleixner void tick_handle_periodic(struct clock_event_device *dev) 83906568c9SThomas Gleixner { 84906568c9SThomas Gleixner int cpu = smp_processor_id(); 853494c166SDavid S. Miller ktime_t next; 86906568c9SThomas Gleixner 87906568c9SThomas Gleixner tick_periodic(cpu); 88906568c9SThomas Gleixner 89906568c9SThomas Gleixner if (dev->mode != CLOCK_EVT_MODE_ONESHOT) 90906568c9SThomas Gleixner return; 91906568c9SThomas Gleixner /* 92906568c9SThomas Gleixner * Setup the next period for devices, which do not have 93906568c9SThomas Gleixner * periodic mode: 94906568c9SThomas Gleixner */ 953494c166SDavid S. Miller next = ktime_add(dev->next_event, tick_period); 96906568c9SThomas Gleixner for (;;) { 97d1748302SMartin Schwidefsky if (!clockevents_program_event(dev, next, false)) 98906568c9SThomas Gleixner return; 9974a03b69Sjohn stultz /* 10074a03b69Sjohn stultz * Have to be careful here. If we're in oneshot mode, 10174a03b69Sjohn stultz * before we call tick_periodic() in a loop, we need 10274a03b69Sjohn stultz * to be sure we're using a real hardware clocksource. 10374a03b69Sjohn stultz * Otherwise we could get trapped in an infinite 10474a03b69Sjohn stultz * loop, as the tick_periodic() increments jiffies, 10574a03b69Sjohn stultz * when then will increment time, posibly causing 10674a03b69Sjohn stultz * the loop to trigger again and again. 10774a03b69Sjohn stultz */ 10874a03b69Sjohn stultz if (timekeeping_valid_for_hres()) 109906568c9SThomas Gleixner tick_periodic(cpu); 1103494c166SDavid S. Miller next = ktime_add(next, tick_period); 111906568c9SThomas Gleixner } 112906568c9SThomas Gleixner } 113906568c9SThomas Gleixner 114906568c9SThomas Gleixner /* 115906568c9SThomas Gleixner * Setup the device for a periodic tick 116906568c9SThomas Gleixner */ 117f8381cbaSThomas Gleixner void tick_setup_periodic(struct clock_event_device *dev, int broadcast) 118906568c9SThomas Gleixner { 119f8381cbaSThomas Gleixner tick_set_periodic_handler(dev, broadcast); 120f8381cbaSThomas Gleixner 121f8381cbaSThomas Gleixner /* Broadcast setup ? */ 122f8381cbaSThomas Gleixner if (!tick_device_is_functional(dev)) 123f8381cbaSThomas Gleixner return; 124906568c9SThomas Gleixner 12527ce4cb4SThomas Gleixner if ((dev->features & CLOCK_EVT_FEAT_PERIODIC) && 12627ce4cb4SThomas Gleixner !tick_broadcast_oneshot_active()) { 127906568c9SThomas Gleixner clockevents_set_mode(dev, CLOCK_EVT_MODE_PERIODIC); 128906568c9SThomas Gleixner } else { 129906568c9SThomas Gleixner unsigned long seq; 130906568c9SThomas Gleixner ktime_t next; 131906568c9SThomas Gleixner 132906568c9SThomas Gleixner do { 133*d6ad4187SJohn Stultz seq = read_seqbegin(&jiffies_lock); 134906568c9SThomas Gleixner next = tick_next_period; 135*d6ad4187SJohn Stultz } while (read_seqretry(&jiffies_lock, seq)); 136906568c9SThomas Gleixner 137906568c9SThomas Gleixner clockevents_set_mode(dev, CLOCK_EVT_MODE_ONESHOT); 138906568c9SThomas Gleixner 139906568c9SThomas Gleixner for (;;) { 140d1748302SMartin Schwidefsky if (!clockevents_program_event(dev, next, false)) 141906568c9SThomas Gleixner return; 142906568c9SThomas Gleixner next = ktime_add(next, tick_period); 143906568c9SThomas Gleixner } 144906568c9SThomas Gleixner } 145906568c9SThomas Gleixner } 146906568c9SThomas Gleixner 147906568c9SThomas Gleixner /* 148906568c9SThomas Gleixner * Setup the tick device 149906568c9SThomas Gleixner */ 150906568c9SThomas Gleixner static void tick_setup_device(struct tick_device *td, 151906568c9SThomas Gleixner struct clock_event_device *newdev, int cpu, 1520de26520SRusty Russell const struct cpumask *cpumask) 153906568c9SThomas Gleixner { 154906568c9SThomas Gleixner ktime_t next_event; 155906568c9SThomas Gleixner void (*handler)(struct clock_event_device *) = NULL; 156906568c9SThomas Gleixner 157906568c9SThomas Gleixner /* 158906568c9SThomas Gleixner * First device setup ? 159906568c9SThomas Gleixner */ 160906568c9SThomas Gleixner if (!td->evtdev) { 161906568c9SThomas Gleixner /* 162906568c9SThomas Gleixner * If no cpu took the do_timer update, assign it to 163906568c9SThomas Gleixner * this cpu: 164906568c9SThomas Gleixner */ 1656441402bSThomas Gleixner if (tick_do_timer_cpu == TICK_DO_TIMER_BOOT) { 166906568c9SThomas Gleixner tick_do_timer_cpu = cpu; 167906568c9SThomas Gleixner tick_next_period = ktime_get(); 168906568c9SThomas Gleixner tick_period = ktime_set(0, NSEC_PER_SEC / HZ); 169906568c9SThomas Gleixner } 170906568c9SThomas Gleixner 171906568c9SThomas Gleixner /* 172906568c9SThomas Gleixner * Startup in periodic mode first. 173906568c9SThomas Gleixner */ 174906568c9SThomas Gleixner td->mode = TICKDEV_MODE_PERIODIC; 175906568c9SThomas Gleixner } else { 176906568c9SThomas Gleixner handler = td->evtdev->event_handler; 177906568c9SThomas Gleixner next_event = td->evtdev->next_event; 1787c1e7689SVenkatesh Pallipadi td->evtdev->event_handler = clockevents_handle_noop; 179906568c9SThomas Gleixner } 180906568c9SThomas Gleixner 181906568c9SThomas Gleixner td->evtdev = newdev; 182906568c9SThomas Gleixner 183906568c9SThomas Gleixner /* 184906568c9SThomas Gleixner * When the device is not per cpu, pin the interrupt to the 185906568c9SThomas Gleixner * current cpu: 186906568c9SThomas Gleixner */ 187320ab2b0SRusty Russell if (!cpumask_equal(newdev->cpumask, cpumask)) 1880de26520SRusty Russell irq_set_affinity(newdev->irq, cpumask); 189906568c9SThomas Gleixner 190f8381cbaSThomas Gleixner /* 191f8381cbaSThomas Gleixner * When global broadcasting is active, check if the current 192f8381cbaSThomas Gleixner * device is registered as a placeholder for broadcast mode. 193f8381cbaSThomas Gleixner * This allows us to handle this x86 misfeature in a generic 194f8381cbaSThomas Gleixner * way. 195f8381cbaSThomas Gleixner */ 196f8381cbaSThomas Gleixner if (tick_device_uses_broadcast(newdev, cpu)) 197f8381cbaSThomas Gleixner return; 198f8381cbaSThomas Gleixner 199906568c9SThomas Gleixner if (td->mode == TICKDEV_MODE_PERIODIC) 200906568c9SThomas Gleixner tick_setup_periodic(newdev, 0); 20179bf2bb3SThomas Gleixner else 20279bf2bb3SThomas Gleixner tick_setup_oneshot(newdev, handler, next_event); 203906568c9SThomas Gleixner } 204906568c9SThomas Gleixner 205906568c9SThomas Gleixner /* 206906568c9SThomas Gleixner * Check, if the new registered device should be used. 207906568c9SThomas Gleixner */ 208906568c9SThomas Gleixner static int tick_check_new_device(struct clock_event_device *newdev) 209906568c9SThomas Gleixner { 210906568c9SThomas Gleixner struct clock_event_device *curdev; 211906568c9SThomas Gleixner struct tick_device *td; 212906568c9SThomas Gleixner int cpu, ret = NOTIFY_OK; 213906568c9SThomas Gleixner unsigned long flags; 214906568c9SThomas Gleixner 215b5f91da0SThomas Gleixner raw_spin_lock_irqsave(&tick_device_lock, flags); 216906568c9SThomas Gleixner 217906568c9SThomas Gleixner cpu = smp_processor_id(); 218320ab2b0SRusty Russell if (!cpumask_test_cpu(cpu, newdev->cpumask)) 2194a93232dSVenki Pallipadi goto out_bc; 220906568c9SThomas Gleixner 221906568c9SThomas Gleixner td = &per_cpu(tick_cpu_device, cpu); 222906568c9SThomas Gleixner curdev = td->evtdev; 223906568c9SThomas Gleixner 224906568c9SThomas Gleixner /* cpu local device ? */ 225320ab2b0SRusty Russell if (!cpumask_equal(newdev->cpumask, cpumask_of(cpu))) { 226906568c9SThomas Gleixner 227906568c9SThomas Gleixner /* 228906568c9SThomas Gleixner * If the cpu affinity of the device interrupt can not 229906568c9SThomas Gleixner * be set, ignore it. 230906568c9SThomas Gleixner */ 231906568c9SThomas Gleixner if (!irq_can_set_affinity(newdev->irq)) 232906568c9SThomas Gleixner goto out_bc; 233906568c9SThomas Gleixner 234906568c9SThomas Gleixner /* 235906568c9SThomas Gleixner * If we have a cpu local device already, do not replace it 236906568c9SThomas Gleixner * by a non cpu local device 237906568c9SThomas Gleixner */ 238320ab2b0SRusty Russell if (curdev && cpumask_equal(curdev->cpumask, cpumask_of(cpu))) 239906568c9SThomas Gleixner goto out_bc; 240906568c9SThomas Gleixner } 241906568c9SThomas Gleixner 242906568c9SThomas Gleixner /* 243906568c9SThomas Gleixner * If we have an active device, then check the rating and the oneshot 244906568c9SThomas Gleixner * feature. 245906568c9SThomas Gleixner */ 246906568c9SThomas Gleixner if (curdev) { 247906568c9SThomas Gleixner /* 24879bf2bb3SThomas Gleixner * Prefer one shot capable devices ! 24979bf2bb3SThomas Gleixner */ 25079bf2bb3SThomas Gleixner if ((curdev->features & CLOCK_EVT_FEAT_ONESHOT) && 25179bf2bb3SThomas Gleixner !(newdev->features & CLOCK_EVT_FEAT_ONESHOT)) 25279bf2bb3SThomas Gleixner goto out_bc; 25379bf2bb3SThomas Gleixner /* 254906568c9SThomas Gleixner * Check the rating 255906568c9SThomas Gleixner */ 256906568c9SThomas Gleixner if (curdev->rating >= newdev->rating) 257f8381cbaSThomas Gleixner goto out_bc; 258906568c9SThomas Gleixner } 259906568c9SThomas Gleixner 260906568c9SThomas Gleixner /* 261906568c9SThomas Gleixner * Replace the eventually existing device by the new 262f8381cbaSThomas Gleixner * device. If the current device is the broadcast device, do 263f8381cbaSThomas Gleixner * not give it back to the clockevents layer ! 264906568c9SThomas Gleixner */ 265f8381cbaSThomas Gleixner if (tick_is_broadcast_device(curdev)) { 2662344abbcSThomas Gleixner clockevents_shutdown(curdev); 267f8381cbaSThomas Gleixner curdev = NULL; 268f8381cbaSThomas Gleixner } 269906568c9SThomas Gleixner clockevents_exchange_device(curdev, newdev); 2706b954823SRusty Russell tick_setup_device(td, newdev, cpu, cpumask_of(cpu)); 27179bf2bb3SThomas Gleixner if (newdev->features & CLOCK_EVT_FEAT_ONESHOT) 27279bf2bb3SThomas Gleixner tick_oneshot_notify(); 273906568c9SThomas Gleixner 274b5f91da0SThomas Gleixner raw_spin_unlock_irqrestore(&tick_device_lock, flags); 275f8381cbaSThomas Gleixner return NOTIFY_STOP; 276f8381cbaSThomas Gleixner 277f8381cbaSThomas Gleixner out_bc: 278f8381cbaSThomas Gleixner /* 279f8381cbaSThomas Gleixner * Can the new device be used as a broadcast device ? 280f8381cbaSThomas Gleixner */ 281f8381cbaSThomas Gleixner if (tick_check_broadcast_device(newdev)) 282f8381cbaSThomas Gleixner ret = NOTIFY_STOP; 2834a93232dSVenki Pallipadi 284b5f91da0SThomas Gleixner raw_spin_unlock_irqrestore(&tick_device_lock, flags); 285f8381cbaSThomas Gleixner 286906568c9SThomas Gleixner return ret; 287906568c9SThomas Gleixner } 288906568c9SThomas Gleixner 289906568c9SThomas Gleixner /* 29094df7de0SSebastien Dugue * Transfer the do_timer job away from a dying cpu. 29194df7de0SSebastien Dugue * 29294df7de0SSebastien Dugue * Called with interrupts disabled. 29394df7de0SSebastien Dugue */ 29494df7de0SSebastien Dugue static void tick_handover_do_timer(int *cpup) 29594df7de0SSebastien Dugue { 29694df7de0SSebastien Dugue if (*cpup == tick_do_timer_cpu) { 29794df7de0SSebastien Dugue int cpu = cpumask_first(cpu_online_mask); 29894df7de0SSebastien Dugue 29994df7de0SSebastien Dugue tick_do_timer_cpu = (cpu < nr_cpu_ids) ? cpu : 30094df7de0SSebastien Dugue TICK_DO_TIMER_NONE; 30194df7de0SSebastien Dugue } 30294df7de0SSebastien Dugue } 30394df7de0SSebastien Dugue 30494df7de0SSebastien Dugue /* 305906568c9SThomas Gleixner * Shutdown an event device on a given cpu: 306906568c9SThomas Gleixner * 307906568c9SThomas Gleixner * This is called on a life CPU, when a CPU is dead. So we cannot 308906568c9SThomas Gleixner * access the hardware device itself. 309906568c9SThomas Gleixner * We just set the mode and remove it from the lists. 310906568c9SThomas Gleixner */ 311906568c9SThomas Gleixner static void tick_shutdown(unsigned int *cpup) 312906568c9SThomas Gleixner { 313906568c9SThomas Gleixner struct tick_device *td = &per_cpu(tick_cpu_device, *cpup); 314906568c9SThomas Gleixner struct clock_event_device *dev = td->evtdev; 315906568c9SThomas Gleixner unsigned long flags; 316906568c9SThomas Gleixner 317b5f91da0SThomas Gleixner raw_spin_lock_irqsave(&tick_device_lock, flags); 318906568c9SThomas Gleixner td->mode = TICKDEV_MODE_PERIODIC; 319906568c9SThomas Gleixner if (dev) { 320906568c9SThomas Gleixner /* 321906568c9SThomas Gleixner * Prevent that the clock events layer tries to call 322906568c9SThomas Gleixner * the set mode function! 323906568c9SThomas Gleixner */ 324906568c9SThomas Gleixner dev->mode = CLOCK_EVT_MODE_UNUSED; 325906568c9SThomas Gleixner clockevents_exchange_device(dev, NULL); 326906568c9SThomas Gleixner td->evtdev = NULL; 327906568c9SThomas Gleixner } 328b5f91da0SThomas Gleixner raw_spin_unlock_irqrestore(&tick_device_lock, flags); 329906568c9SThomas Gleixner } 330906568c9SThomas Gleixner 331cd05a1f8SThomas Gleixner static void tick_suspend(void) 3326321dd60SThomas Gleixner { 3336321dd60SThomas Gleixner struct tick_device *td = &__get_cpu_var(tick_cpu_device); 3346321dd60SThomas Gleixner unsigned long flags; 3356321dd60SThomas Gleixner 336b5f91da0SThomas Gleixner raw_spin_lock_irqsave(&tick_device_lock, flags); 3372344abbcSThomas Gleixner clockevents_shutdown(td->evtdev); 338b5f91da0SThomas Gleixner raw_spin_unlock_irqrestore(&tick_device_lock, flags); 3396321dd60SThomas Gleixner } 3406321dd60SThomas Gleixner 341cd05a1f8SThomas Gleixner static void tick_resume(void) 3426321dd60SThomas Gleixner { 3436321dd60SThomas Gleixner struct tick_device *td = &__get_cpu_var(tick_cpu_device); 3446321dd60SThomas Gleixner unsigned long flags; 34518de5bc4SThomas Gleixner int broadcast = tick_resume_broadcast(); 3466321dd60SThomas Gleixner 347b5f91da0SThomas Gleixner raw_spin_lock_irqsave(&tick_device_lock, flags); 34818de5bc4SThomas Gleixner clockevents_set_mode(td->evtdev, CLOCK_EVT_MODE_RESUME); 34918de5bc4SThomas Gleixner 35018de5bc4SThomas Gleixner if (!broadcast) { 3516321dd60SThomas Gleixner if (td->mode == TICKDEV_MODE_PERIODIC) 3526321dd60SThomas Gleixner tick_setup_periodic(td->evtdev, 0); 353cd05a1f8SThomas Gleixner else 354cd05a1f8SThomas Gleixner tick_resume_oneshot(); 35518de5bc4SThomas Gleixner } 356b5f91da0SThomas Gleixner raw_spin_unlock_irqrestore(&tick_device_lock, flags); 3576321dd60SThomas Gleixner } 3586321dd60SThomas Gleixner 359906568c9SThomas Gleixner /* 360906568c9SThomas Gleixner * Notification about clock event devices 361906568c9SThomas Gleixner */ 362906568c9SThomas Gleixner static int tick_notify(struct notifier_block *nb, unsigned long reason, 363906568c9SThomas Gleixner void *dev) 364906568c9SThomas Gleixner { 365906568c9SThomas Gleixner switch (reason) { 366906568c9SThomas Gleixner 367906568c9SThomas Gleixner case CLOCK_EVT_NOTIFY_ADD: 368906568c9SThomas Gleixner return tick_check_new_device(dev); 369906568c9SThomas Gleixner 370f8381cbaSThomas Gleixner case CLOCK_EVT_NOTIFY_BROADCAST_ON: 371f8381cbaSThomas Gleixner case CLOCK_EVT_NOTIFY_BROADCAST_OFF: 3721595f452SThomas Gleixner case CLOCK_EVT_NOTIFY_BROADCAST_FORCE: 373f8381cbaSThomas Gleixner tick_broadcast_on_off(reason, dev); 374f8381cbaSThomas Gleixner break; 375f8381cbaSThomas Gleixner 37679bf2bb3SThomas Gleixner case CLOCK_EVT_NOTIFY_BROADCAST_ENTER: 37779bf2bb3SThomas Gleixner case CLOCK_EVT_NOTIFY_BROADCAST_EXIT: 37879bf2bb3SThomas Gleixner tick_broadcast_oneshot_control(reason); 37979bf2bb3SThomas Gleixner break; 38079bf2bb3SThomas Gleixner 38194df7de0SSebastien Dugue case CLOCK_EVT_NOTIFY_CPU_DYING: 38294df7de0SSebastien Dugue tick_handover_do_timer(dev); 38394df7de0SSebastien Dugue break; 38494df7de0SSebastien Dugue 385906568c9SThomas Gleixner case CLOCK_EVT_NOTIFY_CPU_DEAD: 38679bf2bb3SThomas Gleixner tick_shutdown_broadcast_oneshot(dev); 387f8381cbaSThomas Gleixner tick_shutdown_broadcast(dev); 388906568c9SThomas Gleixner tick_shutdown(dev); 389906568c9SThomas Gleixner break; 390906568c9SThomas Gleixner 3916321dd60SThomas Gleixner case CLOCK_EVT_NOTIFY_SUSPEND: 392cd05a1f8SThomas Gleixner tick_suspend(); 3936321dd60SThomas Gleixner tick_suspend_broadcast(); 3946321dd60SThomas Gleixner break; 3956321dd60SThomas Gleixner 3966321dd60SThomas Gleixner case CLOCK_EVT_NOTIFY_RESUME: 397cd05a1f8SThomas Gleixner tick_resume(); 3986321dd60SThomas Gleixner break; 3996321dd60SThomas Gleixner 400906568c9SThomas Gleixner default: 401906568c9SThomas Gleixner break; 402906568c9SThomas Gleixner } 403906568c9SThomas Gleixner 404906568c9SThomas Gleixner return NOTIFY_OK; 405906568c9SThomas Gleixner } 406906568c9SThomas Gleixner 407906568c9SThomas Gleixner static struct notifier_block tick_notifier = { 408906568c9SThomas Gleixner .notifier_call = tick_notify, 409906568c9SThomas Gleixner }; 410906568c9SThomas Gleixner 411906568c9SThomas Gleixner /** 412906568c9SThomas Gleixner * tick_init - initialize the tick control 413906568c9SThomas Gleixner * 414906568c9SThomas Gleixner * Register the notifier with the clockevents framework 415906568c9SThomas Gleixner */ 416906568c9SThomas Gleixner void __init tick_init(void) 417906568c9SThomas Gleixner { 418906568c9SThomas Gleixner clockevents_register_notifier(&tick_notifier); 419906568c9SThomas Gleixner } 420