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 #include <linux/tick.h> 22906568c9SThomas Gleixner 23d7b90689SRussell King #include <asm/irq_regs.h> 24d7b90689SRussell King 25f8381cbaSThomas Gleixner #include "tick-internal.h" 26f8381cbaSThomas Gleixner 27906568c9SThomas Gleixner /* 28906568c9SThomas Gleixner * Tick devices 29906568c9SThomas Gleixner */ 30f8381cbaSThomas Gleixner DEFINE_PER_CPU(struct tick_device, tick_cpu_device); 31906568c9SThomas Gleixner /* 32906568c9SThomas Gleixner * Tick next event: keeps track of the tick time 33906568c9SThomas Gleixner */ 34f8381cbaSThomas Gleixner ktime_t tick_next_period; 35f8381cbaSThomas Gleixner ktime_t tick_period; 366441402bSThomas Gleixner int tick_do_timer_cpu __read_mostly = TICK_DO_TIMER_BOOT; 37b5f91da0SThomas Gleixner static DEFINE_RAW_SPINLOCK(tick_device_lock); 38906568c9SThomas Gleixner 39289f480aSIngo Molnar /* 40289f480aSIngo Molnar * Debugging: see timer_list.c 41289f480aSIngo Molnar */ 42289f480aSIngo Molnar struct tick_device *tick_get_device(int cpu) 43289f480aSIngo Molnar { 44289f480aSIngo Molnar return &per_cpu(tick_cpu_device, cpu); 45289f480aSIngo Molnar } 46289f480aSIngo Molnar 4779bf2bb3SThomas Gleixner /** 4879bf2bb3SThomas Gleixner * tick_is_oneshot_available - check for a oneshot capable event device 4979bf2bb3SThomas Gleixner */ 5079bf2bb3SThomas Gleixner int tick_is_oneshot_available(void) 5179bf2bb3SThomas Gleixner { 52909ea964SChristoph Lameter struct clock_event_device *dev = __this_cpu_read(tick_cpu_device.evtdev); 5379bf2bb3SThomas Gleixner 54*3a142a06SThomas Gleixner if (!dev || !(dev->features & CLOCK_EVT_FEAT_ONESHOT)) 55*3a142a06SThomas Gleixner return 0; 56*3a142a06SThomas Gleixner if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) 57*3a142a06SThomas Gleixner return 1; 58*3a142a06SThomas Gleixner return tick_broadcast_oneshot_available(); 5979bf2bb3SThomas Gleixner } 6079bf2bb3SThomas Gleixner 61906568c9SThomas Gleixner /* 62906568c9SThomas Gleixner * Periodic tick 63906568c9SThomas Gleixner */ 64906568c9SThomas Gleixner static void tick_periodic(int cpu) 65906568c9SThomas Gleixner { 66906568c9SThomas Gleixner if (tick_do_timer_cpu == cpu) { 67906568c9SThomas Gleixner write_seqlock(&xtime_lock); 68906568c9SThomas Gleixner 69906568c9SThomas Gleixner /* Keep track of the next tick event */ 70906568c9SThomas Gleixner tick_next_period = ktime_add(tick_next_period, tick_period); 71906568c9SThomas Gleixner 72906568c9SThomas Gleixner do_timer(1); 73906568c9SThomas Gleixner write_sequnlock(&xtime_lock); 74906568c9SThomas Gleixner } 75906568c9SThomas Gleixner 76906568c9SThomas Gleixner update_process_times(user_mode(get_irq_regs())); 77906568c9SThomas Gleixner profile_tick(CPU_PROFILING); 78906568c9SThomas Gleixner } 79906568c9SThomas Gleixner 80906568c9SThomas Gleixner /* 81906568c9SThomas Gleixner * Event handler for periodic ticks 82906568c9SThomas Gleixner */ 83906568c9SThomas Gleixner void tick_handle_periodic(struct clock_event_device *dev) 84906568c9SThomas Gleixner { 85906568c9SThomas Gleixner int cpu = smp_processor_id(); 863494c166SDavid S. Miller ktime_t next; 87906568c9SThomas Gleixner 88906568c9SThomas Gleixner tick_periodic(cpu); 89906568c9SThomas Gleixner 90906568c9SThomas Gleixner if (dev->mode != CLOCK_EVT_MODE_ONESHOT) 91906568c9SThomas Gleixner return; 92906568c9SThomas Gleixner /* 93906568c9SThomas Gleixner * Setup the next period for devices, which do not have 94906568c9SThomas Gleixner * periodic mode: 95906568c9SThomas Gleixner */ 963494c166SDavid S. Miller next = ktime_add(dev->next_event, tick_period); 97906568c9SThomas Gleixner for (;;) { 98906568c9SThomas Gleixner if (!clockevents_program_event(dev, next, ktime_get())) 99906568c9SThomas Gleixner return; 10074a03b69Sjohn stultz /* 10174a03b69Sjohn stultz * Have to be careful here. If we're in oneshot mode, 10274a03b69Sjohn stultz * before we call tick_periodic() in a loop, we need 10374a03b69Sjohn stultz * to be sure we're using a real hardware clocksource. 10474a03b69Sjohn stultz * Otherwise we could get trapped in an infinite 10574a03b69Sjohn stultz * loop, as the tick_periodic() increments jiffies, 10674a03b69Sjohn stultz * when then will increment time, posibly causing 10774a03b69Sjohn stultz * the loop to trigger again and again. 10874a03b69Sjohn stultz */ 10974a03b69Sjohn stultz if (timekeeping_valid_for_hres()) 110906568c9SThomas Gleixner tick_periodic(cpu); 1113494c166SDavid S. Miller next = ktime_add(next, tick_period); 112906568c9SThomas Gleixner } 113906568c9SThomas Gleixner } 114906568c9SThomas Gleixner 115906568c9SThomas Gleixner /* 116906568c9SThomas Gleixner * Setup the device for a periodic tick 117906568c9SThomas Gleixner */ 118f8381cbaSThomas Gleixner void tick_setup_periodic(struct clock_event_device *dev, int broadcast) 119906568c9SThomas Gleixner { 120f8381cbaSThomas Gleixner tick_set_periodic_handler(dev, broadcast); 121f8381cbaSThomas Gleixner 122f8381cbaSThomas Gleixner /* Broadcast setup ? */ 123f8381cbaSThomas Gleixner if (!tick_device_is_functional(dev)) 124f8381cbaSThomas Gleixner return; 125906568c9SThomas Gleixner 12627ce4cb4SThomas Gleixner if ((dev->features & CLOCK_EVT_FEAT_PERIODIC) && 12727ce4cb4SThomas Gleixner !tick_broadcast_oneshot_active()) { 128906568c9SThomas Gleixner clockevents_set_mode(dev, CLOCK_EVT_MODE_PERIODIC); 129906568c9SThomas Gleixner } else { 130906568c9SThomas Gleixner unsigned long seq; 131906568c9SThomas Gleixner ktime_t next; 132906568c9SThomas Gleixner 133906568c9SThomas Gleixner do { 134906568c9SThomas Gleixner seq = read_seqbegin(&xtime_lock); 135906568c9SThomas Gleixner next = tick_next_period; 136906568c9SThomas Gleixner } while (read_seqretry(&xtime_lock, seq)); 137906568c9SThomas Gleixner 138906568c9SThomas Gleixner clockevents_set_mode(dev, CLOCK_EVT_MODE_ONESHOT); 139906568c9SThomas Gleixner 140906568c9SThomas Gleixner for (;;) { 141906568c9SThomas Gleixner if (!clockevents_program_event(dev, next, ktime_get())) 142906568c9SThomas Gleixner return; 143906568c9SThomas Gleixner next = ktime_add(next, tick_period); 144906568c9SThomas Gleixner } 145906568c9SThomas Gleixner } 146906568c9SThomas Gleixner } 147906568c9SThomas Gleixner 148906568c9SThomas Gleixner /* 149906568c9SThomas Gleixner * Setup the tick device 150906568c9SThomas Gleixner */ 151906568c9SThomas Gleixner static void tick_setup_device(struct tick_device *td, 152906568c9SThomas Gleixner struct clock_event_device *newdev, int cpu, 1530de26520SRusty Russell const struct cpumask *cpumask) 154906568c9SThomas Gleixner { 155906568c9SThomas Gleixner ktime_t next_event; 156906568c9SThomas Gleixner void (*handler)(struct clock_event_device *) = NULL; 157906568c9SThomas Gleixner 158906568c9SThomas Gleixner /* 159906568c9SThomas Gleixner * First device setup ? 160906568c9SThomas Gleixner */ 161906568c9SThomas Gleixner if (!td->evtdev) { 162906568c9SThomas Gleixner /* 163906568c9SThomas Gleixner * If no cpu took the do_timer update, assign it to 164906568c9SThomas Gleixner * this cpu: 165906568c9SThomas Gleixner */ 1666441402bSThomas Gleixner if (tick_do_timer_cpu == TICK_DO_TIMER_BOOT) { 167906568c9SThomas Gleixner tick_do_timer_cpu = cpu; 168906568c9SThomas Gleixner tick_next_period = ktime_get(); 169906568c9SThomas Gleixner tick_period = ktime_set(0, NSEC_PER_SEC / HZ); 170906568c9SThomas Gleixner } 171906568c9SThomas Gleixner 172906568c9SThomas Gleixner /* 173906568c9SThomas Gleixner * Startup in periodic mode first. 174906568c9SThomas Gleixner */ 175906568c9SThomas Gleixner td->mode = TICKDEV_MODE_PERIODIC; 176906568c9SThomas Gleixner } else { 177906568c9SThomas Gleixner handler = td->evtdev->event_handler; 178906568c9SThomas Gleixner next_event = td->evtdev->next_event; 1797c1e7689SVenkatesh Pallipadi td->evtdev->event_handler = clockevents_handle_noop; 180906568c9SThomas Gleixner } 181906568c9SThomas Gleixner 182906568c9SThomas Gleixner td->evtdev = newdev; 183906568c9SThomas Gleixner 184906568c9SThomas Gleixner /* 185906568c9SThomas Gleixner * When the device is not per cpu, pin the interrupt to the 186906568c9SThomas Gleixner * current cpu: 187906568c9SThomas Gleixner */ 188320ab2b0SRusty Russell if (!cpumask_equal(newdev->cpumask, cpumask)) 1890de26520SRusty Russell irq_set_affinity(newdev->irq, cpumask); 190906568c9SThomas Gleixner 191f8381cbaSThomas Gleixner /* 192f8381cbaSThomas Gleixner * When global broadcasting is active, check if the current 193f8381cbaSThomas Gleixner * device is registered as a placeholder for broadcast mode. 194f8381cbaSThomas Gleixner * This allows us to handle this x86 misfeature in a generic 195f8381cbaSThomas Gleixner * way. 196f8381cbaSThomas Gleixner */ 197f8381cbaSThomas Gleixner if (tick_device_uses_broadcast(newdev, cpu)) 198f8381cbaSThomas Gleixner return; 199f8381cbaSThomas Gleixner 200906568c9SThomas Gleixner if (td->mode == TICKDEV_MODE_PERIODIC) 201906568c9SThomas Gleixner tick_setup_periodic(newdev, 0); 20279bf2bb3SThomas Gleixner else 20379bf2bb3SThomas Gleixner tick_setup_oneshot(newdev, handler, next_event); 204906568c9SThomas Gleixner } 205906568c9SThomas Gleixner 206906568c9SThomas Gleixner /* 207906568c9SThomas Gleixner * Check, if the new registered device should be used. 208906568c9SThomas Gleixner */ 209906568c9SThomas Gleixner static int tick_check_new_device(struct clock_event_device *newdev) 210906568c9SThomas Gleixner { 211906568c9SThomas Gleixner struct clock_event_device *curdev; 212906568c9SThomas Gleixner struct tick_device *td; 213906568c9SThomas Gleixner int cpu, ret = NOTIFY_OK; 214906568c9SThomas Gleixner unsigned long flags; 215906568c9SThomas Gleixner 216b5f91da0SThomas Gleixner raw_spin_lock_irqsave(&tick_device_lock, flags); 217906568c9SThomas Gleixner 218906568c9SThomas Gleixner cpu = smp_processor_id(); 219320ab2b0SRusty Russell if (!cpumask_test_cpu(cpu, newdev->cpumask)) 2204a93232dSVenki Pallipadi goto out_bc; 221906568c9SThomas Gleixner 222906568c9SThomas Gleixner td = &per_cpu(tick_cpu_device, cpu); 223906568c9SThomas Gleixner curdev = td->evtdev; 224906568c9SThomas Gleixner 225906568c9SThomas Gleixner /* cpu local device ? */ 226320ab2b0SRusty Russell if (!cpumask_equal(newdev->cpumask, cpumask_of(cpu))) { 227906568c9SThomas Gleixner 228906568c9SThomas Gleixner /* 229906568c9SThomas Gleixner * If the cpu affinity of the device interrupt can not 230906568c9SThomas Gleixner * be set, ignore it. 231906568c9SThomas Gleixner */ 232906568c9SThomas Gleixner if (!irq_can_set_affinity(newdev->irq)) 233906568c9SThomas Gleixner goto out_bc; 234906568c9SThomas Gleixner 235906568c9SThomas Gleixner /* 236906568c9SThomas Gleixner * If we have a cpu local device already, do not replace it 237906568c9SThomas Gleixner * by a non cpu local device 238906568c9SThomas Gleixner */ 239320ab2b0SRusty Russell if (curdev && cpumask_equal(curdev->cpumask, cpumask_of(cpu))) 240906568c9SThomas Gleixner goto out_bc; 241906568c9SThomas Gleixner } 242906568c9SThomas Gleixner 243906568c9SThomas Gleixner /* 244906568c9SThomas Gleixner * If we have an active device, then check the rating and the oneshot 245906568c9SThomas Gleixner * feature. 246906568c9SThomas Gleixner */ 247906568c9SThomas Gleixner if (curdev) { 248906568c9SThomas Gleixner /* 24979bf2bb3SThomas Gleixner * Prefer one shot capable devices ! 25079bf2bb3SThomas Gleixner */ 25179bf2bb3SThomas Gleixner if ((curdev->features & CLOCK_EVT_FEAT_ONESHOT) && 25279bf2bb3SThomas Gleixner !(newdev->features & CLOCK_EVT_FEAT_ONESHOT)) 25379bf2bb3SThomas Gleixner goto out_bc; 25479bf2bb3SThomas Gleixner /* 255906568c9SThomas Gleixner * Check the rating 256906568c9SThomas Gleixner */ 257906568c9SThomas Gleixner if (curdev->rating >= newdev->rating) 258f8381cbaSThomas Gleixner goto out_bc; 259906568c9SThomas Gleixner } 260906568c9SThomas Gleixner 261906568c9SThomas Gleixner /* 262906568c9SThomas Gleixner * Replace the eventually existing device by the new 263f8381cbaSThomas Gleixner * device. If the current device is the broadcast device, do 264f8381cbaSThomas Gleixner * not give it back to the clockevents layer ! 265906568c9SThomas Gleixner */ 266f8381cbaSThomas Gleixner if (tick_is_broadcast_device(curdev)) { 2672344abbcSThomas Gleixner clockevents_shutdown(curdev); 268f8381cbaSThomas Gleixner curdev = NULL; 269f8381cbaSThomas Gleixner } 270906568c9SThomas Gleixner clockevents_exchange_device(curdev, newdev); 2716b954823SRusty Russell tick_setup_device(td, newdev, cpu, cpumask_of(cpu)); 27279bf2bb3SThomas Gleixner if (newdev->features & CLOCK_EVT_FEAT_ONESHOT) 27379bf2bb3SThomas Gleixner tick_oneshot_notify(); 274906568c9SThomas Gleixner 275b5f91da0SThomas Gleixner raw_spin_unlock_irqrestore(&tick_device_lock, flags); 276f8381cbaSThomas Gleixner return NOTIFY_STOP; 277f8381cbaSThomas Gleixner 278f8381cbaSThomas Gleixner out_bc: 279f8381cbaSThomas Gleixner /* 280f8381cbaSThomas Gleixner * Can the new device be used as a broadcast device ? 281f8381cbaSThomas Gleixner */ 282f8381cbaSThomas Gleixner if (tick_check_broadcast_device(newdev)) 283f8381cbaSThomas Gleixner ret = NOTIFY_STOP; 2844a93232dSVenki Pallipadi 285b5f91da0SThomas Gleixner raw_spin_unlock_irqrestore(&tick_device_lock, flags); 286f8381cbaSThomas Gleixner 287906568c9SThomas Gleixner return ret; 288906568c9SThomas Gleixner } 289906568c9SThomas Gleixner 290906568c9SThomas Gleixner /* 29194df7de0SSebastien Dugue * Transfer the do_timer job away from a dying cpu. 29294df7de0SSebastien Dugue * 29394df7de0SSebastien Dugue * Called with interrupts disabled. 29494df7de0SSebastien Dugue */ 29594df7de0SSebastien Dugue static void tick_handover_do_timer(int *cpup) 29694df7de0SSebastien Dugue { 29794df7de0SSebastien Dugue if (*cpup == tick_do_timer_cpu) { 29894df7de0SSebastien Dugue int cpu = cpumask_first(cpu_online_mask); 29994df7de0SSebastien Dugue 30094df7de0SSebastien Dugue tick_do_timer_cpu = (cpu < nr_cpu_ids) ? cpu : 30194df7de0SSebastien Dugue TICK_DO_TIMER_NONE; 30294df7de0SSebastien Dugue } 30394df7de0SSebastien Dugue } 30494df7de0SSebastien Dugue 30594df7de0SSebastien Dugue /* 306906568c9SThomas Gleixner * Shutdown an event device on a given cpu: 307906568c9SThomas Gleixner * 308906568c9SThomas Gleixner * This is called on a life CPU, when a CPU is dead. So we cannot 309906568c9SThomas Gleixner * access the hardware device itself. 310906568c9SThomas Gleixner * We just set the mode and remove it from the lists. 311906568c9SThomas Gleixner */ 312906568c9SThomas Gleixner static void tick_shutdown(unsigned int *cpup) 313906568c9SThomas Gleixner { 314906568c9SThomas Gleixner struct tick_device *td = &per_cpu(tick_cpu_device, *cpup); 315906568c9SThomas Gleixner struct clock_event_device *dev = td->evtdev; 316906568c9SThomas Gleixner unsigned long flags; 317906568c9SThomas Gleixner 318b5f91da0SThomas Gleixner raw_spin_lock_irqsave(&tick_device_lock, flags); 319906568c9SThomas Gleixner td->mode = TICKDEV_MODE_PERIODIC; 320906568c9SThomas Gleixner if (dev) { 321906568c9SThomas Gleixner /* 322906568c9SThomas Gleixner * Prevent that the clock events layer tries to call 323906568c9SThomas Gleixner * the set mode function! 324906568c9SThomas Gleixner */ 325906568c9SThomas Gleixner dev->mode = CLOCK_EVT_MODE_UNUSED; 326906568c9SThomas Gleixner clockevents_exchange_device(dev, NULL); 327906568c9SThomas Gleixner td->evtdev = NULL; 328906568c9SThomas Gleixner } 329b5f91da0SThomas Gleixner raw_spin_unlock_irqrestore(&tick_device_lock, flags); 330906568c9SThomas Gleixner } 331906568c9SThomas Gleixner 332cd05a1f8SThomas Gleixner static void tick_suspend(void) 3336321dd60SThomas Gleixner { 3346321dd60SThomas Gleixner struct tick_device *td = &__get_cpu_var(tick_cpu_device); 3356321dd60SThomas Gleixner unsigned long flags; 3366321dd60SThomas Gleixner 337b5f91da0SThomas Gleixner raw_spin_lock_irqsave(&tick_device_lock, flags); 3382344abbcSThomas Gleixner clockevents_shutdown(td->evtdev); 339b5f91da0SThomas Gleixner raw_spin_unlock_irqrestore(&tick_device_lock, flags); 3406321dd60SThomas Gleixner } 3416321dd60SThomas Gleixner 342cd05a1f8SThomas Gleixner static void tick_resume(void) 3436321dd60SThomas Gleixner { 3446321dd60SThomas Gleixner struct tick_device *td = &__get_cpu_var(tick_cpu_device); 3456321dd60SThomas Gleixner unsigned long flags; 34618de5bc4SThomas Gleixner int broadcast = tick_resume_broadcast(); 3476321dd60SThomas Gleixner 348b5f91da0SThomas Gleixner raw_spin_lock_irqsave(&tick_device_lock, flags); 34918de5bc4SThomas Gleixner clockevents_set_mode(td->evtdev, CLOCK_EVT_MODE_RESUME); 35018de5bc4SThomas Gleixner 35118de5bc4SThomas Gleixner if (!broadcast) { 3526321dd60SThomas Gleixner if (td->mode == TICKDEV_MODE_PERIODIC) 3536321dd60SThomas Gleixner tick_setup_periodic(td->evtdev, 0); 354cd05a1f8SThomas Gleixner else 355cd05a1f8SThomas Gleixner tick_resume_oneshot(); 35618de5bc4SThomas Gleixner } 357b5f91da0SThomas Gleixner raw_spin_unlock_irqrestore(&tick_device_lock, flags); 3586321dd60SThomas Gleixner } 3596321dd60SThomas Gleixner 360906568c9SThomas Gleixner /* 361906568c9SThomas Gleixner * Notification about clock event devices 362906568c9SThomas Gleixner */ 363906568c9SThomas Gleixner static int tick_notify(struct notifier_block *nb, unsigned long reason, 364906568c9SThomas Gleixner void *dev) 365906568c9SThomas Gleixner { 366906568c9SThomas Gleixner switch (reason) { 367906568c9SThomas Gleixner 368906568c9SThomas Gleixner case CLOCK_EVT_NOTIFY_ADD: 369906568c9SThomas Gleixner return tick_check_new_device(dev); 370906568c9SThomas Gleixner 371f8381cbaSThomas Gleixner case CLOCK_EVT_NOTIFY_BROADCAST_ON: 372f8381cbaSThomas Gleixner case CLOCK_EVT_NOTIFY_BROADCAST_OFF: 3731595f452SThomas Gleixner case CLOCK_EVT_NOTIFY_BROADCAST_FORCE: 374f8381cbaSThomas Gleixner tick_broadcast_on_off(reason, dev); 375f8381cbaSThomas Gleixner break; 376f8381cbaSThomas Gleixner 37779bf2bb3SThomas Gleixner case CLOCK_EVT_NOTIFY_BROADCAST_ENTER: 37879bf2bb3SThomas Gleixner case CLOCK_EVT_NOTIFY_BROADCAST_EXIT: 37979bf2bb3SThomas Gleixner tick_broadcast_oneshot_control(reason); 38079bf2bb3SThomas Gleixner break; 38179bf2bb3SThomas Gleixner 38294df7de0SSebastien Dugue case CLOCK_EVT_NOTIFY_CPU_DYING: 38394df7de0SSebastien Dugue tick_handover_do_timer(dev); 38494df7de0SSebastien Dugue break; 38594df7de0SSebastien Dugue 386906568c9SThomas Gleixner case CLOCK_EVT_NOTIFY_CPU_DEAD: 38779bf2bb3SThomas Gleixner tick_shutdown_broadcast_oneshot(dev); 388f8381cbaSThomas Gleixner tick_shutdown_broadcast(dev); 389906568c9SThomas Gleixner tick_shutdown(dev); 390906568c9SThomas Gleixner break; 391906568c9SThomas Gleixner 3926321dd60SThomas Gleixner case CLOCK_EVT_NOTIFY_SUSPEND: 393cd05a1f8SThomas Gleixner tick_suspend(); 3946321dd60SThomas Gleixner tick_suspend_broadcast(); 3956321dd60SThomas Gleixner break; 3966321dd60SThomas Gleixner 3976321dd60SThomas Gleixner case CLOCK_EVT_NOTIFY_RESUME: 398cd05a1f8SThomas Gleixner tick_resume(); 3996321dd60SThomas Gleixner break; 4006321dd60SThomas Gleixner 401906568c9SThomas Gleixner default: 402906568c9SThomas Gleixner break; 403906568c9SThomas Gleixner } 404906568c9SThomas Gleixner 405906568c9SThomas Gleixner return NOTIFY_OK; 406906568c9SThomas Gleixner } 407906568c9SThomas Gleixner 408906568c9SThomas Gleixner static struct notifier_block tick_notifier = { 409906568c9SThomas Gleixner .notifier_call = tick_notify, 410906568c9SThomas Gleixner }; 411906568c9SThomas Gleixner 412906568c9SThomas Gleixner /** 413906568c9SThomas Gleixner * tick_init - initialize the tick control 414906568c9SThomas Gleixner * 415906568c9SThomas Gleixner * Register the notifier with the clockevents framework 416906568c9SThomas Gleixner */ 417906568c9SThomas Gleixner void __init tick_init(void) 418906568c9SThomas Gleixner { 419906568c9SThomas Gleixner clockevents_register_notifier(&tick_notifier); 420906568c9SThomas Gleixner } 421