ARM: bL_switcher: filter CPU hotplug requests when the switcher is active
authorNicolas Pitre <nicolas.pitre@linaro.org>
Tue, 27 Nov 2012 03:48:55 +0000 (22:48 -0500)
committerNicolas Pitre <nicolas.pitre@linaro.org>
Mon, 5 Aug 2013 04:12:41 +0000 (00:12 -0400)
Trying to support both the switcher and CPU hotplug at the same time
is tricky due to ambiguous semantics.  So let's at least prevent users
from messing around with those logical CPUs the switcher has removed
and those which were not active when the switcher was activated.

Signed-off-by: Nicolas Pitre <nico@linaro.org>
arch/arm/common/bL_switcher.c

index 0e4fb3e5e99c798a48e8d333404e8b94760b6c8c..335ff76d4c5a27c8a41c26b100cbda6e03726d86 100644 (file)
@@ -554,6 +554,26 @@ static int __init bL_switcher_sysfs_init(void)
 
 #endif  /* CONFIG_SYSFS */
 
+/*
+ * Veto any CPU hotplug operation on those CPUs we've removed
+ * while the switcher is active.
+ * We're just not ready to deal with that given the trickery involved.
+ */
+static int bL_switcher_hotplug_callback(struct notifier_block *nfb,
+                                       unsigned long action, void *hcpu)
+{
+       if (bL_switcher_active) {
+               int pairing = bL_switcher_cpu_pairing[(unsigned long)hcpu];
+               switch (action & 0xf) {
+               case CPU_UP_PREPARE:
+               case CPU_DOWN_PREPARE:
+                       if (pairing == -1)
+                               return NOTIFY_BAD;
+               }
+       }
+       return NOTIFY_DONE;
+}
+
 static bool no_bL_switcher;
 core_param(no_bL_switcher, no_bL_switcher, bool, 0644);
 
@@ -566,6 +586,8 @@ static int __init bL_switcher_init(void)
                return -EINVAL;
        }
 
+       cpu_notifier(bL_switcher_hotplug_callback, 0);
+
        if (!no_bL_switcher) {
                ret = bL_switcher_enable();
                if (ret)