aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Martin <dave.martin@linaro.org>2012-12-10 17:19:57 +0000
committerNicolas Pitre <nicolas.pitre@linaro.org>2013-06-20 00:45:16 -0400
commit80899af2e864a8a546f6d8f46bccdc1014e9fbd0 (patch)
tree9caa7e3d34db656f98c0884da02448fb2285d2f1
parent976e214051cea025f8f55624b254a4e8fe44cd53 (diff)
downloadvexpress-lsk-80899af2e864a8a546f6d8f46bccdc1014e9fbd0.tar.gz
ARM: bL_switcher: Add synchronous enable/disable interface
Some subsystems will need to know for sure whether the switcher is enabled or disabled during certain critical regions. This patch provides a simple mutex-based mechanism to discover whether the switcher is enabled and temporarily lock out further enable/disable: * bL_switcher_get_enabled() returns true iff the switcher is enabled and temporarily inhibits enable/disable. * bL_switcher_put_enabled() permits enable/disable of the switcher again after a previous call to bL_switcher_get_enabled(). Signed-off-by: Dave Martin <dave.martin@linaro.org> Signed-off-by: Nicolas Pitre <nico@linaro.org>
-rw-r--r--arch/arm/common/bL_switcher.c27
-rw-r--r--arch/arm/include/asm/bL_switcher.h3
2 files changed, 28 insertions, 2 deletions
diff --git a/arch/arm/common/bL_switcher.c b/arch/arm/common/bL_switcher.c
index d18bfdb5dd0..bda51ca23eb 100644
--- a/arch/arm/common/bL_switcher.c
+++ b/arch/arm/common/bL_switcher.c
@@ -23,6 +23,7 @@
#include <linux/hrtimer.h>
#include <linux/tick.h>
#include <linux/mm.h>
+#include <linux/mutex.h>
#include <linux/string.h>
#include <linux/sysfs.h>
#include <linux/irqchip/arm-gic.h>
@@ -345,6 +346,7 @@ EXPORT_SYMBOL_GPL(bL_switch_request);
* Activation and configuration code.
*/
+static DEFINE_MUTEX(bL_switcher_activation_lock);
static unsigned int bL_switcher_active;
static unsigned int bL_switcher_cpu_original_cluster[NR_CPUS];
static cpumask_t bL_switcher_removed_logical_cpus;
@@ -456,9 +458,11 @@ static int bL_switcher_enable(void)
{
int cpu, ret;
+ mutex_lock(&bL_switcher_activation_lock);
cpu_hotplug_driver_lock();
if (bL_switcher_active) {
cpu_hotplug_driver_unlock();
+ mutex_unlock(&bL_switcher_activation_lock);
return 0;
}
@@ -467,6 +471,7 @@ static int bL_switcher_enable(void)
ret = bL_switcher_halve_cpus();
if (ret) {
cpu_hotplug_driver_unlock();
+ mutex_unlock(&bL_switcher_activation_lock);
return ret;
}
@@ -479,9 +484,10 @@ static int bL_switcher_enable(void)
}
bL_switcher_active = 1;
- cpu_hotplug_driver_unlock();
-
pr_info("big.LITTLE switcher initialized\n");
+
+ cpu_hotplug_driver_unlock();
+ mutex_unlock(&bL_switcher_activation_lock);
return 0;
}
@@ -493,9 +499,11 @@ static void bL_switcher_disable(void)
struct bL_thread *t;
struct task_struct *task;
+ mutex_lock(&bL_switcher_activation_lock);
cpu_hotplug_driver_lock();
if (!bL_switcher_active) {
cpu_hotplug_driver_unlock();
+ mutex_unlock(&bL_switcher_activation_lock);
return;
}
bL_switcher_active = 0;
@@ -540,6 +548,7 @@ static void bL_switcher_disable(void)
bL_switcher_restore_cpus();
cpu_hotplug_driver_unlock();
+ mutex_unlock(&bL_switcher_activation_lock);
}
static ssize_t bL_switcher_active_show(struct kobject *kobj,
@@ -597,6 +606,20 @@ static int __init bL_switcher_sysfs_init(void)
#endif /* CONFIG_SYSFS */
+bool bL_switcher_get_enabled(void)
+{
+ mutex_lock(&bL_switcher_activation_lock);
+
+ return bL_switcher_active;
+}
+EXPORT_SYMBOL_GPL(bL_switcher_get_enabled);
+
+void bL_switcher_put_enabled(void)
+{
+ mutex_unlock(&bL_switcher_activation_lock);
+}
+EXPORT_SYMBOL_GPL(bL_switcher_put_enabled);
+
/*
* Veto any CPU hotplug operation while the switcher is active.
* We're just not ready to deal with that given the trickery involved.
diff --git a/arch/arm/include/asm/bL_switcher.h b/arch/arm/include/asm/bL_switcher.h
index 19757c0c987..bc23d1c8bea 100644
--- a/arch/arm/include/asm/bL_switcher.h
+++ b/arch/arm/include/asm/bL_switcher.h
@@ -14,4 +14,7 @@
int bL_switch_request(unsigned int cpu, unsigned int new_cluster_id);
+bool bL_switcher_get_enabled(void);
+void bL_switcher_put_enabled(void);
+
#endif