aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq
diff options
context:
space:
mode:
authorcodeworkx <codeworkx@cyanogenmod.com>2012-09-22 09:48:20 +0200
committercodeworkx <codeworkx@cyanogenmod.com>2012-09-22 14:02:16 +0200
commit2489007e7d740ccbc3e0a202914e243ad5178787 (patch)
treeb8e6380ea7b1da63474ad68a5dba997e01146043 /drivers/cpufreq
parent5f67568eb31e3a813c7c52461dcf66ade15fc2e7 (diff)
downloadkernel_samsung_smdk4412-2489007e7d740ccbc3e0a202914e243ad5178787.zip
kernel_samsung_smdk4412-2489007e7d740ccbc3e0a202914e243ad5178787.tar.gz
kernel_samsung_smdk4412-2489007e7d740ccbc3e0a202914e243ad5178787.tar.bz2
merge opensource jb u5
Change-Id: I1aaec157aa196f3448eff8636134fce89a814cf2
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r--drivers/cpufreq/Kconfig11
-rw-r--r--drivers/cpufreq/Makefile1
-rw-r--r--drivers/cpufreq/cpufreq_interactive.c356
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c7
-rw-r--r--drivers/cpufreq/cpufreq_pegasusq.c95
5 files changed, 435 insertions, 35 deletions
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index 8e089bd..8112af3 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -266,6 +266,17 @@ config CPU_FREQ_GOV_ADAPTIVE
config CPU_FREQ_GOV_PEGASUSQ
tristate "'pegasusq' cpufreq policy governor"
+config CPU_FREQ_GOV_SLP
+ tristate "'slp' cpufreq policy governor"
+
+config SLP_CHECK_CPU_LOAD
+ bool "check load and frequency of cpu"
+ depends on CPU_FREQ_GOV_SLP
+
+config SLP_GOV_DYNAMIC_PARAMS
+ bool "check SLP GOV. Dynamic Params feature"
+ depends on CPU_FREQ_GOV_SLP
+
config CPU_FREQ_DVFS_MONITOR
bool "dvfs monitor"
depends on CPU_FREQ
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index ed91c0d..101c6ed 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_CPU_FREQ_GOV_PERFORMANCE) += cpufreq_performance.o
obj-$(CONFIG_CPU_FREQ_GOV_POWERSAVE) += cpufreq_powersave.o
obj-$(CONFIG_CPU_FREQ_GOV_USERSPACE) += cpufreq_userspace.o
obj-$(CONFIG_CPU_FREQ_GOV_ONDEMAND) += cpufreq_ondemand.o
+obj-$(CONFIG_CPU_FREQ_GOV_SLP) += cpufreq_slp.o
obj-$(CONFIG_CPU_FREQ_GOV_CONSERVATIVE) += cpufreq_conservative.o
obj-$(CONFIG_CPU_FREQ_GOV_INTERACTIVE) += cpufreq_interactive.o
obj-$(CONFIG_CPU_FREQ_GOV_ADAPTIVE) += cpufreq_adaptive.o
diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c
index 45266d5..7dbacf0 100644
--- a/drivers/cpufreq/cpufreq_interactive.c
+++ b/drivers/cpufreq/cpufreq_interactive.c
@@ -27,9 +27,13 @@
#include <linux/workqueue.h>
#include <linux/kthread.h>
#include <linux/mutex.h>
-
+#include <linux/slab.h>
+#include <linux/input.h>
#include <asm/cputime.h>
+#define CREATE_TRACE_POINTS
+#include <trace/events/cpufreq_interactive.h>
+
static atomic_t active_count = ATOMIC_INIT(0);
struct cpufreq_interactive_cpuinfo {
@@ -39,11 +43,14 @@ struct cpufreq_interactive_cpuinfo {
u64 idle_exit_time;
u64 timer_run_time;
int idling;
- u64 freq_change_time;
- u64 freq_change_time_in_idle;
+ u64 target_set_time;
+ u64 target_set_time_in_idle;
struct cpufreq_policy *policy;
struct cpufreq_frequency_table *freq_table;
unsigned int target_freq;
+ unsigned int floor_freq;
+ u64 floor_validate_time;
+ u64 hispeed_validate_time;
int governor_enabled;
};
@@ -63,21 +70,47 @@ static struct mutex set_speed_lock;
static u64 hispeed_freq;
/* Go to hi speed when CPU load at or above this value. */
-#define DEFAULT_GO_HISPEED_LOAD 95
+#define DEFAULT_GO_HISPEED_LOAD 85
static unsigned long go_hispeed_load;
/*
* The minimum amount of time to spend at a frequency before we can ramp down.
*/
-#define DEFAULT_MIN_SAMPLE_TIME 20 * USEC_PER_MSEC
+#define DEFAULT_MIN_SAMPLE_TIME (80 * USEC_PER_MSEC)
static unsigned long min_sample_time;
/*
* The sample rate of the timer used to increase frequency
*/
-#define DEFAULT_TIMER_RATE 20 * USEC_PER_MSEC
+#define DEFAULT_TIMER_RATE (20 * USEC_PER_MSEC)
static unsigned long timer_rate;
+/*
+ * Wait this long before raising speed above hispeed, by default a single
+ * timer interval.
+ */
+#define DEFAULT_ABOVE_HISPEED_DELAY DEFAULT_TIMER_RATE
+static unsigned long above_hispeed_delay_val;
+
+/*
+ * Boost pulse to hispeed on touchscreen input.
+ */
+
+static int input_boost_val;
+
+struct cpufreq_interactive_inputopen {
+ struct input_handle *handle;
+ struct work_struct inputopen_work;
+};
+
+static struct cpufreq_interactive_inputopen inputopen;
+
+/*
+ * Non-zero means longer-term speed boost active.
+ */
+
+static int boost_val;
+
static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
unsigned int event);
@@ -145,9 +178,9 @@ static void cpufreq_interactive_timer(unsigned long data)
cpu_load = 100 * (delta_time - delta_idle) / delta_time;
delta_idle = (unsigned int) cputime64_sub(now_idle,
- pcpu->freq_change_time_in_idle);
+ pcpu->target_set_time_in_idle);
delta_time = (unsigned int) cputime64_sub(pcpu->timer_run_time,
- pcpu->freq_change_time);
+ pcpu->target_set_time);
if ((delta_time == 0) || (delta_idle > delta_time))
load_since_change = 0;
@@ -163,15 +196,33 @@ static void cpufreq_interactive_timer(unsigned long data)
if (load_since_change > cpu_load)
cpu_load = load_since_change;
- if (cpu_load >= go_hispeed_load) {
- if (pcpu->policy->cur == pcpu->policy->min)
+ if (cpu_load >= go_hispeed_load || boost_val) {
+ if (pcpu->target_freq <= pcpu->policy->min) {
new_freq = hispeed_freq;
- else
+ } else {
new_freq = pcpu->policy->max * cpu_load / 100;
+
+ if (new_freq < hispeed_freq)
+ new_freq = hispeed_freq;
+
+ if (pcpu->target_freq == hispeed_freq &&
+ new_freq > hispeed_freq &&
+ cputime64_sub(pcpu->timer_run_time,
+ pcpu->hispeed_validate_time)
+ < above_hispeed_delay_val) {
+ trace_cpufreq_interactive_notyet(data, cpu_load,
+ pcpu->target_freq,
+ new_freq);
+ goto rearm;
+ }
+ }
} else {
- new_freq = pcpu->policy->cur * cpu_load / 100;
+ new_freq = pcpu->policy->max * cpu_load / 100;
}
+ if (new_freq <= hispeed_freq)
+ pcpu->hispeed_validate_time = pcpu->timer_run_time;
+
if (cpufreq_frequency_table_target(pcpu->policy, pcpu->freq_table,
new_freq, CPUFREQ_RELATION_H,
&index)) {
@@ -182,19 +233,34 @@ static void cpufreq_interactive_timer(unsigned long data)
new_freq = pcpu->freq_table[index].frequency;
- if (pcpu->target_freq == new_freq)
- goto rearm_if_notmax;
-
/*
- * Do not scale down unless we have been at this frequency for the
- * minimum sample time.
+ * Do not scale below floor_freq unless we have been at or above the
+ * floor frequency for the minimum sample time since last validated.
*/
- if (new_freq < pcpu->target_freq) {
- if (cputime64_sub(pcpu->timer_run_time, pcpu->freq_change_time)
- < min_sample_time)
+ if (new_freq < pcpu->floor_freq) {
+ if (cputime64_sub(pcpu->timer_run_time,
+ pcpu->floor_validate_time)
+ < min_sample_time) {
+ trace_cpufreq_interactive_notyet(data, cpu_load,
+ pcpu->target_freq, new_freq);
goto rearm;
+ }
}
+ pcpu->floor_freq = new_freq;
+ pcpu->floor_validate_time = pcpu->timer_run_time;
+
+ if (pcpu->target_freq == new_freq) {
+ trace_cpufreq_interactive_already(data, cpu_load,
+ pcpu->target_freq, new_freq);
+ goto rearm_if_notmax;
+ }
+
+ trace_cpufreq_interactive_target(data, cpu_load, pcpu->target_freq,
+ new_freq);
+ pcpu->target_set_time_in_idle = now_idle;
+ pcpu->target_set_time = pcpu->timer_run_time;
+
if (new_freq < pcpu->target_freq) {
pcpu->target_freq = new_freq;
spin_lock_irqsave(&down_cpumask_lock, flags);
@@ -378,10 +444,8 @@ static int cpufreq_interactive_up_task(void *data)
max_freq,
CPUFREQ_RELATION_H);
mutex_unlock(&set_speed_lock);
-
- pcpu->freq_change_time_in_idle =
- get_cpu_idle_time_us(cpu,
- &pcpu->freq_change_time);
+ trace_cpufreq_interactive_up(cpu, pcpu->target_freq,
+ pcpu->policy->cur);
}
}
@@ -425,12 +489,137 @@ static void cpufreq_interactive_freq_down(struct work_struct *work)
CPUFREQ_RELATION_H);
mutex_unlock(&set_speed_lock);
- pcpu->freq_change_time_in_idle =
- get_cpu_idle_time_us(cpu,
- &pcpu->freq_change_time);
+ trace_cpufreq_interactive_down(cpu, pcpu->target_freq,
+ pcpu->policy->cur);
}
}
+static void cpufreq_interactive_boost(void)
+{
+ int i;
+ int anyboost = 0;
+ unsigned long flags;
+ struct cpufreq_interactive_cpuinfo *pcpu;
+
+ spin_lock_irqsave(&up_cpumask_lock, flags);
+
+ for_each_online_cpu(i) {
+ pcpu = &per_cpu(cpuinfo, i);
+
+ if (pcpu->target_freq < hispeed_freq) {
+ pcpu->target_freq = hispeed_freq;
+ cpumask_set_cpu(i, &up_cpumask);
+ pcpu->target_set_time_in_idle =
+ get_cpu_idle_time_us(i, &pcpu->target_set_time);
+ pcpu->hispeed_validate_time = pcpu->target_set_time;
+ anyboost = 1;
+ }
+
+ /*
+ * Set floor freq and (re)start timer for when last
+ * validated.
+ */
+
+ pcpu->floor_freq = hispeed_freq;
+ pcpu->floor_validate_time = ktime_to_us(ktime_get());
+ }
+
+ spin_unlock_irqrestore(&up_cpumask_lock, flags);
+
+ if (anyboost)
+ wake_up_process(up_task);
+}
+
+/*
+ * Pulsed boost on input event raises CPUs to hispeed_freq and lets
+ * usual algorithm of min_sample_time decide when to allow speed
+ * to drop.
+ */
+
+static void cpufreq_interactive_input_event(struct input_handle *handle,
+ unsigned int type,
+ unsigned int code, int value)
+{
+ if (input_boost_val && type == EV_SYN && code == SYN_REPORT) {
+ trace_cpufreq_interactive_boost("input");
+ cpufreq_interactive_boost();
+ }
+}
+
+static void cpufreq_interactive_input_open(struct work_struct *w)
+{
+ struct cpufreq_interactive_inputopen *io =
+ container_of(w, struct cpufreq_interactive_inputopen,
+ inputopen_work);
+ int error;
+
+ error = input_open_device(io->handle);
+ if (error)
+ input_unregister_handle(io->handle);
+}
+
+static int cpufreq_interactive_input_connect(struct input_handler *handler,
+ struct input_dev *dev,
+ const struct input_device_id *id)
+{
+ struct input_handle *handle;
+ int error;
+
+ pr_info("%s: connect to %s\n", __func__, dev->name);
+ handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL);
+ if (!handle)
+ return -ENOMEM;
+
+ handle->dev = dev;
+ handle->handler = handler;
+ handle->name = "cpufreq_interactive";
+
+ error = input_register_handle(handle);
+ if (error)
+ goto err;
+
+ inputopen.handle = handle;
+ queue_work(down_wq, &inputopen.inputopen_work);
+ return 0;
+err:
+ kfree(handle);
+ return error;
+}
+
+static void cpufreq_interactive_input_disconnect(struct input_handle *handle)
+{
+ input_close_device(handle);
+ input_unregister_handle(handle);
+ kfree(handle);
+}
+
+static const struct input_device_id cpufreq_interactive_ids[] = {
+ {
+ .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
+ INPUT_DEVICE_ID_MATCH_ABSBIT,
+ .evbit = { BIT_MASK(EV_ABS) },
+ .absbit = { [BIT_WORD(ABS_MT_POSITION_X)] =
+ BIT_MASK(ABS_MT_POSITION_X) |
+ BIT_MASK(ABS_MT_POSITION_Y) },
+ }, /* multi-touch touchscreen */
+ {
+ .flags = INPUT_DEVICE_ID_MATCH_KEYBIT |
+ INPUT_DEVICE_ID_MATCH_ABSBIT,
+ .keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) },
+ .absbit = { [BIT_WORD(ABS_X)] =
+ BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) },
+ }, /* touchpad */
+ { },
+};
+
+static struct input_handler cpufreq_interactive_input_handler = {
+ .event = cpufreq_interactive_input_event,
+ .connect = cpufreq_interactive_input_connect,
+ .disconnect = cpufreq_interactive_input_disconnect,
+ .name = "cpufreq_interactive",
+ .id_table = cpufreq_interactive_ids,
+};
+
static ssize_t show_hispeed_freq(struct kobject *kobj,
struct attribute *attr, char *buf)
{
@@ -499,6 +688,28 @@ static ssize_t store_min_sample_time(struct kobject *kobj,
static struct global_attr min_sample_time_attr = __ATTR(min_sample_time, 0644,
show_min_sample_time, store_min_sample_time);
+static ssize_t show_above_hispeed_delay(struct kobject *kobj,
+ struct attribute *attr, char *buf)
+{
+ return sprintf(buf, "%lu\n", above_hispeed_delay_val);
+}
+
+static ssize_t store_above_hispeed_delay(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buf, size_t count)
+{
+ int ret;
+ unsigned long val;
+
+ ret = strict_strtoul(buf, 0, &val);
+ if (ret < 0)
+ return ret;
+ above_hispeed_delay_val = val;
+ return count;
+}
+
+define_one_global_rw(above_hispeed_delay);
+
static ssize_t show_timer_rate(struct kobject *kobj,
struct attribute *attr, char *buf)
{
@@ -521,11 +732,84 @@ static ssize_t store_timer_rate(struct kobject *kobj,
static struct global_attr timer_rate_attr = __ATTR(timer_rate, 0644,
show_timer_rate, store_timer_rate);
+static ssize_t show_input_boost(struct kobject *kobj, struct attribute *attr,
+ char *buf)
+{
+ return sprintf(buf, "%u\n", input_boost_val);
+}
+
+static ssize_t store_input_boost(struct kobject *kobj, struct attribute *attr,
+ const char *buf, size_t count)
+{
+ int ret;
+ unsigned long val;
+
+ ret = strict_strtoul(buf, 0, &val);
+ if (ret < 0)
+ return ret;
+ input_boost_val = val;
+ return count;
+}
+
+define_one_global_rw(input_boost);
+
+static ssize_t show_boost(struct kobject *kobj, struct attribute *attr,
+ char *buf)
+{
+ return sprintf(buf, "%d\n", boost_val);
+}
+
+static ssize_t store_boost(struct kobject *kobj, struct attribute *attr,
+ const char *buf, size_t count)
+{
+ int ret;
+ unsigned long val;
+
+ ret = kstrtoul(buf, 0, &val);
+ if (ret < 0)
+ return ret;
+
+ boost_val = val;
+
+ if (boost_val) {
+ trace_cpufreq_interactive_boost("on");
+ cpufreq_interactive_boost();
+ } else {
+ trace_cpufreq_interactive_unboost("off");
+ }
+
+ return count;
+}
+
+define_one_global_rw(boost);
+
+static ssize_t store_boostpulse(struct kobject *kobj, struct attribute *attr,
+ const char *buf, size_t count)
+{
+ int ret;
+ unsigned long val;
+
+ ret = kstrtoul(buf, 0, &val);
+ if (ret < 0)
+ return ret;
+
+ trace_cpufreq_interactive_boost("pulse");
+ cpufreq_interactive_boost();
+ return count;
+}
+
+static struct global_attr boostpulse =
+ __ATTR(boostpulse, 0200, NULL, store_boostpulse);
+
static struct attribute *interactive_attributes[] = {
&hispeed_freq_attr.attr,
&go_hispeed_load_attr.attr,
+ &above_hispeed_delay.attr,
&min_sample_time_attr.attr,
&timer_rate_attr.attr,
+ &input_boost.attr,
+ &boost.attr,
+ &boostpulse.attr,
NULL,
};
@@ -555,9 +839,14 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
pcpu->policy = policy;
pcpu->target_freq = policy->cur;
pcpu->freq_table = freq_table;
- pcpu->freq_change_time_in_idle =
+ pcpu->target_set_time_in_idle =
get_cpu_idle_time_us(j,
- &pcpu->freq_change_time);
+ &pcpu->target_set_time);
+ pcpu->floor_freq = pcpu->target_freq;
+ pcpu->floor_validate_time =
+ pcpu->target_set_time;
+ pcpu->hispeed_validate_time =
+ pcpu->target_set_time;
pcpu->governor_enabled = 1;
smp_wmb();
}
@@ -577,6 +866,11 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
if (rc)
return rc;
+ rc = input_register_handler(&cpufreq_interactive_input_handler);
+ if (rc)
+ pr_warn("%s: failed to register input handler\n",
+ __func__);
+
break;
case CPUFREQ_GOV_STOP:
@@ -599,6 +893,7 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
if (atomic_dec_return(&active_count) > 0)
return 0;
+ input_unregister_handler(&cpufreq_interactive_input_handler);
sysfs_remove_group(cpufreq_global_kobject,
&interactive_attr_group);
@@ -644,6 +939,7 @@ static int __init cpufreq_interactive_init(void)
go_hispeed_load = DEFAULT_GO_HISPEED_LOAD;
min_sample_time = DEFAULT_MIN_SAMPLE_TIME;
+ above_hispeed_delay_val = DEFAULT_ABOVE_HISPEED_DELAY;
timer_rate = DEFAULT_TIMER_RATE;
/* Initalize per-cpu timers */
@@ -677,7 +973,7 @@ static int __init cpufreq_interactive_init(void)
mutex_init(&set_speed_lock);
idle_notifier_register(&cpufreq_interactive_idle_nb);
-
+ INIT_WORK(&inputopen.inputopen_work, cpufreq_interactive_input_open);
return cpufreq_register_governor(&cpufreq_gov_interactive);
err_freeuptask:
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 68a15b6..a87dc5d 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -33,8 +33,15 @@
#define DEF_FREQUENCY_UP_THRESHOLD (80)
#define DEF_SAMPLING_DOWN_FACTOR (1)
#define MAX_SAMPLING_DOWN_FACTOR (100000)
+
+#if defined(CONFIG_MACH_SLP_PQ)
+#define MICRO_FREQUENCY_DOWN_DIFFERENTIAL (5)
+#define MICRO_FREQUENCY_UP_THRESHOLD (85)
+#else
#define MICRO_FREQUENCY_DOWN_DIFFERENTIAL (3)
#define MICRO_FREQUENCY_UP_THRESHOLD (95)
+#endif
+
#define MICRO_FREQUENCY_MIN_SAMPLE_RATE (10000)
#define MIN_FREQUENCY_UP_THRESHOLD (11)
#define MAX_FREQUENCY_UP_THRESHOLD (100)
diff --git a/drivers/cpufreq/cpufreq_pegasusq.c b/drivers/cpufreq/cpufreq_pegasusq.c
index 4a90a01..208a991 100644
--- a/drivers/cpufreq/cpufreq_pegasusq.c
+++ b/drivers/cpufreq/cpufreq_pegasusq.c
@@ -34,6 +34,7 @@
#ifdef CONFIG_HAS_EARLYSUSPEND
#include <linux/earlysuspend.h>
#endif
+#define EARLYSUSPEND_HOTPLUGLOCK 1
/*
* runqueue average
@@ -154,16 +155,17 @@ static unsigned int get_nr_run_avg(void)
#define MAX_HOTPLUG_RATE (40u)
#define DEF_MAX_CPU_LOCK (0)
+#define DEF_MIN_CPU_LOCK (0)
#define DEF_CPU_UP_FREQ (500000)
#define DEF_CPU_DOWN_FREQ (200000)
#define DEF_UP_NR_CPUS (1)
#define DEF_CPU_UP_RATE (10)
#define DEF_CPU_DOWN_RATE (20)
-#define DEF_FREQ_STEP (40)
+#define DEF_FREQ_STEP (37)
#define DEF_START_DELAY (0)
#define UP_THRESHOLD_AT_MIN_FREQ (40)
-#define FREQ_FOR_RESPONSIVENESS (500000)
+#define FREQ_FOR_RESPONSIVENESS (400000)
#define HOTPLUG_DOWN_INDEX (0)
#define HOTPLUG_UP_INDEX (1)
@@ -255,6 +257,7 @@ static struct dbs_tuners {
unsigned int cpu_down_freq;
unsigned int up_nr_cpus;
unsigned int max_cpu_lock;
+ unsigned int min_cpu_lock;
atomic_t hotplug_lock;
unsigned int dvfs_debug;
unsigned int max_freq;
@@ -274,6 +277,7 @@ static struct dbs_tuners {
.cpu_down_freq = DEF_CPU_DOWN_FREQ,
.up_nr_cpus = DEF_UP_NR_CPUS,
.max_cpu_lock = DEF_MAX_CPU_LOCK,
+ .min_cpu_lock = DEF_MIN_CPU_LOCK,
.hotplug_lock = ATOMIC_INIT(0),
.dvfs_debug = 0,
#ifdef CONFIG_HAS_EARLYSUSPEND
@@ -349,6 +353,38 @@ int cpufreq_pegasusq_cpu_unlock(int num_core)
return 0;
}
+void cpufreq_pegasusq_min_cpu_lock(unsigned int num_core)
+{
+ int online, flag;
+ struct cpu_dbs_info_s *dbs_info;
+
+ dbs_tuners_ins.min_cpu_lock = min(num_core, num_possible_cpus());
+
+ dbs_info = &per_cpu(od_cpu_dbs_info, 0); /* from CPU0 */
+ online = num_online_cpus();
+ flag = (int)num_core - online;
+ if (flag <= 0)
+ return;
+ queue_work_on(dbs_info->cpu, dvfs_workqueue, &dbs_info->up_work);
+}
+
+void cpufreq_pegasusq_min_cpu_unlock(void)
+{
+ int online, lock, flag;
+ struct cpu_dbs_info_s *dbs_info;
+
+ dbs_tuners_ins.min_cpu_lock = 0;
+
+ dbs_info = &per_cpu(od_cpu_dbs_info, 0); /* from CPU0 */
+ online = num_online_cpus();
+ lock = atomic_read(&g_hotplug_lock);
+ if (lock == 0)
+ return;
+ flag = lock - online;
+ if (flag >= 0)
+ return;
+ queue_work_on(dbs_info->cpu, dvfs_workqueue, &dbs_info->down_work);
+}
/*
* History of CPU usage
@@ -440,6 +476,7 @@ show_one(cpu_up_freq, cpu_up_freq);
show_one(cpu_down_freq, cpu_down_freq);
show_one(up_nr_cpus, up_nr_cpus);
show_one(max_cpu_lock, max_cpu_lock);
+show_one(min_cpu_lock, min_cpu_lock);
show_one(dvfs_debug, dvfs_debug);
static ssize_t show_hotplug_lock(struct kobject *kobj,
struct attribute *attr, char *buf)
@@ -700,6 +737,21 @@ static ssize_t store_max_cpu_lock(struct kobject *a, struct attribute *b,
return count;
}
+static ssize_t store_min_cpu_lock(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;
+ if (input == 0)
+ cpufreq_pegasusq_min_cpu_unlock();
+ else
+ cpufreq_pegasusq_min_cpu_lock(input);
+ return count;
+}
+
static ssize_t store_hotplug_lock(struct kobject *a, struct attribute *b,
const char *buf, size_t count)
{
@@ -758,6 +810,7 @@ define_one_global_rw(cpu_up_freq);
define_one_global_rw(cpu_down_freq);
define_one_global_rw(up_nr_cpus);
define_one_global_rw(max_cpu_lock);
+define_one_global_rw(min_cpu_lock);
define_one_global_rw(hotplug_lock);
define_one_global_rw(dvfs_debug);
@@ -775,8 +828,10 @@ static struct attribute *dbs_attributes[] = {
&cpu_up_freq.attr,
&cpu_down_freq.attr,
&up_nr_cpus.attr,
- /* priority: hotplug_lock > max_cpu_lock */
+ /* priority: hotplug_lock > max_cpu_lock > min_cpu_lock
+ Exception: hotplug_lock on early_suspend uses min_cpu_lock */
&max_cpu_lock.attr,
+ &min_cpu_lock.attr,
&hotplug_lock.attr,
&dvfs_debug.attr,
&hotplug_freq_1_1.attr,
@@ -806,9 +861,15 @@ static void cpu_up_work(struct work_struct *work)
int cpu;
int online = num_online_cpus();
int nr_up = dbs_tuners_ins.up_nr_cpus;
+ int min_cpu_lock = dbs_tuners_ins.min_cpu_lock;
int hotplug_lock = atomic_read(&g_hotplug_lock);
- if (hotplug_lock)
+
+ if (hotplug_lock && min_cpu_lock)
+ nr_up = max(hotplug_lock, min_cpu_lock) - online;
+ else if (hotplug_lock)
nr_up = hotplug_lock - online;
+ else if (min_cpu_lock)
+ nr_up = max(nr_up, min_cpu_lock - online);
if (online == 1) {
printk(KERN_ERR "CPU_UP 3\n");
@@ -894,10 +955,15 @@ static int check_up(void)
if (online == num_possible_cpus())
return 0;
+
if (dbs_tuners_ins.max_cpu_lock != 0
&& online >= dbs_tuners_ins.max_cpu_lock)
return 0;
+ if (dbs_tuners_ins.min_cpu_lock != 0
+ && online < dbs_tuners_ins.min_cpu_lock)
+ return 1;
+
if (num_hist == 0 || num_hist % up_rate)
return 0;
@@ -950,6 +1016,10 @@ static int check_down(void)
&& online > dbs_tuners_ins.max_cpu_lock)
return 1;
+ if (dbs_tuners_ins.min_cpu_lock != 0
+ && online <= dbs_tuners_ins.min_cpu_lock)
+ return 0;
+
if (num_hist == 0 || num_hist % down_rate)
return 0;
@@ -1221,24 +1291,33 @@ unsigned int prev_freq_step;
unsigned int prev_sampling_rate;
static void cpufreq_pegasusq_early_suspend(struct early_suspend *h)
{
+#if EARLYSUSPEND_HOTPLUGLOCK
dbs_tuners_ins.early_suspend =
atomic_read(&g_hotplug_lock);
+#endif
prev_freq_step = dbs_tuners_ins.freq_step;
prev_sampling_rate = dbs_tuners_ins.sampling_rate;
dbs_tuners_ins.freq_step = 20;
dbs_tuners_ins.sampling_rate *= 4;
- atomic_set(&g_hotplug_lock, 1);
+#if EARLYSUSPEND_HOTPLUGLOCK
+ atomic_set(&g_hotplug_lock,
+ (dbs_tuners_ins.min_cpu_lock) ? dbs_tuners_ins.min_cpu_lock : 1);
apply_hotplug_lock();
stop_rq_work();
+#endif
}
static void cpufreq_pegasusq_late_resume(struct early_suspend *h)
{
+#if EARLYSUSPEND_HOTPLUGLOCK
atomic_set(&g_hotplug_lock, dbs_tuners_ins.early_suspend);
+#endif
dbs_tuners_ins.early_suspend = -1;
dbs_tuners_ins.freq_step = prev_freq_step;
dbs_tuners_ins.sampling_rate = prev_sampling_rate;
+#if EARLYSUSPEND_HOTPLUGLOCK
apply_hotplug_lock();
start_rq_work();
+#endif
}
#endif
@@ -1302,6 +1381,9 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
mutex_init(&this_dbs_info->timer_mutex);
dbs_timer_init(this_dbs_info);
+#if !EARLYSUSPEND_HOTPLUGLOCK
+ register_pm_notifier(&pm_notifier);
+#endif
#ifdef CONFIG_HAS_EARLYSUSPEND
register_early_suspend(&early_suspend);
#endif
@@ -1311,6 +1393,9 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
#ifdef CONFIG_HAS_EARLYSUSPEND
unregister_early_suspend(&early_suspend);
#endif
+#if !EARLYSUSPEND_HOTPLUGLOCK
+ unregister_pm_notifier(&pm_notifier);
+#endif
dbs_timer_exit(this_dbs_info);