blob: 4790037163f6e001c6aa4cd1d06f9b64c9188970 [file] [log] [blame]
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -08001/*
2 * linux/kernel/time/tick-broadcast.c
3 *
4 * This file contains functions which emulate a local clock-event
5 * device via a broadcast event source.
6 *
7 * Copyright(C) 2005-2006, Thomas Gleixner <tglx@linutronix.de>
8 * Copyright(C) 2005-2007, Red Hat, Inc., Ingo Molnar
9 * Copyright(C) 2006-2007, Timesys Corp., Thomas Gleixner
10 *
11 * This code is licenced under the GPL version 2. For details see
12 * kernel-base/COPYING.
13 */
14#include <linux/cpu.h>
15#include <linux/err.h>
16#include <linux/hrtimer.h>
Russell Kingd7b90682008-04-17 07:46:24 +020017#include <linux/interrupt.h>
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080018#include <linux/percpu.h>
19#include <linux/profile.h>
20#include <linux/sched.h>
Mark Rutland12ad1002013-01-14 17:05:22 +000021#include <linux/smp.h>
Thomas Gleixnerccf33d62013-04-25 20:31:49 +000022#include <linux/module.h>
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080023
24#include "tick-internal.h"
25
26/*
27 * Broadcast support for broken x86 hardware, where the local apic
28 * timer stops in C3 state.
29 */
30
Dmitri Vorobieva52f5c52009-05-01 13:10:21 -070031static struct tick_device tick_broadcast_device;
Thomas Gleixnerb352bc12013-03-05 14:25:32 +010032static cpumask_var_t tick_broadcast_mask;
33static cpumask_var_t tmpmask;
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +010034static DEFINE_RAW_SPINLOCK(tick_broadcast_lock);
Thomas Gleixneraa276e12008-06-09 19:15:00 +020035static int tick_broadcast_force;
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080036
Thomas Gleixner5590a532007-07-21 04:37:35 -070037#ifdef CONFIG_TICK_ONESHOT
38static void tick_broadcast_clear_oneshot(int cpu);
39#else
40static inline void tick_broadcast_clear_oneshot(int cpu) { }
41#endif
42
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080043/*
Ingo Molnar289f4802007-02-16 01:28:15 -080044 * Debugging: see timer_list.c
45 */
46struct tick_device *tick_get_broadcast_device(void)
47{
48 return &tick_broadcast_device;
49}
50
Rusty Russell6b954822009-01-01 10:12:25 +103051struct cpumask *tick_get_broadcast_mask(void)
Ingo Molnar289f4802007-02-16 01:28:15 -080052{
Thomas Gleixnerb352bc12013-03-05 14:25:32 +010053 return tick_broadcast_mask;
Ingo Molnar289f4802007-02-16 01:28:15 -080054}
55
56/*
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080057 * Start the device in periodic mode
58 */
59static void tick_broadcast_start_periodic(struct clock_event_device *bc)
60{
Thomas Gleixner18de5bc2007-07-21 04:37:34 -070061 if (bc)
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080062 tick_setup_periodic(bc, 1);
63}
64
65/*
66 * Check, if the device can be utilized as broadcast device:
67 */
Thomas Gleixner45cb8e02013-04-25 20:31:50 +000068static bool tick_check_broadcast_device(struct clock_event_device *curdev,
69 struct clock_event_device *newdev)
70{
71 if ((newdev->features & CLOCK_EVT_FEAT_DUMMY) ||
72 (newdev->features & CLOCK_EVT_FEAT_C3STOP))
73 return false;
74
75 if (tick_broadcast_device.mode == TICKDEV_MODE_ONESHOT &&
76 !(newdev->features & CLOCK_EVT_FEAT_ONESHOT))
77 return false;
78
79 return !curdev || newdev->rating > curdev->rating;
80}
81
82/*
83 * Conditionally install/replace broadcast device
84 */
Thomas Gleixner7172a282013-04-25 20:31:47 +000085void tick_install_broadcast_device(struct clock_event_device *dev)
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080086{
Thomas Gleixner6f7a05d2013-04-25 11:45:53 +020087 struct clock_event_device *cur = tick_broadcast_device.evtdev;
88
Thomas Gleixner45cb8e02013-04-25 20:31:50 +000089 if (!tick_check_broadcast_device(cur, dev))
Thomas Gleixner7172a282013-04-25 20:31:47 +000090 return;
Thomas Gleixner45cb8e02013-04-25 20:31:50 +000091
Thomas Gleixnerccf33d62013-04-25 20:31:49 +000092 if (!try_module_get(dev->owner))
93 return;
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080094
Thomas Gleixner45cb8e02013-04-25 20:31:50 +000095 clockevents_exchange_device(cur, dev);
Thomas Gleixner6f7a05d2013-04-25 11:45:53 +020096 if (cur)
97 cur->event_handler = clockevents_handle_noop;
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -080098 tick_broadcast_device.evtdev = dev;
Thomas Gleixnerb352bc12013-03-05 14:25:32 +010099 if (!cpumask_empty(tick_broadcast_mask))
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800100 tick_broadcast_start_periodic(dev);
Stephen Boydc038c1c2013-04-17 10:26:06 -0700101 /*
102 * Inform all cpus about this. We might be in a situation
103 * where we did not switch to oneshot mode because the per cpu
104 * devices are affected by CLOCK_EVT_FEAT_C3STOP and the lack
105 * of a oneshot capable broadcast device. Without that
106 * notification the systems stays stuck in periodic mode
107 * forever.
108 */
109 if (dev->features & CLOCK_EVT_FEAT_ONESHOT)
110 tick_clock_notify();
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800111}
112
113/*
114 * Check, if the device is the broadcast device
115 */
116int tick_is_broadcast_device(struct clock_event_device *dev)
117{
118 return (dev && tick_broadcast_device.evtdev == dev);
119}
120
Mark Rutland12ad1002013-01-14 17:05:22 +0000121static void err_broadcast(const struct cpumask *mask)
122{
123 pr_crit_once("Failed to broadcast timer tick. Some CPUs may be unresponsive.\n");
124}
125
Mark Rutland5d1d9a22013-02-08 15:24:07 +0000126static void tick_device_setup_broadcast_func(struct clock_event_device *dev)
127{
128 if (!dev->broadcast)
129 dev->broadcast = tick_broadcast;
130 if (!dev->broadcast) {
131 pr_warn_once("%s depends on broadcast, but no broadcast function available\n",
132 dev->name);
133 dev->broadcast = err_broadcast;
134 }
135}
136
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800137/*
138 * Check, if the device is disfunctional and a place holder, which
139 * needs to be handled by the broadcast device.
140 */
141int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
142{
143 unsigned long flags;
144 int ret = 0;
145
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100146 raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800147
148 /*
149 * Devices might be registered with both periodic and oneshot
150 * mode disabled. This signals, that the device needs to be
151 * operated from the broadcast device and is a placeholder for
152 * the cpu local device.
153 */
154 if (!tick_device_is_functional(dev)) {
155 dev->event_handler = tick_handle_periodic;
Mark Rutland5d1d9a22013-02-08 15:24:07 +0000156 tick_device_setup_broadcast_func(dev);
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100157 cpumask_set_cpu(cpu, tick_broadcast_mask);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800158 tick_broadcast_start_periodic(tick_broadcast_device.evtdev);
159 ret = 1;
Thomas Gleixner5590a532007-07-21 04:37:35 -0700160 } else {
161 /*
162 * When the new device is not affected by the stop
163 * feature and the cpu is marked in the broadcast mask
164 * then clear the broadcast bit.
165 */
166 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
167 int cpu = smp_processor_id();
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100168 cpumask_clear_cpu(cpu, tick_broadcast_mask);
Thomas Gleixner5590a532007-07-21 04:37:35 -0700169 tick_broadcast_clear_oneshot(cpu);
Mark Rutland5d1d9a22013-02-08 15:24:07 +0000170 } else {
171 tick_device_setup_broadcast_func(dev);
Thomas Gleixner5590a532007-07-21 04:37:35 -0700172 }
173 }
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100174 raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800175 return ret;
176}
177
Mark Rutland12572db2013-01-14 17:05:21 +0000178#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
179int tick_receive_broadcast(void)
180{
181 struct tick_device *td = this_cpu_ptr(&tick_cpu_device);
182 struct clock_event_device *evt = td->evtdev;
183
184 if (!evt)
185 return -ENODEV;
186
187 if (!evt->event_handler)
188 return -EINVAL;
189
190 evt->event_handler(evt);
191 return 0;
192}
193#endif
194
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800195/*
Rusty Russell6b954822009-01-01 10:12:25 +1030196 * Broadcast the event to the cpus, which are set in the mask (mangled).
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800197 */
Rusty Russell6b954822009-01-01 10:12:25 +1030198static void tick_do_broadcast(struct cpumask *mask)
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800199{
Thomas Gleixner186e3cb2008-01-30 13:30:01 +0100200 int cpu = smp_processor_id();
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800201 struct tick_device *td;
202
203 /*
204 * Check, if the current cpu is in the mask
205 */
Rusty Russell6b954822009-01-01 10:12:25 +1030206 if (cpumask_test_cpu(cpu, mask)) {
207 cpumask_clear_cpu(cpu, mask);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800208 td = &per_cpu(tick_cpu_device, cpu);
209 td->evtdev->event_handler(td->evtdev);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800210 }
211
Rusty Russell6b954822009-01-01 10:12:25 +1030212 if (!cpumask_empty(mask)) {
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800213 /*
214 * It might be necessary to actually check whether the devices
215 * have different broadcast functions. For now, just use the
216 * one of the first device. This works as long as we have this
217 * misfeature only on x86 (lapic)
218 */
Rusty Russell6b954822009-01-01 10:12:25 +1030219 td = &per_cpu(tick_cpu_device, cpumask_first(mask));
220 td->evtdev->broadcast(mask);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800221 }
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800222}
223
224/*
225 * Periodic broadcast:
226 * - invoke the broadcast handlers
227 */
228static void tick_do_periodic_broadcast(void)
229{
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100230 raw_spin_lock(&tick_broadcast_lock);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800231
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100232 cpumask_and(tmpmask, cpu_online_mask, tick_broadcast_mask);
233 tick_do_broadcast(tmpmask);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800234
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100235 raw_spin_unlock(&tick_broadcast_lock);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800236}
237
238/*
239 * Event handler for periodic broadcast ticks
240 */
241static void tick_handle_periodic_broadcast(struct clock_event_device *dev)
242{
Thomas Gleixnerd4496b32008-09-03 21:36:57 +0000243 ktime_t next;
244
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800245 tick_do_periodic_broadcast();
246
247 /*
248 * The device is in periodic mode. No reprogramming necessary:
249 */
250 if (dev->mode == CLOCK_EVT_MODE_PERIODIC)
251 return;
252
253 /*
254 * Setup the next period for devices, which do not have
Thomas Gleixnerd4496b32008-09-03 21:36:57 +0000255 * periodic mode. We read dev->next_event first and add to it
Uwe Kleine-König698f9312010-07-02 20:41:51 +0200256 * when the event already expired. clockevents_program_event()
Thomas Gleixnerd4496b32008-09-03 21:36:57 +0000257 * sets dev->next_event only when the event is really
258 * programmed to the device.
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800259 */
Thomas Gleixnerd4496b32008-09-03 21:36:57 +0000260 for (next = dev->next_event; ;) {
261 next = ktime_add(next, tick_period);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800262
Martin Schwidefskyd1748302011-08-23 15:29:42 +0200263 if (!clockevents_program_event(dev, next, false))
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800264 return;
265 tick_do_periodic_broadcast();
266 }
267}
268
269/*
270 * Powerstate information: The system enters/leaves a state, where
271 * affected devices might stop
272 */
Suresh Siddhaf833bab2009-08-17 14:34:59 -0700273static void tick_do_broadcast_on_off(unsigned long *reason)
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800274{
275 struct clock_event_device *bc, *dev;
276 struct tick_device *td;
Suresh Siddhaf833bab2009-08-17 14:34:59 -0700277 unsigned long flags;
Thomas Gleixner9c17bcd2008-09-03 21:37:08 +0000278 int cpu, bc_stopped;
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800279
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100280 raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800281
282 cpu = smp_processor_id();
283 td = &per_cpu(tick_cpu_device, cpu);
284 dev = td->evtdev;
285 bc = tick_broadcast_device.evtdev;
286
287 /*
Thomas Gleixner1595f452007-10-14 22:57:45 +0200288 * Is the device not affected by the powerstate ?
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800289 */
Thomas Gleixner1595f452007-10-14 22:57:45 +0200290 if (!dev || !(dev->features & CLOCK_EVT_FEAT_C3STOP))
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800291 goto out;
292
Thomas Gleixner3dfbc882007-10-17 18:04:32 +0200293 if (!tick_device_is_functional(dev))
294 goto out;
Thomas Gleixner1595f452007-10-14 22:57:45 +0200295
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100296 bc_stopped = cpumask_empty(tick_broadcast_mask);
Thomas Gleixner9c17bcd2008-09-03 21:37:08 +0000297
Thomas Gleixner1595f452007-10-14 22:57:45 +0200298 switch (*reason) {
299 case CLOCK_EVT_NOTIFY_BROADCAST_ON:
300 case CLOCK_EVT_NOTIFY_BROADCAST_FORCE:
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100301 if (!cpumask_test_and_set_cpu(cpu, tick_broadcast_mask)) {
Thomas Gleixner07454bf2008-10-04 10:51:07 +0200302 if (tick_broadcast_device.mode ==
303 TICKDEV_MODE_PERIODIC)
Thomas Gleixner2344abb2008-09-16 11:32:50 -0700304 clockevents_shutdown(dev);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800305 }
Thomas Gleixner3dfbc882007-10-17 18:04:32 +0200306 if (*reason == CLOCK_EVT_NOTIFY_BROADCAST_FORCE)
Thomas Gleixneraa276e12008-06-09 19:15:00 +0200307 tick_broadcast_force = 1;
Thomas Gleixner1595f452007-10-14 22:57:45 +0200308 break;
309 case CLOCK_EVT_NOTIFY_BROADCAST_OFF:
Thomas Gleixneraa276e12008-06-09 19:15:00 +0200310 if (!tick_broadcast_force &&
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100311 cpumask_test_and_clear_cpu(cpu, tick_broadcast_mask)) {
Thomas Gleixner07454bf2008-10-04 10:51:07 +0200312 if (tick_broadcast_device.mode ==
313 TICKDEV_MODE_PERIODIC)
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800314 tick_setup_periodic(dev, 0);
315 }
Thomas Gleixner1595f452007-10-14 22:57:45 +0200316 break;
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800317 }
318
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100319 if (cpumask_empty(tick_broadcast_mask)) {
Thomas Gleixner9c17bcd2008-09-03 21:37:08 +0000320 if (!bc_stopped)
Thomas Gleixner2344abb2008-09-16 11:32:50 -0700321 clockevents_shutdown(bc);
Thomas Gleixner9c17bcd2008-09-03 21:37:08 +0000322 } else if (bc_stopped) {
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800323 if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC)
324 tick_broadcast_start_periodic(bc);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800325 else
326 tick_broadcast_setup_oneshot(bc);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800327 }
328out:
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100329 raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800330}
331
332/*
333 * Powerstate information: The system enters/leaves a state, where
334 * affected devices might stop.
335 */
336void tick_broadcast_on_off(unsigned long reason, int *oncpu)
337{
Rusty Russell6b954822009-01-01 10:12:25 +1030338 if (!cpumask_test_cpu(*oncpu, cpu_online_mask))
Glauber Costa833df312008-04-18 13:38:58 -0700339 printk(KERN_ERR "tick-broadcast: ignoring broadcast for "
Thomas Gleixner72fcde92007-05-23 13:57:30 -0700340 "offline CPU #%d\n", *oncpu);
Avi Kivitybf020cb2007-10-16 23:26:24 -0700341 else
Suresh Siddhaf833bab2009-08-17 14:34:59 -0700342 tick_do_broadcast_on_off(&reason);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800343}
344
345/*
346 * Set the periodic handler depending on broadcast on/off
347 */
348void tick_set_periodic_handler(struct clock_event_device *dev, int broadcast)
349{
350 if (!broadcast)
351 dev->event_handler = tick_handle_periodic;
352 else
353 dev->event_handler = tick_handle_periodic_broadcast;
354}
355
356/*
357 * Remove a CPU from broadcasting
358 */
359void tick_shutdown_broadcast(unsigned int *cpup)
360{
361 struct clock_event_device *bc;
362 unsigned long flags;
363 unsigned int cpu = *cpup;
364
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100365 raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800366
367 bc = tick_broadcast_device.evtdev;
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100368 cpumask_clear_cpu(cpu, tick_broadcast_mask);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800369
370 if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) {
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100371 if (bc && cpumask_empty(tick_broadcast_mask))
Thomas Gleixner2344abb2008-09-16 11:32:50 -0700372 clockevents_shutdown(bc);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800373 }
374
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100375 raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
Thomas Gleixnerf8381cb2007-02-16 01:28:02 -0800376}
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800377
Thomas Gleixner6321dd62007-03-06 08:25:42 +0100378void tick_suspend_broadcast(void)
379{
380 struct clock_event_device *bc;
381 unsigned long flags;
382
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100383 raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
Thomas Gleixner6321dd62007-03-06 08:25:42 +0100384
385 bc = tick_broadcast_device.evtdev;
Thomas Gleixner18de5bc2007-07-21 04:37:34 -0700386 if (bc)
Thomas Gleixner2344abb2008-09-16 11:32:50 -0700387 clockevents_shutdown(bc);
Thomas Gleixner6321dd62007-03-06 08:25:42 +0100388
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100389 raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
Thomas Gleixner6321dd62007-03-06 08:25:42 +0100390}
391
392int tick_resume_broadcast(void)
393{
394 struct clock_event_device *bc;
395 unsigned long flags;
396 int broadcast = 0;
397
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100398 raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
Thomas Gleixner6321dd62007-03-06 08:25:42 +0100399
400 bc = tick_broadcast_device.evtdev;
Thomas Gleixner6321dd62007-03-06 08:25:42 +0100401
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +0100402 if (bc) {
Thomas Gleixner18de5bc2007-07-21 04:37:34 -0700403 clockevents_set_mode(bc, CLOCK_EVT_MODE_RESUME);
404
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +0100405 switch (tick_broadcast_device.mode) {
406 case TICKDEV_MODE_PERIODIC:
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100407 if (!cpumask_empty(tick_broadcast_mask))
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +0100408 tick_broadcast_start_periodic(bc);
Rusty Russell6b954822009-01-01 10:12:25 +1030409 broadcast = cpumask_test_cpu(smp_processor_id(),
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100410 tick_broadcast_mask);
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +0100411 break;
412 case TICKDEV_MODE_ONESHOT:
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100413 if (!cpumask_empty(tick_broadcast_mask))
Suresh Siddhaa6371f82012-04-18 19:27:39 -0700414 broadcast = tick_resume_broadcast_oneshot(bc);
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +0100415 break;
416 }
Thomas Gleixner6321dd62007-03-06 08:25:42 +0100417 }
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100418 raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
Thomas Gleixner6321dd62007-03-06 08:25:42 +0100419
420 return broadcast;
421}
422
423
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800424#ifdef CONFIG_TICK_ONESHOT
425
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100426static cpumask_var_t tick_broadcast_oneshot_mask;
Thomas Gleixner26517f32013-03-06 11:18:35 +0000427static cpumask_var_t tick_broadcast_pending_mask;
Thomas Gleixner989dcb62013-03-06 11:18:35 +0000428static cpumask_var_t tick_broadcast_force_mask;
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800429
Ingo Molnar289f4802007-02-16 01:28:15 -0800430/*
Rusty Russell6b954822009-01-01 10:12:25 +1030431 * Exposed for debugging: see timer_list.c
Ingo Molnar289f4802007-02-16 01:28:15 -0800432 */
Rusty Russell6b954822009-01-01 10:12:25 +1030433struct cpumask *tick_get_broadcast_oneshot_mask(void)
Ingo Molnar289f4802007-02-16 01:28:15 -0800434{
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100435 return tick_broadcast_oneshot_mask;
Ingo Molnar289f4802007-02-16 01:28:15 -0800436}
437
Daniel Lezcanod2348fb2013-03-02 11:10:11 +0100438/*
Thomas Gleixnereaa907c2013-03-06 11:18:36 +0000439 * Called before going idle with interrupts disabled. Checks whether a
440 * broadcast event from the other core is about to happen. We detected
441 * that in tick_broadcast_oneshot_control(). The callsite can use this
442 * to avoid a deep idle transition as we are about to get the
443 * broadcast IPI right away.
444 */
445int tick_check_broadcast_expired(void)
446{
447 return cpumask_test_cpu(smp_processor_id(), tick_broadcast_force_mask);
448}
449
450/*
Daniel Lezcanod2348fb2013-03-02 11:10:11 +0100451 * Set broadcast interrupt affinity
452 */
453static void tick_broadcast_set_affinity(struct clock_event_device *bc,
454 const struct cpumask *cpumask)
455{
456 if (!(bc->features & CLOCK_EVT_FEAT_DYNIRQ))
457 return;
458
459 if (cpumask_equal(bc->cpumask, cpumask))
460 return;
461
462 bc->cpumask = cpumask;
463 irq_set_affinity(bc->irq, bc->cpumask);
464}
465
466static int tick_broadcast_set_event(struct clock_event_device *bc, int cpu,
Daniel Lezcanof9ae39d2013-03-02 11:10:10 +0100467 ktime_t expires, int force)
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800468{
Daniel Lezcanod2348fb2013-03-02 11:10:11 +0100469 int ret;
470
Thomas Gleixnerb9a6a2352012-04-18 17:31:58 +0200471 if (bc->mode != CLOCK_EVT_MODE_ONESHOT)
472 clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT);
473
Daniel Lezcanod2348fb2013-03-02 11:10:11 +0100474 ret = clockevents_program_event(bc, expires, force);
475 if (!ret)
476 tick_broadcast_set_affinity(bc, cpumask_of(cpu));
477 return ret;
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800478}
479
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +0100480int tick_resume_broadcast_oneshot(struct clock_event_device *bc)
481{
482 clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT);
Thomas Gleixnerb7e113d2007-09-22 22:29:06 +0000483 return 0;
Thomas Gleixnercd05a1f2007-03-17 00:25:52 +0100484}
485
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800486/*
Thomas Gleixnerfb02fbc2008-10-17 10:01:23 +0200487 * Called from irq_enter() when idle was interrupted to reenable the
488 * per cpu device.
489 */
490void tick_check_oneshot_broadcast(int cpu)
491{
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100492 if (cpumask_test_cpu(cpu, tick_broadcast_oneshot_mask)) {
Thomas Gleixnerfb02fbc2008-10-17 10:01:23 +0200493 struct tick_device *td = &per_cpu(tick_cpu_device, cpu);
494
495 clockevents_set_mode(td->evtdev, CLOCK_EVT_MODE_ONESHOT);
496 }
497}
498
499/*
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800500 * Handle oneshot mode broadcasting
501 */
502static void tick_handle_oneshot_broadcast(struct clock_event_device *dev)
503{
504 struct tick_device *td;
Thomas Gleixnercdc6f272007-12-18 18:05:58 +0100505 ktime_t now, next_event;
Daniel Lezcanod2348fb2013-03-02 11:10:11 +0100506 int cpu, next_cpu = 0;
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800507
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100508 raw_spin_lock(&tick_broadcast_lock);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800509again:
510 dev->next_event.tv64 = KTIME_MAX;
Thomas Gleixnercdc6f272007-12-18 18:05:58 +0100511 next_event.tv64 = KTIME_MAX;
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100512 cpumask_clear(tmpmask);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800513 now = ktime_get();
514 /* Find all expired events */
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100515 for_each_cpu(cpu, tick_broadcast_oneshot_mask) {
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800516 td = &per_cpu(tick_cpu_device, cpu);
Daniel Lezcanod2348fb2013-03-02 11:10:11 +0100517 if (td->evtdev->next_event.tv64 <= now.tv64) {
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100518 cpumask_set_cpu(cpu, tmpmask);
Thomas Gleixner26517f32013-03-06 11:18:35 +0000519 /*
520 * Mark the remote cpu in the pending mask, so
521 * it can avoid reprogramming the cpu local
522 * timer in tick_broadcast_oneshot_control().
523 */
524 cpumask_set_cpu(cpu, tick_broadcast_pending_mask);
Daniel Lezcanod2348fb2013-03-02 11:10:11 +0100525 } else if (td->evtdev->next_event.tv64 < next_event.tv64) {
Thomas Gleixnercdc6f272007-12-18 18:05:58 +0100526 next_event.tv64 = td->evtdev->next_event.tv64;
Daniel Lezcanod2348fb2013-03-02 11:10:11 +0100527 next_cpu = cpu;
528 }
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800529 }
530
Thomas Gleixner989dcb62013-03-06 11:18:35 +0000531 /* Take care of enforced broadcast requests */
532 cpumask_or(tmpmask, tmpmask, tick_broadcast_force_mask);
533 cpumask_clear(tick_broadcast_force_mask);
534
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800535 /*
Thomas Gleixnerc9b5a262013-06-26 12:17:32 +0200536 * Sanity check. Catch the case where we try to broadcast to
537 * offline cpus.
538 */
539 if (WARN_ON_ONCE(!cpumask_subset(tmpmask, cpu_online_mask)))
540 cpumask_and(tmpmask, tmpmask, cpu_online_mask);
541
542 /*
Thomas Gleixnercdc6f272007-12-18 18:05:58 +0100543 * Wakeup the cpus which have an expired event.
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800544 */
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100545 tick_do_broadcast(tmpmask);
Thomas Gleixnercdc6f272007-12-18 18:05:58 +0100546
547 /*
548 * Two reasons for reprogram:
549 *
550 * - The global event did not expire any CPU local
551 * events. This happens in dyntick mode, as the maximum PIT
552 * delta is quite small.
553 *
554 * - There are pending events on sleeping CPUs which were not
555 * in the event mask
556 */
557 if (next_event.tv64 != KTIME_MAX) {
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800558 /*
Thomas Gleixnercdc6f272007-12-18 18:05:58 +0100559 * Rearm the broadcast device. If event expired,
560 * repeat the above
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800561 */
Daniel Lezcanod2348fb2013-03-02 11:10:11 +0100562 if (tick_broadcast_set_event(dev, next_cpu, next_event, 0))
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800563 goto again;
564 }
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100565 raw_spin_unlock(&tick_broadcast_lock);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800566}
567
568/*
569 * Powerstate information: The system enters/leaves a state, where
570 * affected devices might stop
571 */
572void tick_broadcast_oneshot_control(unsigned long reason)
573{
574 struct clock_event_device *bc, *dev;
575 struct tick_device *td;
576 unsigned long flags;
Thomas Gleixner989dcb62013-03-06 11:18:35 +0000577 ktime_t now;
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800578 int cpu;
579
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800580 /*
581 * Periodic mode does not care about the enter/exit of power
582 * states
583 */
584 if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC)
Andi Kleen7372b0b2011-05-04 15:09:27 -0700585 return;
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800586
Andi Kleen7372b0b2011-05-04 15:09:27 -0700587 /*
588 * We are called with preemtion disabled from the depth of the
589 * idle code, so we can't be moved away.
590 */
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800591 cpu = smp_processor_id();
592 td = &per_cpu(tick_cpu_device, cpu);
593 dev = td->evtdev;
594
595 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP))
Andi Kleen7372b0b2011-05-04 15:09:27 -0700596 return;
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800597
Andi Kleen7372b0b2011-05-04 15:09:27 -0700598 bc = tick_broadcast_device.evtdev;
599
600 raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800601 if (reason == CLOCK_EVT_NOTIFY_BROADCAST_ENTER) {
Thomas Gleixner26517f32013-03-06 11:18:35 +0000602 WARN_ON_ONCE(cpumask_test_cpu(cpu, tick_broadcast_pending_mask));
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100603 if (!cpumask_test_and_set_cpu(cpu, tick_broadcast_oneshot_mask)) {
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800604 clockevents_set_mode(dev, CLOCK_EVT_MODE_SHUTDOWN);
Thomas Gleixner989dcb62013-03-06 11:18:35 +0000605 /*
606 * We only reprogram the broadcast timer if we
607 * did not mark ourself in the force mask and
608 * if the cpu local event is earlier than the
609 * broadcast event. If the current CPU is in
610 * the force mask, then we are going to be
611 * woken by the IPI right away.
612 */
613 if (!cpumask_test_cpu(cpu, tick_broadcast_force_mask) &&
614 dev->next_event.tv64 < bc->next_event.tv64)
Daniel Lezcanod2348fb2013-03-02 11:10:11 +0100615 tick_broadcast_set_event(bc, cpu, dev->next_event, 1);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800616 }
617 } else {
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100618 if (cpumask_test_and_clear_cpu(cpu, tick_broadcast_oneshot_mask)) {
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800619 clockevents_set_mode(dev, CLOCK_EVT_MODE_ONESHOT);
Thomas Gleixner26517f32013-03-06 11:18:35 +0000620 if (dev->next_event.tv64 == KTIME_MAX)
621 goto out;
622 /*
623 * The cpu which was handling the broadcast
624 * timer marked this cpu in the broadcast
625 * pending mask and fired the broadcast
626 * IPI. So we are going to handle the expired
627 * event anyway via the broadcast IPI
628 * handler. No need to reprogram the timer
629 * with an already expired event.
630 */
631 if (cpumask_test_and_clear_cpu(cpu,
632 tick_broadcast_pending_mask))
633 goto out;
634
Thomas Gleixner989dcb62013-03-06 11:18:35 +0000635 /*
636 * If the pending bit is not set, then we are
637 * either the CPU handling the broadcast
638 * interrupt or we got woken by something else.
639 *
640 * We are not longer in the broadcast mask, so
641 * if the cpu local expiry time is already
642 * reached, we would reprogram the cpu local
643 * timer with an already expired event.
644 *
645 * This can lead to a ping-pong when we return
646 * to idle and therefor rearm the broadcast
647 * timer before the cpu local timer was able
648 * to fire. This happens because the forced
649 * reprogramming makes sure that the event
650 * will happen in the future and depending on
651 * the min_delta setting this might be far
652 * enough out that the ping-pong starts.
653 *
654 * If the cpu local next_event has expired
655 * then we know that the broadcast timer
656 * next_event has expired as well and
657 * broadcast is about to be handled. So we
658 * avoid reprogramming and enforce that the
659 * broadcast handler, which did not run yet,
660 * will invoke the cpu local handler.
661 *
662 * We cannot call the handler directly from
663 * here, because we might be in a NOHZ phase
664 * and we did not go through the irq_enter()
665 * nohz fixups.
666 */
667 now = ktime_get();
668 if (dev->next_event.tv64 <= now.tv64) {
669 cpumask_set_cpu(cpu, tick_broadcast_force_mask);
670 goto out;
671 }
672 /*
673 * We got woken by something else. Reprogram
674 * the cpu local timer device.
675 */
Thomas Gleixner26517f32013-03-06 11:18:35 +0000676 tick_program_event(dev->next_event, 1);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800677 }
678 }
Thomas Gleixner26517f32013-03-06 11:18:35 +0000679out:
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100680 raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800681}
682
Thomas Gleixner5590a532007-07-21 04:37:35 -0700683/*
684 * Reset the one shot broadcast for a cpu
685 *
686 * Called with tick_broadcast_lock held
687 */
688static void tick_broadcast_clear_oneshot(int cpu)
689{
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100690 cpumask_clear_cpu(cpu, tick_broadcast_oneshot_mask);
Thomas Gleixner5590a532007-07-21 04:37:35 -0700691}
692
Rusty Russell6b954822009-01-01 10:12:25 +1030693static void tick_broadcast_init_next_event(struct cpumask *mask,
694 ktime_t expires)
Thomas Gleixner73007112008-09-06 03:01:45 +0200695{
696 struct tick_device *td;
697 int cpu;
698
Rusty Russell5db0e1e2009-01-01 10:12:29 +1030699 for_each_cpu(cpu, mask) {
Thomas Gleixner73007112008-09-06 03:01:45 +0200700 td = &per_cpu(tick_cpu_device, cpu);
701 if (td->evtdev)
702 td->evtdev->next_event = expires;
703 }
704}
705
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800706/**
Li Zefan8dce39c2007-11-05 14:51:10 -0800707 * tick_broadcast_setup_oneshot - setup the broadcast device
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800708 */
709void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
710{
Thomas Gleixner07f4beb2011-05-16 11:07:48 +0200711 int cpu = smp_processor_id();
712
Thomas Gleixner9c17bcd2008-09-03 21:37:08 +0000713 /* Set it up only once ! */
714 if (bc->event_handler != tick_handle_oneshot_broadcast) {
Thomas Gleixner73007112008-09-06 03:01:45 +0200715 int was_periodic = bc->mode == CLOCK_EVT_MODE_PERIODIC;
Thomas Gleixner73007112008-09-06 03:01:45 +0200716
Thomas Gleixner9c17bcd2008-09-03 21:37:08 +0000717 bc->event_handler = tick_handle_oneshot_broadcast;
Thomas Gleixner73007112008-09-06 03:01:45 +0200718
719 /* Take the do_timer update */
Frederic Weisbeckerc5bfece2013-04-12 16:45:34 +0200720 if (!tick_nohz_full_cpu(cpu))
Frederic Weisbeckera382bf92012-12-18 18:24:35 +0100721 tick_do_timer_cpu = cpu;
Thomas Gleixner73007112008-09-06 03:01:45 +0200722
723 /*
724 * We must be careful here. There might be other CPUs
725 * waiting for periodic broadcast. We need to set the
726 * oneshot_mask bits for those and program the
727 * broadcast device to fire.
728 */
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100729 cpumask_copy(tmpmask, tick_broadcast_mask);
730 cpumask_clear_cpu(cpu, tmpmask);
731 cpumask_or(tick_broadcast_oneshot_mask,
732 tick_broadcast_oneshot_mask, tmpmask);
Thomas Gleixner73007112008-09-06 03:01:45 +0200733
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100734 if (was_periodic && !cpumask_empty(tmpmask)) {
Thomas Gleixnerb4350922012-04-18 12:08:23 +0200735 clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT);
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100736 tick_broadcast_init_next_event(tmpmask,
Rusty Russell6b954822009-01-01 10:12:25 +1030737 tick_next_period);
Daniel Lezcanod2348fb2013-03-02 11:10:11 +0100738 tick_broadcast_set_event(bc, cpu, tick_next_period, 1);
Thomas Gleixner73007112008-09-06 03:01:45 +0200739 } else
740 bc->next_event.tv64 = KTIME_MAX;
Thomas Gleixner07f4beb2011-05-16 11:07:48 +0200741 } else {
742 /*
743 * The first cpu which switches to oneshot mode sets
744 * the bit for all other cpus which are in the general
745 * (periodic) broadcast mask. So the bit is set and
746 * would prevent the first broadcast enter after this
747 * to program the bc device.
748 */
749 tick_broadcast_clear_oneshot(cpu);
Thomas Gleixner9c17bcd2008-09-03 21:37:08 +0000750 }
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800751}
752
753/*
754 * Select oneshot operating mode for the broadcast device
755 */
756void tick_broadcast_switch_to_oneshot(void)
757{
758 struct clock_event_device *bc;
759 unsigned long flags;
760
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100761 raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
Suresh Siddhafa4da362012-04-09 15:41:44 -0700762
763 tick_broadcast_device.mode = TICKDEV_MODE_ONESHOT;
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800764 bc = tick_broadcast_device.evtdev;
765 if (bc)
766 tick_broadcast_setup_oneshot(bc);
Suresh Siddha77b0d602011-11-04 17:18:21 -0700767
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100768 raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800769}
770
771
772/*
773 * Remove a dead CPU from broadcasting
774 */
775void tick_shutdown_broadcast_oneshot(unsigned int *cpup)
776{
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800777 unsigned long flags;
778 unsigned int cpu = *cpup;
779
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100780 raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800781
Thomas Gleixner31d9b392007-09-16 15:36:43 +0200782 /*
Thomas Gleixnerc9b5a262013-06-26 12:17:32 +0200783 * Clear the broadcast masks for the dead cpu, but do not stop
784 * the broadcast device!
Thomas Gleixner31d9b392007-09-16 15:36:43 +0200785 */
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100786 cpumask_clear_cpu(cpu, tick_broadcast_oneshot_mask);
Thomas Gleixnerc9b5a262013-06-26 12:17:32 +0200787 cpumask_clear_cpu(cpu, tick_broadcast_pending_mask);
788 cpumask_clear_cpu(cpu, tick_broadcast_force_mask);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800789
Thomas Gleixnerb5f91da2009-12-08 12:40:31 +0100790 raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800791}
792
Thomas Gleixner27ce4cb2008-09-22 19:04:02 +0200793/*
794 * Check, whether the broadcast device is in one shot mode
795 */
796int tick_broadcast_oneshot_active(void)
797{
798 return tick_broadcast_device.mode == TICKDEV_MODE_ONESHOT;
799}
800
Thomas Gleixner3a142a02011-02-25 22:34:23 +0100801/*
802 * Check whether the broadcast device supports oneshot.
803 */
804bool tick_broadcast_oneshot_available(void)
805{
806 struct clock_event_device *bc = tick_broadcast_device.evtdev;
807
808 return bc ? bc->features & CLOCK_EVT_FEAT_ONESHOT : false;
809}
810
Thomas Gleixner79bf2bb2007-02-16 01:28:03 -0800811#endif
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100812
813void __init tick_broadcast_init(void)
814{
Thomas Gleixnerfbd44a62013-05-03 20:22:36 +0200815 zalloc_cpumask_var(&tick_broadcast_mask, GFP_NOWAIT);
816 zalloc_cpumask_var(&tmpmask, GFP_NOWAIT);
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100817#ifdef CONFIG_TICK_ONESHOT
Thomas Gleixnerfbd44a62013-05-03 20:22:36 +0200818 zalloc_cpumask_var(&tick_broadcast_oneshot_mask, GFP_NOWAIT);
819 zalloc_cpumask_var(&tick_broadcast_pending_mask, GFP_NOWAIT);
820 zalloc_cpumask_var(&tick_broadcast_force_mask, GFP_NOWAIT);
Thomas Gleixnerb352bc12013-03-05 14:25:32 +0100821#endif
822}