ARM: tegra: cpuquiet: make userspace governor actions synchronous
authorPeter De Schrijver <pdeschrijver@nvidia.com>
Tue, 12 Feb 2013 15:51:26 +0000 (17:51 +0200)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 18 May 2015 08:07:10 +0000 (16:07 +0800)
Userspace expects changes to happen synchronously. Implement this by waiting
with a (configureable) timeout for the action to happen.

Bug 1220065

Change-Id: I81301719707e4baf2b3aea62c38fc771ffe1205d
Signed-off-by: Peter De Schrijver <pdeschrijver@nvidia.com>
Reviewed-on: http://git-master/r/200013
Reviewed-by: Simone Willett <swillett@nvidia.com>
Tested-by: Simone Willett <swillett@nvidia.com>
drivers/cpuquiet/driver.c
drivers/cpuquiet/governors/balanced.c
drivers/cpuquiet/governors/runnable_threads.c
drivers/cpuquiet/governors/userspace.c
include/linux/cpuquiet.h

index fc83fa8cd02266a6c07eb13605e3018c803d4f60..fb9912b86e5e6e622019196ce3cfefd9ac91ad21 100644 (file)
@@ -106,12 +106,12 @@ static struct kobj_type ktype_cpu_stats = {
 };
 #endif
 
-int cpuquiet_quiesence_cpu(unsigned int cpunumber)
+int cpuquiet_quiesence_cpu(unsigned int cpunumber, bool sync)
 {
        int err = -EPERM;
 
        if (cpuquiet_curr_driver && cpuquiet_curr_driver->quiesence_cpu)
-               err = cpuquiet_curr_driver->quiesence_cpu(cpunumber);
+               err = cpuquiet_curr_driver->quiesence_cpu(cpunumber, sync);
 
 #ifdef CONFIG_CPUQUIET_STATS
        if (!err)
@@ -122,12 +122,12 @@ int cpuquiet_quiesence_cpu(unsigned int cpunumber)
 }
 EXPORT_SYMBOL(cpuquiet_quiesence_cpu);
 
-int cpuquiet_wake_cpu(unsigned int cpunumber)
+int cpuquiet_wake_cpu(unsigned int cpunumber, bool sync)
 {
        int err = -EPERM;
 
        if (cpuquiet_curr_driver && cpuquiet_curr_driver->wake_cpu)
-               err = cpuquiet_curr_driver->wake_cpu(cpunumber);
+               err = cpuquiet_curr_driver->wake_cpu(cpunumber, sync);
 
 #ifdef CONFIG_CPUQUIET_STATS
        if (!err)
index f187206ef1c46b434d416198c3db53a8d3e4d3af..794ef1e7e24c39855dd9b99a81fa4dd025ec3aea 100644 (file)
@@ -341,9 +341,9 @@ static void balanced_work_func(struct work_struct *work)
        if (cpu < nr_cpu_ids) {
                last_change_time = now;
                if (up)
-                       cpuquiet_wake_cpu(cpu);
+                       cpuquiet_wake_cpu(cpu, false);
                else
-                       cpuquiet_quiesence_cpu(cpu);
+                       cpuquiet_quiesence_cpu(cpu, false);
        }
 }
 
index c91d4566a47def27977430e6bf0fd20c1a5664b4..79ba69d8057afcdea7d44830f8119a8e625863c2 100644 (file)
@@ -190,11 +190,11 @@ static void runnables_work_func(struct work_struct *work)
        if (action > 0) {
                cpu = cpumask_next_zero(0, cpu_online_mask);
                if (cpu < nr_cpu_ids)
-                       cpuquiet_wake_cpu(cpu);
+                       cpuquiet_wake_cpu(cpu, false);
        } else if (action < 0) {
                cpu = get_lightest_loaded_cpu_n();
                if (cpu < nr_cpu_ids)
-                       cpuquiet_quiesence_cpu(cpu);
+                       cpuquiet_quiesence_cpu(cpu, false);
        }
 }
 
index 664594d68d8c25a87097248fefab9e3133db63cc..12a3d86228ed606df0645b3296fa0a07e539bef1 100644 (file)
@@ -25,14 +25,16 @@ static DEFINE_MUTEX(userspace_mutex);
 
 static int governor_set(unsigned int cpu, bool active)
 {
+       int err;
+
        mutex_lock(&userspace_mutex);
        if (active)
-               cpuquiet_wake_cpu(cpu);
+               err = cpuquiet_wake_cpu(cpu, true);
        else
-               cpuquiet_quiesence_cpu(cpu);
+               err = cpuquiet_quiesence_cpu(cpu, true);
        mutex_unlock(&userspace_mutex);
 
-       return 0;
+       return err;
 }
 
 struct cpuquiet_governor userspace_governor = {
index 5558c015bb507030d0a196301f2b436a10ae52fd..1bcfecce3a28a6a8459eaf20ea184ae0bce4a500 100644 (file)
@@ -37,14 +37,14 @@ struct cpuquiet_governor {
 
 struct cpuquiet_driver {
        char                    name[CPUQUIET_NAME_LEN];
-       int (*quiesence_cpu)    (unsigned int cpunumber);
-       int (*wake_cpu)         (unsigned int cpunumber);
+       int (*quiesence_cpu)    (unsigned int cpunumber, bool sync);
+       int (*wake_cpu)         (unsigned int cpunumber, bool sync);
 };
 
 extern int cpuquiet_register_governor(struct cpuquiet_governor *gov);
 extern void cpuquiet_unregister_governor(struct cpuquiet_governor *gov);
-extern int cpuquiet_quiesence_cpu(unsigned int cpunumber);
-extern int cpuquiet_wake_cpu(unsigned int cpunumber);
+extern int cpuquiet_quiesence_cpu(unsigned int cpunumber, bool sync);
+extern int cpuquiet_wake_cpu(unsigned int cpunumber, bool sync);
 extern int cpuquiet_register_driver(struct cpuquiet_driver *drv);
 extern void cpuquiet_unregister_driver(struct cpuquiet_driver *drv);
 extern int cpuquiet_add_group(struct attribute_group *attrs);