clockevents: Move C3 stop test outside lock
[platform/adaptation/renesas_rcar/renesas_kernel.git] / kernel / time / tick-broadcast.c
index a3b5aff..827e0f8 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/percpu.h>
 #include <linux/profile.h>
 #include <linux/sched.h>
-#include <linux/tick.h>
 
 #include "tick-internal.h"
 
@@ -457,23 +456,27 @@ void tick_broadcast_oneshot_control(unsigned long reason)
        unsigned long flags;
        int cpu;
 
-       raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
-
        /*
         * Periodic mode does not care about the enter/exit of power
         * states
         */
        if (tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC)
-               goto out;
+               return;
 
-       bc = tick_broadcast_device.evtdev;
+       /*
+        * We are called with preemtion disabled from the depth of the
+        * idle code, so we can't be moved away.
+        */
        cpu = smp_processor_id();
        td = &per_cpu(tick_cpu_device, cpu);
        dev = td->evtdev;
 
        if (!(dev->features & CLOCK_EVT_FEAT_C3STOP))
-               goto out;
+               return;
+
+       bc = tick_broadcast_device.evtdev;
 
+       raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
        if (reason == CLOCK_EVT_NOTIFY_BROADCAST_ENTER) {
                if (!cpumask_test_cpu(cpu, tick_get_broadcast_oneshot_mask())) {
                        cpumask_set_cpu(cpu, tick_get_broadcast_oneshot_mask());
@@ -490,8 +493,6 @@ void tick_broadcast_oneshot_control(unsigned long reason)
                                tick_program_event(dev->next_event, 1);
                }
        }
-
-out:
        raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
 }