aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/common/bL_switcher.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/common/bL_switcher.c')
-rw-r--r--arch/arm/common/bL_switcher.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/arch/arm/common/bL_switcher.c b/arch/arm/common/bL_switcher.c
index 335ff76d4c5a..7d98629aa446 100644
--- a/arch/arm/common/bL_switcher.c
+++ b/arch/arm/common/bL_switcher.c
@@ -23,6 +23,7 @@
23#include <linux/hrtimer.h> 23#include <linux/hrtimer.h>
24#include <linux/tick.h> 24#include <linux/tick.h>
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/mutex.h>
26#include <linux/string.h> 27#include <linux/string.h>
27#include <linux/sysfs.h> 28#include <linux/sysfs.h>
28#include <linux/irqchip/arm-gic.h> 29#include <linux/irqchip/arm-gic.h>
@@ -302,6 +303,7 @@ EXPORT_SYMBOL_GPL(bL_switch_request);
302 * Activation and configuration code. 303 * Activation and configuration code.
303 */ 304 */
304 305
306static DEFINE_MUTEX(bL_switcher_activation_lock);
305static unsigned int bL_switcher_active; 307static unsigned int bL_switcher_active;
306static unsigned int bL_switcher_cpu_original_cluster[NR_CPUS]; 308static unsigned int bL_switcher_cpu_original_cluster[NR_CPUS];
307static cpumask_t bL_switcher_removed_logical_cpus; 309static cpumask_t bL_switcher_removed_logical_cpus;
@@ -413,9 +415,11 @@ static int bL_switcher_enable(void)
413{ 415{
414 int cpu, ret; 416 int cpu, ret;
415 417
418 mutex_lock(&bL_switcher_activation_lock);
416 cpu_hotplug_driver_lock(); 419 cpu_hotplug_driver_lock();
417 if (bL_switcher_active) { 420 if (bL_switcher_active) {
418 cpu_hotplug_driver_unlock(); 421 cpu_hotplug_driver_unlock();
422 mutex_unlock(&bL_switcher_activation_lock);
419 return 0; 423 return 0;
420 } 424 }
421 425
@@ -424,6 +428,7 @@ static int bL_switcher_enable(void)
424 ret = bL_switcher_halve_cpus(); 428 ret = bL_switcher_halve_cpus();
425 if (ret) { 429 if (ret) {
426 cpu_hotplug_driver_unlock(); 430 cpu_hotplug_driver_unlock();
431 mutex_unlock(&bL_switcher_activation_lock);
427 return ret; 432 return ret;
428 } 433 }
429 434
@@ -436,9 +441,10 @@ static int bL_switcher_enable(void)
436 } 441 }
437 442
438 bL_switcher_active = 1; 443 bL_switcher_active = 1;
439 cpu_hotplug_driver_unlock();
440
441 pr_info("big.LITTLE switcher initialized\n"); 444 pr_info("big.LITTLE switcher initialized\n");
445
446 cpu_hotplug_driver_unlock();
447 mutex_unlock(&bL_switcher_activation_lock);
442 return 0; 448 return 0;
443} 449}
444 450
@@ -450,9 +456,11 @@ static void bL_switcher_disable(void)
450 struct bL_thread *t; 456 struct bL_thread *t;
451 struct task_struct *task; 457 struct task_struct *task;
452 458
459 mutex_lock(&bL_switcher_activation_lock);
453 cpu_hotplug_driver_lock(); 460 cpu_hotplug_driver_lock();
454 if (!bL_switcher_active) { 461 if (!bL_switcher_active) {
455 cpu_hotplug_driver_unlock(); 462 cpu_hotplug_driver_unlock();
463 mutex_unlock(&bL_switcher_activation_lock);
456 return; 464 return;
457 } 465 }
458 bL_switcher_active = 0; 466 bL_switcher_active = 0;
@@ -497,6 +505,7 @@ static void bL_switcher_disable(void)
497 505
498 bL_switcher_restore_cpus(); 506 bL_switcher_restore_cpus();
499 cpu_hotplug_driver_unlock(); 507 cpu_hotplug_driver_unlock();
508 mutex_unlock(&bL_switcher_activation_lock);
500} 509}
501 510
502static ssize_t bL_switcher_active_show(struct kobject *kobj, 511static ssize_t bL_switcher_active_show(struct kobject *kobj,
@@ -554,6 +563,20 @@ static int __init bL_switcher_sysfs_init(void)
554 563
555#endif /* CONFIG_SYSFS */ 564#endif /* CONFIG_SYSFS */
556 565
566bool bL_switcher_get_enabled(void)
567{
568 mutex_lock(&bL_switcher_activation_lock);
569
570 return bL_switcher_active;
571}
572EXPORT_SYMBOL_GPL(bL_switcher_get_enabled);
573
574void bL_switcher_put_enabled(void)
575{
576 mutex_unlock(&bL_switcher_activation_lock);
577}
578EXPORT_SYMBOL_GPL(bL_switcher_put_enabled);
579
557/* 580/*
558 * Veto any CPU hotplug operation on those CPUs we've removed 581 * Veto any CPU hotplug operation on those CPUs we've removed
559 * while the switcher is active. 582 * while the switcher is active.