diff options
Diffstat (limited to 'drivers/clocksource/arm_global_timer.c')
-rw-r--r-- | drivers/clocksource/arm_global_timer.c | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/drivers/clocksource/arm_global_timer.c b/drivers/clocksource/arm_global_timer.c index 2a9ceb6e93f9..8da03298f844 100644 --- a/drivers/clocksource/arm_global_timer.c +++ b/drivers/clocksource/arm_global_timer.c | |||
@@ -165,9 +165,9 @@ static irqreturn_t gt_clockevent_interrupt(int irq, void *dev_id) | |||
165 | return IRQ_HANDLED; | 165 | return IRQ_HANDLED; |
166 | } | 166 | } |
167 | 167 | ||
168 | static int gt_clockevents_init(struct clock_event_device *clk) | 168 | static int gt_starting_cpu(unsigned int cpu) |
169 | { | 169 | { |
170 | int cpu = smp_processor_id(); | 170 | struct clock_event_device *clk = this_cpu_ptr(gt_evt); |
171 | 171 | ||
172 | clk->name = "arm_global_timer"; | 172 | clk->name = "arm_global_timer"; |
173 | clk->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT | | 173 | clk->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT | |
@@ -186,10 +186,13 @@ static int gt_clockevents_init(struct clock_event_device *clk) | |||
186 | return 0; | 186 | return 0; |
187 | } | 187 | } |
188 | 188 | ||
189 | static void gt_clockevents_stop(struct clock_event_device *clk) | 189 | static int gt_dying_cpu(unsigned int cpu) |
190 | { | 190 | { |
191 | struct clock_event_device *clk = this_cpu_ptr(gt_evt); | ||
192 | |||
191 | gt_clockevent_shutdown(clk); | 193 | gt_clockevent_shutdown(clk); |
192 | disable_percpu_irq(clk->irq); | 194 | disable_percpu_irq(clk->irq); |
195 | return 0; | ||
193 | } | 196 | } |
194 | 197 | ||
195 | static cycle_t gt_clocksource_read(struct clocksource *cs) | 198 | static cycle_t gt_clocksource_read(struct clocksource *cs) |
@@ -252,24 +255,6 @@ static int __init gt_clocksource_init(void) | |||
252 | return clocksource_register_hz(>_clocksource, gt_clk_rate); | 255 | return clocksource_register_hz(>_clocksource, gt_clk_rate); |
253 | } | 256 | } |
254 | 257 | ||
255 | static int gt_cpu_notify(struct notifier_block *self, unsigned long action, | ||
256 | void *hcpu) | ||
257 | { | ||
258 | switch (action & ~CPU_TASKS_FROZEN) { | ||
259 | case CPU_STARTING: | ||
260 | gt_clockevents_init(this_cpu_ptr(gt_evt)); | ||
261 | break; | ||
262 | case CPU_DYING: | ||
263 | gt_clockevents_stop(this_cpu_ptr(gt_evt)); | ||
264 | break; | ||
265 | } | ||
266 | |||
267 | return NOTIFY_OK; | ||
268 | } | ||
269 | static struct notifier_block gt_cpu_nb = { | ||
270 | .notifier_call = gt_cpu_notify, | ||
271 | }; | ||
272 | |||
273 | static int __init global_timer_of_register(struct device_node *np) | 258 | static int __init global_timer_of_register(struct device_node *np) |
274 | { | 259 | { |
275 | struct clk *gt_clk; | 260 | struct clk *gt_clk; |
@@ -325,18 +310,14 @@ static int __init global_timer_of_register(struct device_node *np) | |||
325 | goto out_free; | 310 | goto out_free; |
326 | } | 311 | } |
327 | 312 | ||
328 | err = register_cpu_notifier(>_cpu_nb); | 313 | /* Register and immediately configure the timer on the boot CPU */ |
329 | if (err) { | ||
330 | pr_warn("global-timer: unable to register cpu notifier.\n"); | ||
331 | goto out_irq; | ||
332 | } | ||
333 | |||
334 | /* Immediately configure the timer on the boot CPU */ | ||
335 | err = gt_clocksource_init(); | 314 | err = gt_clocksource_init(); |
336 | if (err) | 315 | if (err) |
337 | goto out_irq; | 316 | goto out_irq; |
338 | 317 | ||
339 | err = gt_clockevents_init(this_cpu_ptr(gt_evt)); | 318 | err = cpuhp_setup_state(CPUHP_AP_ARM_GLOBAL_TIMER_STARTING, |
319 | "AP_ARM_GLOBAL_TIMER_STARTING", | ||
320 | gt_starting_cpu, gt_dying_cpu); | ||
340 | if (err) | 321 | if (err) |
341 | goto out_irq; | 322 | goto out_irq; |
342 | 323 | ||