tick: Sanitize broadcast control logic
[platform/adaptation/renesas_rcar/renesas_kernel.git] / kernel / time / tick-common.c
index 5edfb48..64522ec 100644 (file)
@@ -194,7 +194,8 @@ static void tick_setup_device(struct tick_device *td,
         * When global broadcasting is active, check if the current
         * device is registered as a placeholder for broadcast mode.
         * This allows us to handle this x86 misfeature in a generic
-        * way.
+        * way. This function also returns !=0 when we keep the
+        * current active broadcast state for this CPU.
         */
        if (tick_device_uses_broadcast(newdev, cpu))
                return;
@@ -243,8 +244,13 @@ static bool tick_check_preferred(struct clock_event_device *curdev,
                        return false;
        }
 
-       /* Use the higher rated one */
-       return !curdev || newdev->rating > curdev->rating;
+       /*
+        * Use the higher rated one, but prefer a CPU local device with a lower
+        * rating than a non-CPU local device
+        */
+       return !curdev ||
+               newdev->rating > curdev->rating ||
+              !cpumask_equal(curdev->cpumask, newdev->cpumask);
 }
 
 /*