GPU: fix 2d OC, kernel mpdecision
/arch/arm/mach-msm/msm_mpdecision.c
blob:79823be3729f2005032395efd93ecb71f467830d -> blob:758c84a41343b07b073a4bb48634c5322cd94f55
--- arch/arm/mach-msm/msm_mpdecision.c
+++ arch/arm/mach-msm/msm_mpdecision.c
@@ -1,3 +1,28 @@
+/*
+ * arch/arm/mach-msm/msm_mpdecision.c
+ *
+ * This program features:
+ * -cpu auto-hotplug/unplug based on system load for MSM multicore cpus
+ * -single core while screen is off
+ * -extensive sysfs tuneables
+ *
+ * Copyright (c) 2011-2012, Chad Goodman <chad.goodman@gmail.com> - All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
#include <linux/earlysuspend.h>
#include <linux/init.h>
#include <linux/cpufreq.h>
@@ -8,11 +33,15 @@
#include <asm-generic/cputime.h>
#include <linux/hrtimer.h>
#include <linux/delay.h>
-
#include "acpuclock.h"
-#include <mach/board_htc.h>
-#define MPDEC_TAG "[AnthraX-MPD]: "
+#define DEBUG 0
+
+#define MPDEC_TAG "[AnThRaX MPDEC]: "
+#define MSM_MPDEC_STARTDELAY 20000
+#define MSM_MPDEC_DELAY 70
+#define MSM_MPDEC_PAUSE 10000
+#define MSM_MPDEC_IDLE_FREQ 486000
enum {
MSM_MPDEC_DISABLED = 0,
@@ -30,7 +59,8 @@ struct msm_mpdec_cpudata_t {
static DEFINE_PER_CPU(struct msm_mpdec_cpudata_t, msm_mpdec_cpudata);
static struct delayed_work msm_mpdec_work;
-static DEFINE_MUTEX(msm_cpu_lock);
+static struct workqueue_struct *msm_mpdec_workq;
+static DEFINE_MUTEX(mpdec_msm_cpu_lock);
static struct msm_mpdec_tuners {
unsigned int startdelay;
@@ -38,16 +68,20 @@ static struct msm_mpdec_tuners {
unsigned int pause;
bool scroff_single_core;
unsigned long int idle_freq;
+ unsigned int max_cpus;
+ unsigned int min_cpus;
} msm_mpdec_tuners_ins = {
- .startdelay = CONFIG_MSM_MPDEC_STARTDELAY,
- .delay = CONFIG_MSM_MPDEC_DELAY,
- .pause = CONFIG_MSM_MPDEC_PAUSE,
+ .startdelay = MSM_MPDEC_STARTDELAY,
+ .delay = MSM_MPDEC_DELAY,
+ .pause = MSM_MPDEC_PAUSE,
.scroff_single_core = true,
- .idle_freq = CONFIG_MSM_MPDEC_IDLE_FREQ,
+ .idle_freq = MSM_MPDEC_IDLE_FREQ,
+ .max_cpus = CONFIG_NR_CPUS,
+ .min_cpus = 1,
};
-static unsigned int NwNs_Threshold[4] = {35, 0, 0, 5};
-static unsigned int TwTs_Threshold[4] = {250, 0, 0, 250};
+static unsigned int NwNs_Threshold[8] = {12, 0, 25, 20, 32, 28, 0, 35};
+static unsigned int TwTs_Threshold[8] = {140, 0, 140, 190, 140, 190, 0, 190};
extern unsigned int get_rq_info(void);
extern unsigned long acpuclk_get_rate(int);
@@ -55,6 +89,54 @@ extern unsigned long acpuclk_get_rate(in
unsigned int state = MSM_MPDEC_IDLE;
bool was_paused = false;
+static unsigned long get_rate(int cpu)
+{
+ return acpuclk_get_rate(cpu);
+}
+
+static int get_slowest_cpu(void)
+{
+ int i, cpu = 0;
+ unsigned long rate, slow_rate = 0;
+
+ for (i = 1; i < CONFIG_NR_CPUS; i++) {
+ if (!cpu_online(i))
+ continue;
+
+ rate = get_rate(i);
+ if (slow_rate == 0) {
+ slow_rate = rate;
+ }
+
+ if ((rate <= slow_rate) && (slow_rate != 0)) {
+ cpu = i;
+ slow_rate = rate;
+ }
+ }
+
+ return cpu;
+}
+
+static unsigned long get_slowest_cpu_rate(void)
+{
+ int i = 0;
+ unsigned long rate, slow_rate = 0;
+
+ for (i = 0; i < CONFIG_NR_CPUS; i++) {
+ if (!cpu_online(i))
+ continue;
+ rate = get_rate(i);
+ if ((rate < slow_rate) && (slow_rate != 0)) {
+ slow_rate = rate;
+ }
+ if (slow_rate == 0) {
+ slow_rate = rate;
+ }
+ }
+
+ return slow_rate;
+}
+
static int mp_decision(void)
{
static bool first_call = true;
@@ -86,20 +168,19 @@ static int mp_decision(void)
if (nr_cpu_online) {
index = (nr_cpu_online - 1) * 2;
- if ((nr_cpu_online < 2) && (rq_depth >= NwNs_Threshold[index])) {
- if (total_time >= TwTs_Threshold[index]) {
+ if ((nr_cpu_online < CONFIG_NR_CPUS) && (rq_depth >= NwNs_Threshold[index])) {
+ if ((total_time >= TwTs_Threshold[index]) &&
+ (nr_cpu_online < msm_mpdec_tuners_ins.max_cpus)) {
new_state = MSM_MPDEC_UP;
- if (acpuclk_get_rate((CONFIG_NR_CPUS - 2)) <=
- msm_mpdec_tuners_ins.idle_freq)
+ if (get_slowest_cpu_rate() <= msm_mpdec_tuners_ins.idle_freq)
new_state = MSM_MPDEC_IDLE;
- }
- } else if (rq_depth <= NwNs_Threshold[index+1]) {
- if (total_time >= TwTs_Threshold[index+1] ) {
+ }
+ } else if ((nr_cpu_online > 1) && (rq_depth <= NwNs_Threshold[index+1])) {
+ if ((total_time >= TwTs_Threshold[index+1]) &&
+ (nr_cpu_online > msm_mpdec_tuners_ins.min_cpus)) {
new_state = MSM_MPDEC_DOWN;
- if (cpu_online((CONFIG_NR_CPUS - 1)))
- if (acpuclk_get_rate((CONFIG_NR_CPUS - 1)) >
- msm_mpdec_tuners_ins.idle_freq)
- new_state = MSM_MPDEC_IDLE;
+ if (get_slowest_cpu_rate() > msm_mpdec_tuners_ins.idle_freq)
+ new_state = MSM_MPDEC_IDLE;
}
} else {
new_state = MSM_MPDEC_IDLE;
@@ -114,7 +195,10 @@ static int mp_decision(void)
}
last_time = ktime_to_ms(ktime_get());
-
+#if DEBUG
+ pr_info(MPDEC_TAG"[DEBUG] rq: %u, new_state: %i | Mask=[%d%d%d%d]\n",
+ rq_depth, new_state, cpu_online(0), cpu_online(1), cpu_online(2), cpu_online(3));
+#endif
return new_state;
}
@@ -122,11 +206,21 @@ static void msm_mpdec_work_thread(struct
{
unsigned int cpu = nr_cpu_ids;
cputime64_t on_time = 0;
+ bool suspended = false;
- if (per_cpu(msm_mpdec_cpudata, (CONFIG_NR_CPUS - 1)).device_suspended == true)
+ if (ktime_to_ms(ktime_get()) <= msm_mpdec_tuners_ins.startdelay)
+ goto out;
+
+ for_each_possible_cpu(cpu) {
+ if ((per_cpu(msm_mpdec_cpudata, cpu).device_suspended == true)) {
+ suspended = true;
+ break;
+ }
+ }
+ if (suspended == true)
goto out;
- if (!mutex_trylock(&msm_cpu_lock))
+ if (!mutex_trylock(&mpdec_msm_cpu_lock))
goto out;
/* if sth messed with the cpus, update the check vars so we can proceed */
@@ -146,14 +240,14 @@ static void msm_mpdec_work_thread(struct
case MSM_MPDEC_IDLE:
break;
case MSM_MPDEC_DOWN:
- cpu = (CONFIG_NR_CPUS - 1);
+ cpu = get_slowest_cpu();
if (cpu < nr_cpu_ids) {
if ((per_cpu(msm_mpdec_cpudata, cpu).online == true) && (cpu_online(cpu))) {
cpu_down(cpu);
per_cpu(msm_mpdec_cpudata, cpu).online = false;
on_time = ktime_to_ms(ktime_get()) - per_cpu(msm_mpdec_cpudata, cpu).on_time;
- pr_info(MPDEC_TAG"CPU[%d] on->off | Mask=[%d%d] | time online: %llu\n",
- cpu, cpu_online(0), cpu_online(1), on_time);
+ pr_info(MPDEC_TAG"CPU[%d] on->off | Mask=[%d%d%d%d] | time online: %llu\n",
+ cpu, cpu_online(0), cpu_online(1), cpu_online(2), cpu_online(3), on_time);
} else if (per_cpu(msm_mpdec_cpudata, cpu).online != cpu_online(cpu)) {
pr_info(MPDEC_TAG"CPU[%d] was controlled outside of mpdecision! | pausing [%d]ms\n",
cpu, msm_mpdec_tuners_ins.pause);
@@ -163,14 +257,14 @@ static void msm_mpdec_work_thread(struct
}
break;
case MSM_MPDEC_UP:
- cpu = (CONFIG_NR_CPUS - 1);
+ cpu = cpumask_next_zero(0, cpu_online_mask);
if (cpu < nr_cpu_ids) {
if ((per_cpu(msm_mpdec_cpudata, cpu).online == false) && (!cpu_online(cpu))) {
cpu_up(cpu);
per_cpu(msm_mpdec_cpudata, cpu).online = true;
per_cpu(msm_mpdec_cpudata, cpu).on_time = ktime_to_ms(ktime_get());
- pr_info(MPDEC_TAG"CPU[%d] off->on | Mask=[%d%d]\n",
- cpu, cpu_online(0), cpu_online(1));
+ pr_info(MPDEC_TAG"CPU[%d] off->on | Mask=[%d%d%d%d]\n",
+ cpu, cpu_online(0), cpu_online(1), cpu_online(2), cpu_online(3));
} else if (per_cpu(msm_mpdec_cpudata, cpu).online != cpu_online(cpu)) {
pr_info(MPDEC_TAG"CPU[%d] was controlled outside of mpdecision! | pausing [%d]ms\n",
cpu, msm_mpdec_tuners_ins.pause);
@@ -183,49 +277,59 @@ static void msm_mpdec_work_thread(struct
pr_err(MPDEC_TAG"%s: invalid mpdec hotplug state %d\n",
__func__, state);
}
- mutex_unlock(&msm_cpu_lock);
+ mutex_unlock(&mpdec_msm_cpu_lock);
out:
if (state != MSM_MPDEC_DISABLED)
- schedule_delayed_work(&msm_mpdec_work,
+ queue_delayed_work(msm_mpdec_workq, &msm_mpdec_work,
msecs_to_jiffies(msm_mpdec_tuners_ins.delay));
return;
}
static void msm_mpdec_early_suspend(struct early_suspend *h)
{
- int cpu = 0;
+ int cpu = nr_cpu_ids;
for_each_possible_cpu(cpu) {
mutex_lock(&per_cpu(msm_mpdec_cpudata, cpu).suspend_mutex);
- if (((cpu >= (CONFIG_NR_CPUS - 1)) && (num_online_cpus() > 1)) && (msm_mpdec_tuners_ins.scroff_single_core)) {
- cpu_down(cpu);
- pr_info(MPDEC_TAG"Screen -> off. Suspended CPU%d | Mask=[%d%d]\n",
- cpu, cpu_online(0), cpu_online(1));
+ if ((cpu >= 1) && (cpu_online(cpu))) {
+ cpu_down(cpu);
+ pr_info(MPDEC_TAG"Screen -> off. Suspended CPU[%d] | Mask=[%d%d%d%d]\n",
+ cpu, cpu_online(0), cpu_online(1), cpu_online(2), cpu_online(3));
per_cpu(msm_mpdec_cpudata, cpu).online = false;
}
per_cpu(msm_mpdec_cpudata, cpu).device_suspended = true;
mutex_unlock(&per_cpu(msm_mpdec_cpudata, cpu).suspend_mutex);
}
+ /* main work thread can sleep now */
+ cancel_delayed_work_sync(&msm_mpdec_work);
+
+ pr_info(MPDEC_TAG"Screen -> off. Deactivated mpdecision.\n");
}
static void msm_mpdec_late_resume(struct early_suspend *h)
{
- int cpu = 0;
- for_each_possible_cpu(cpu) {
- mutex_lock(&per_cpu(msm_mpdec_cpudata, cpu).suspend_mutex);
- if ((cpu >= (CONFIG_NR_CPUS - 1)) && (num_online_cpus() < CONFIG_NR_CPUS)) {
- /* Always enable cpus when screen comes online.
- * This boosts the wakeup process.
- */
- cpu_up(cpu);
- per_cpu(msm_mpdec_cpudata, cpu).on_time = ktime_to_ms(ktime_get());
- per_cpu(msm_mpdec_cpudata, cpu).online = true;
- pr_info(MPDEC_TAG"Screen -> on. Hot plugged CPU%d | Mask=[%d%d]\n",
- cpu, cpu_online(0), cpu_online(1));
- }
+ int cpu = nr_cpu_ids;
+ for_each_possible_cpu(cpu)
per_cpu(msm_mpdec_cpudata, cpu).device_suspended = false;
- mutex_unlock(&per_cpu(msm_mpdec_cpudata, cpu).suspend_mutex);
- }
+
+ mutex_lock(&per_cpu(msm_mpdec_cpudata, 1).suspend_mutex);
+ if (!cpu_online(1)) {
+ /* Always enable cpu1 when screen comes online.
+ * This boosts the wakeup process. */
+ cpu_up(1);
+ per_cpu(msm_mpdec_cpudata, 1).on_time = ktime_to_ms(ktime_get());
+ per_cpu(msm_mpdec_cpudata, 1).online = true;
+ pr_info(MPDEC_TAG"Screen -> on. Hot plugged CPU1 | Mask=[%d%d%d%d]\n",
+ cpu_online(0), cpu_online(1), cpu_online(2), cpu_online(3));
+ }
+ mutex_unlock(&per_cpu(msm_mpdec_cpudata, 1).suspend_mutex);
+
+ /* wake up main work thread */
+ was_paused = true;
+ queue_delayed_work(msm_mpdec_workq, &msm_mpdec_work, 0);
+
+ pr_info(MPDEC_TAG"Screen -> on. Activated mpdecision. | Mask=[%d%d%d%d]\n",
+ cpu_online(0), cpu_online(1), cpu_online(2), cpu_online(3));
}
static struct early_suspend msm_mpdec_early_suspend_handler = {
@@ -248,6 +352,82 @@ show_one(startdelay, startdelay);
show_one(delay, delay);
show_one(pause, pause);
show_one(scroff_single_core, scroff_single_core);
+show_one(min_cpus, min_cpus);
+show_one(max_cpus, max_cpus);
+
+#define show_one_twts(file_name, arraypos) \
+static ssize_t show_##file_name \
+(struct kobject *kobj, struct attribute *attr, char *buf) \
+{ \
+ return sprintf(buf, "%u\n", TwTs_Threshold[arraypos]); \
+}
+show_one_twts(twts_threshold_0, 0);
+show_one_twts(twts_threshold_1, 1);
+show_one_twts(twts_threshold_2, 2);
+show_one_twts(twts_threshold_3, 3);
+show_one_twts(twts_threshold_4, 4);
+show_one_twts(twts_threshold_5, 5);
+show_one_twts(twts_threshold_6, 6);
+show_one_twts(twts_threshold_7, 7);
+
+#define store_one_twts(file_name, arraypos) \
+static ssize_t store_##file_name \
+(struct kobject *a, struct attribute *b, const char *buf, size_t count) \
+{ \
+ unsigned int input; \
+ int ret; \
+ ret = sscanf(buf, "%u", &input); \
+ if (ret != 1) \
+ return -EINVAL; \
+ TwTs_Threshold[arraypos] = input; \
+ return count; \
+} \
+define_one_global_rw(file_name);
+store_one_twts(twts_threshold_0, 0);
+store_one_twts(twts_threshold_1, 1);
+store_one_twts(twts_threshold_2, 2);
+store_one_twts(twts_threshold_3, 3);
+store_one_twts(twts_threshold_4, 4);
+store_one_twts(twts_threshold_5, 5);
+store_one_twts(twts_threshold_6, 6);
+store_one_twts(twts_threshold_7, 7);
+
+#define show_one_nwns(file_name, arraypos) \
+static ssize_t show_##file_name \
+(struct kobject *kobj, struct attribute *attr, char *buf) \
+{ \
+ return sprintf(buf, "%u\n", NwNs_Threshold[arraypos]); \
+}
+show_one_nwns(nwns_threshold_0, 0);
+show_one_nwns(nwns_threshold_1, 1);
+show_one_nwns(nwns_threshold_2, 2);
+show_one_nwns(nwns_threshold_3, 3);
+show_one_nwns(nwns_threshold_4, 4);
+show_one_nwns(nwns_threshold_5, 5);
+show_one_nwns(nwns_threshold_6, 6);
+show_one_nwns(nwns_threshold_7, 7);
+
+#define store_one_nwns(file_name, arraypos) \
+static ssize_t store_##file_name \
+(struct kobject *a, struct attribute *b, const char *buf, size_t count) \
+{ \
+ unsigned int input; \
+ int ret; \
+ ret = sscanf(buf, "%u", &input); \
+ if (ret != 1) \
+ return -EINVAL; \
+ NwNs_Threshold[arraypos] = input; \
+ return count; \
+} \
+define_one_global_rw(file_name);
+store_one_nwns(nwns_threshold_0, 0);
+store_one_nwns(nwns_threshold_1, 1);
+store_one_nwns(nwns_threshold_2, 2);
+store_one_nwns(nwns_threshold_3, 3);
+store_one_nwns(nwns_threshold_4, 4);
+store_one_nwns(nwns_threshold_5, 5);
+store_one_nwns(nwns_threshold_6, 6);
+store_one_nwns(nwns_threshold_7, 7);
static ssize_t show_idle_freq (struct kobject *kobj, struct attribute *attr,
char *buf)
@@ -274,30 +454,6 @@ static ssize_t show_enabled(struct kobje
return sprintf(buf, "%u\n", enabled);
}
-static ssize_t show_nwns_threshold_up(struct kobject *kobj, struct attribute *attr,
- char *buf)
-{
- return sprintf(buf, "%u\n", NwNs_Threshold[0]);
-}
-
-static ssize_t show_nwns_threshold_down(struct kobject *kobj, struct attribute *attr,
- char *buf)
-{
- return sprintf(buf, "%u\n", NwNs_Threshold[3]);
-}
-
-static ssize_t show_twts_threshold_up(struct kobject *kobj, struct attribute *attr,
- char *buf)
-{
- return sprintf(buf, "%u\n", TwTs_Threshold[0]);
-}
-
-static ssize_t show_twts_threshold_down(struct kobject *kobj, struct attribute *attr,
- char *buf)
-{
- return sprintf(buf, "%u\n", TwTs_Threshold[3]);
-}
-
static ssize_t store_startdelay(struct kobject *a, struct attribute *b,
const char *buf, size_t count)
{
@@ -348,7 +504,8 @@ static ssize_t store_idle_freq(struct ko
ret = sscanf(buf, "%lu", &input);
if (ret != 1)
return -EINVAL;
- msm_mpdec_tuners_ins.idle_freq = acpu_check_khz_value(input);
+
+ msm_mpdec_tuners_ins.idle_freq = input;
return count;
}
@@ -374,6 +531,34 @@ static ssize_t store_scroff_single_core(
return count;
}
+static ssize_t store_max_cpus(struct kobject *a, struct attribute *b,
+ const char *buf, size_t count)
+{
+ unsigned int input;
+ int ret;
+ ret = sscanf(buf, "%u", &input);
+ if ((ret != 1) || input > CONFIG_NR_CPUS)
+ return -EINVAL;
+
+ msm_mpdec_tuners_ins.max_cpus = input;
+
+ return count;
+}
+
+static ssize_t store_min_cpus(struct kobject *a, struct attribute *b,
+ const char *buf, size_t count)
+{
+ unsigned int input;
+ int ret;
+ ret = sscanf(buf, "%u", &input);
+ if ((ret != 1) || input < 1)
+ return -EINVAL;
+
+ msm_mpdec_tuners_ins.min_cpus = input;
+
+ return count;
+}
+
static ssize_t store_enabled(struct kobject *a, struct attribute *b,
const char *buf, size_t count)
{
@@ -402,22 +587,24 @@ static ssize_t store_enabled(struct kobj
switch (buf[0]) {
case '0':
state = MSM_MPDEC_DISABLED;
- cpu = (CONFIG_NR_CPUS - 1);
- if (!cpu_online(cpu)) {
- per_cpu(msm_mpdec_cpudata, cpu).on_time = ktime_to_ms(ktime_get());
- per_cpu(msm_mpdec_cpudata, cpu).online = true;
- cpu_up(cpu);
- pr_info(MPDEC_TAG"disabled... Hot plugged CPU[%d] | Mask=[%d%d]\n",
- cpu, cpu_online(0), cpu_online(1));
- } else {
- pr_info(MPDEC_TAG"disabled...\n");
- }
+ pr_info(MPDEC_TAG"nap time... Hot plugging offline CPUs...\n");
+
+ for (cpu = 1; cpu < CONFIG_NR_CPUS; cpu++) {
+ if (!cpu_online(cpu)) {
+ per_cpu(msm_mpdec_cpudata, cpu).on_time = ktime_to_ms(ktime_get());
+ per_cpu(msm_mpdec_cpudata, cpu).online = true;
+ cpu_up(cpu);
+ pr_info(MPDEC_TAG" DISABLED... Hot plugged CPU[%d] | Mask=[%d%d%d%d]\n",
+ cpu, cpu_online(0), cpu_online(1), cpu_online(2), cpu_online(3));
+ }
+ }
break;
case '1':
state = MSM_MPDEC_IDLE;
was_paused = true;
- schedule_delayed_work(&msm_mpdec_work, 0);
- pr_info(MPDEC_TAG" mpdecision enabled...\n");
+ queue_delayed_work(msm_mpdec_workq, &msm_mpdec_work,
+ msecs_to_jiffies(msm_mpdec_tuners_ins.delay));
+ pr_info(MPDEC_TAG" ENABLED mpdecision...\n");
break;
default:
ret = -EINVAL;
@@ -425,72 +612,14 @@ static ssize_t store_enabled(struct kobj
return count;
}
-static ssize_t store_nwns_threshold_up(struct kobject *a, struct attribute *b,
- const char *buf, size_t count)
-{
- unsigned int input;
- int ret;
- ret = sscanf(buf, "%u", &input);
- if (ret != 1)
- return -EINVAL;
-
- NwNs_Threshold[0] = input;
-
- return count;
-}
-
-static ssize_t store_nwns_threshold_down(struct kobject *a, struct attribute *b,
- const char *buf, size_t count)
-{
- unsigned int input;
- int ret;
- ret = sscanf(buf, "%u", &input);
- if (ret != 1)
- return -EINVAL;
-
- NwNs_Threshold[3] = input;
-
- return count;
-}
-
-static ssize_t store_twts_threshold_up(struct kobject *a, struct attribute *b,
- const char *buf, size_t count)
-{
- unsigned int input;
- int ret;
- ret = sscanf(buf, "%u", &input);
- if (ret != 1)
- return -EINVAL;
-
- TwTs_Threshold[0] = input;
-
- return count;
-}
-
-static ssize_t store_twts_threshold_down(struct kobject *a, struct attribute *b,
- const char *buf, size_t count)
-{
- unsigned int input;
- int ret;
- ret = sscanf(buf, "%u", &input);
- if (ret != 1)
- return -EINVAL;
-
- TwTs_Threshold[3] = input;
-
- return count;
-}
-
define_one_global_rw(startdelay);
define_one_global_rw(delay);
define_one_global_rw(pause);
define_one_global_rw(scroff_single_core);
define_one_global_rw(idle_freq);
+define_one_global_rw(min_cpus);
+define_one_global_rw(max_cpus);
define_one_global_rw(enabled);
-define_one_global_rw(nwns_threshold_up);
-define_one_global_rw(nwns_threshold_down);
-define_one_global_rw(twts_threshold_up);
-define_one_global_rw(twts_threshold_down);
static struct attribute *msm_mpdec_attributes[] = {
&startdelay.attr,
@@ -498,11 +627,25 @@ static struct attribute *msm_mpdec_attri
&pause.attr,
&scroff_single_core.attr,
&idle_freq.attr,
+ &min_cpus.attr,
+ &max_cpus.attr,
&enabled.attr,
- &nwns_threshold_up.attr,
- &nwns_threshold_down.attr,
- &twts_threshold_up.attr,
- &twts_threshold_down.attr,
+ &twts_threshold_0.attr,
+ &twts_threshold_1.attr,
+ &twts_threshold_2.attr,
+ &twts_threshold_3.attr,
+ &twts_threshold_4.attr,
+ &twts_threshold_5.attr,
+ &twts_threshold_6.attr,
+ &twts_threshold_7.attr,
+ &nwns_threshold_0.attr,
+ &nwns_threshold_1.attr,
+ &nwns_threshold_2.attr,
+ &nwns_threshold_3.attr,
+ &nwns_threshold_4.attr,
+ &nwns_threshold_5.attr,
+ &nwns_threshold_6.attr,
+ &nwns_threshold_7.attr,
NULL
};
@@ -513,7 +656,7 @@ static struct attribute_group msm_mpdec_
};
/**************************** SYSFS END ****************************/
-static int __init msm_mpdec(void)
+static int __init msm_mpdec_init(void)
{
int cpu, rc, err = 0;
@@ -523,9 +666,16 @@ static int __init msm_mpdec(void)
per_cpu(msm_mpdec_cpudata, cpu).online = true;
}
+ was_paused = true;
+
+ msm_mpdec_workq = alloc_workqueue(
+ "mpdec", WQ_UNBOUND | WQ_RESCUER | WQ_FREEZABLE, 1);
+ if (!msm_mpdec_workq)
+ return -ENOMEM;
INIT_DELAYED_WORK(&msm_mpdec_work, msm_mpdec_work_thread);
if (state != MSM_MPDEC_DISABLED)
- schedule_delayed_work(&msm_mpdec_work, 0);
+ queue_delayed_work(msm_mpdec_workq, &msm_mpdec_work,
+ msecs_to_jiffies(msm_mpdec_tuners_ins.delay));
register_early_suspend(&msm_mpdec_early_suspend_handler);
@@ -543,9 +693,12 @@ static int __init msm_mpdec(void)
return err;
}
+late_initcall(msm_mpdec_init);
-late_initcall(msm_mpdec);
-
-MODULE_DESCRIPTION("Kernel based MPDECISION (C) 2011 Chad Goodman");
-
+void msm_mpdec_exit(void)
+{
+ destroy_workqueue(msm_mpdec_workq);
+ destroy_workqueue(msm_mpdec_workq);
+}
+MODULE_DESCRIPTION("Kernel based MPDECISION (C) 2011-12 Chad Goodman");