From ff58d52e3016f23cfe9fb4059de1b95961f836a6 Mon Sep 17 00:00:00 2001 From: Alex Frid Date: Fri, 16 Dec 2011 13:44:23 -0800 Subject: PM QoS: Add max online cpus as PM QoS parameter Bug 894200 Change-Id: Ieb009a13c6ef9bca2388e234eb973d65a4e3a58b Signed-off-by: Alex Frid Reviewed-on: http://git-master/r/71034 Reviewed-by: Rohan Somvanshi Tested-by: Rohan Somvanshi Rebase-Id: R5791d3cb0bb66f3b8079f5a8af5fa758fb3c6705 --- include/linux/pm_qos.h | 2 ++ kernel/power/qos.c | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h index 5a95013905c8..9b403166a6af 100644 --- a/include/linux/pm_qos.h +++ b/include/linux/pm_qos.h @@ -15,6 +15,7 @@ enum { PM_QOS_CPU_DMA_LATENCY, PM_QOS_NETWORK_LATENCY, PM_QOS_NETWORK_THROUGHPUT, + PM_QOS_MAX_ONLINE_CPUS, /* insert new class ID */ PM_QOS_NUM_CLASSES, @@ -32,6 +33,7 @@ enum pm_qos_flags_status { #define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) #define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) #define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 +#define PM_QOS_MAX_ONLINE_CPUS_DEFAULT_VALUE LONG_MAX #define PM_QOS_DEV_LAT_DEFAULT_VALUE 0 #define PM_QOS_FLAG_NO_POWER_OFF (1 << 0) diff --git a/kernel/power/qos.c b/kernel/power/qos.c index 25cf89bc659e..37b9a69cb4b6 100644 --- a/kernel/power/qos.c +++ b/kernel/power/qos.c @@ -100,12 +100,27 @@ static struct pm_qos_object network_throughput_pm_qos = { .name = "network_throughput", }; +static BLOCKING_NOTIFIER_HEAD(max_online_cpus_notifier); +static struct pm_qos_constraints max_online_cpus_constraints = { + .list = PLIST_HEAD_INIT(max_online_cpus_constraints.list), + .target_value = PM_QOS_MAX_ONLINE_CPUS_DEFAULT_VALUE, + .default_value = PM_QOS_MAX_ONLINE_CPUS_DEFAULT_VALUE, + .type = PM_QOS_MIN, + .notifiers = &max_online_cpus_notifier, +}; +static struct pm_qos_object max_online_cpus_pm_qos = { + .constraints = &max_online_cpus_constraints, + .name = "max_online_cpus", + +}; + static struct pm_qos_object *pm_qos_array[] = { &null_pm_qos, &cpu_dma_pm_qos, &network_lat_pm_qos, - &network_throughput_pm_qos + &network_throughput_pm_qos, + &max_online_cpus_pm_qos }; static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, -- cgit v1.2.3 From d11d7c254c57a99330bcce9b114edc1bcad34fb4 Mon Sep 17 00:00:00 2001 From: Antti P Miettinen Date: Tue, 27 Dec 2011 12:28:21 +0200 Subject: PM QoS: Add CPU frequency min/max as PM QoS params Add minimum and maximum CPU frequency as PM QoS parameters. Bug 888312 Change-Id: I18abddded35a044a6ad8365035e31d1a2213a329 Reviewed-on: http://git-master/r/72206 Signed-off-by: Antti P Miettinen Signed-off-by: Varun Wadekar Reviewed-on: http://git-master/r/75883 Reviewed-by: Automatic_Commit_Validation_User Rebase-Id: R1007bbef60489ecc81a9acd0ce3b0abfa9a05f3e --- include/linux/pm_qos.h | 4 ++++ kernel/power/qos.c | 32 +++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h index 9b403166a6af..30300876d085 100644 --- a/include/linux/pm_qos.h +++ b/include/linux/pm_qos.h @@ -16,6 +16,8 @@ enum { PM_QOS_NETWORK_LATENCY, PM_QOS_NETWORK_THROUGHPUT, PM_QOS_MAX_ONLINE_CPUS, + PM_QOS_CPU_FREQ_MIN, + PM_QOS_CPU_FREQ_MAX, /* insert new class ID */ PM_QOS_NUM_CLASSES, @@ -34,6 +36,8 @@ enum pm_qos_flags_status { #define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) #define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 #define PM_QOS_MAX_ONLINE_CPUS_DEFAULT_VALUE LONG_MAX +#define PM_QOS_CPU_FREQ_MIN_DEFAULT_VALUE 0 +#define PM_QOS_CPU_FREQ_MAX_DEFAULT_VALUE LONG_MAX #define PM_QOS_DEV_LAT_DEFAULT_VALUE 0 #define PM_QOS_FLAG_NO_POWER_OFF (1 << 0) diff --git a/kernel/power/qos.c b/kernel/power/qos.c index 37b9a69cb4b6..7eb186fbecb8 100644 --- a/kernel/power/qos.c +++ b/kernel/power/qos.c @@ -115,12 +115,42 @@ static struct pm_qos_object max_online_cpus_pm_qos = { }; +static BLOCKING_NOTIFIER_HEAD(cpu_freq_min_notifier); +static struct pm_qos_constraints cpu_freq_min_constraints = { + .list = PLIST_HEAD_INIT(cpu_freq_min_constraints.list), + .target_value = PM_QOS_CPU_FREQ_MIN_DEFAULT_VALUE, + .default_value = PM_QOS_CPU_FREQ_MIN_DEFAULT_VALUE, + .type = PM_QOS_MAX, + .notifiers = &cpu_freq_min_notifier, +}; +static struct pm_qos_object cpu_freq_min_pm_qos = { + .constraints = &cpu_freq_min_constraints, + .name = "cpu_freq_min", +}; + + +static BLOCKING_NOTIFIER_HEAD(cpu_freq_max_notifier); +static struct pm_qos_constraints cpu_freq_max_constraints = { + .list = PLIST_HEAD_INIT(cpu_freq_max_constraints.list), + .target_value = PM_QOS_CPU_FREQ_MAX_DEFAULT_VALUE, + .default_value = PM_QOS_CPU_FREQ_MAX_DEFAULT_VALUE, + .type = PM_QOS_MIN, + .notifiers = &cpu_freq_max_notifier, +}; +static struct pm_qos_object cpu_freq_max_pm_qos = { + .constraints = &cpu_freq_max_constraints, + .name = "cpu_freq_max", +}; + + static struct pm_qos_object *pm_qos_array[] = { &null_pm_qos, &cpu_dma_pm_qos, &network_lat_pm_qos, &network_throughput_pm_qos, - &max_online_cpus_pm_qos + &max_online_cpus_pm_qos, + &cpu_freq_min_pm_qos, + &cpu_freq_max_pm_qos }; static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, -- cgit v1.2.3 From bddadeee2389b9db21229997e74c5684bd6d999a Mon Sep 17 00:00:00 2001 From: Gaurav Sarode Date: Fri, 17 Feb 2012 15:25:43 +0530 Subject: PM Qos: Add min online cpus as PM QoS parameter Bug 940061 Change-Id: Ibae842fdc3af3c92ec7e6125c602417110d8b55e Signed-off-by: Gaurav Sarode Reviewed-on: http://git-master/r/84521 Reviewed-by: Sachin Nikam Tested-by: Aleksandr Frid Reviewed-by: Diwakar Tundlam Rebase-Id: R830d4e99f1e03b61a8c4e52e11645b7ed2f10f56 --- include/linux/pm_qos.h | 2 ++ kernel/power/qos.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h index 30300876d085..fa11e5648959 100644 --- a/include/linux/pm_qos.h +++ b/include/linux/pm_qos.h @@ -15,6 +15,7 @@ enum { PM_QOS_CPU_DMA_LATENCY, PM_QOS_NETWORK_LATENCY, PM_QOS_NETWORK_THROUGHPUT, + PM_QOS_MIN_ONLINE_CPUS, PM_QOS_MAX_ONLINE_CPUS, PM_QOS_CPU_FREQ_MIN, PM_QOS_CPU_FREQ_MAX, @@ -35,6 +36,7 @@ enum pm_qos_flags_status { #define PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) #define PM_QOS_NETWORK_LAT_DEFAULT_VALUE (2000 * USEC_PER_SEC) #define PM_QOS_NETWORK_THROUGHPUT_DEFAULT_VALUE 0 +#define PM_QOS_MIN_ONLINE_CPUS_DEFAULT_VALUE 0 #define PM_QOS_MAX_ONLINE_CPUS_DEFAULT_VALUE LONG_MAX #define PM_QOS_CPU_FREQ_MIN_DEFAULT_VALUE 0 #define PM_QOS_CPU_FREQ_MAX_DEFAULT_VALUE LONG_MAX diff --git a/kernel/power/qos.c b/kernel/power/qos.c index 7eb186fbecb8..b343ea2fbdb2 100644 --- a/kernel/power/qos.c +++ b/kernel/power/qos.c @@ -100,6 +100,21 @@ static struct pm_qos_object network_throughput_pm_qos = { .name = "network_throughput", }; + +static BLOCKING_NOTIFIER_HEAD(min_online_cpus_notifier); +static struct pm_qos_constraints min_online_cpus_constraints = { + .list = PLIST_HEAD_INIT(min_online_cpus_constraints.list), + .target_value = PM_QOS_MIN_ONLINE_CPUS_DEFAULT_VALUE, + .default_value = PM_QOS_MIN_ONLINE_CPUS_DEFAULT_VALUE, + .type = PM_QOS_MAX, + .notifiers = &min_online_cpus_notifier, +}; +static struct pm_qos_object min_online_cpus_pm_qos = { + .constraints = &min_online_cpus_constraints, + .name = "min_online_cpus", +}; + + static BLOCKING_NOTIFIER_HEAD(max_online_cpus_notifier); static struct pm_qos_constraints max_online_cpus_constraints = { .list = PLIST_HEAD_INIT(max_online_cpus_constraints.list), @@ -148,6 +163,7 @@ static struct pm_qos_object *pm_qos_array[] = { &cpu_dma_pm_qos, &network_lat_pm_qos, &network_throughput_pm_qos, + &min_online_cpus_pm_qos, &max_online_cpus_pm_qos, &cpu_freq_min_pm_qos, &cpu_freq_max_pm_qos -- cgit v1.2.3 From 5ec1068d47f8c22eacaee450424a1158dc4f440d Mon Sep 17 00:00:00 2001 From: Antti P Miettinen Date: Mon, 20 Aug 2012 19:36:38 +0300 Subject: PM QoS: Add disable parameter For testing purposes it is useful to be able to disable PM Qos. Bug 1020898 Bug 917572 Reviewed-on: http://git-master/r/124667 Change-Id: I266f5b5730cfe4705197d8b09db7f9eda6766c7c Signed-off-by: Antti P Miettinen Signed-off-by: Varun Wadekar Rebase-Id: Re2088674f90436e0b9dd74310d5cda1f9e2868e4 --- kernel/power/qos.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 3 deletions(-) diff --git a/kernel/power/qos.c b/kernel/power/qos.c index b343ea2fbdb2..8e662c3dc2ef 100644 --- a/kernel/power/qos.c +++ b/kernel/power/qos.c @@ -41,7 +41,7 @@ #include #include #include - +#include #include #include @@ -184,6 +184,8 @@ static const struct file_operations pm_qos_power_fops = { .llseek = noop_llseek, }; +static bool pm_qos_enabled __read_mostly = true; + /* unlocked internal variant */ static inline int pm_qos_get_value(struct pm_qos_constraints *c) { @@ -258,8 +260,12 @@ int pm_qos_update_target(struct pm_qos_constraints *c, struct plist_node *node, ; } - curr_value = pm_qos_get_value(c); - pm_qos_set_value(c, curr_value); + if (pm_qos_enabled) { + curr_value = pm_qos_get_value(c); + pm_qos_set_value(c, curr_value); + } else { + curr_value = c->default_value; + } spin_unlock_irqrestore(&pm_qos_lock, flags); @@ -495,6 +501,59 @@ void pm_qos_remove_request(struct pm_qos_request *req) } EXPORT_SYMBOL_GPL(pm_qos_remove_request); +static int pm_qos_enabled_set(const char *arg, const struct kernel_param *kp) +{ + unsigned long flags; + bool old; + s32 prev[PM_QOS_NUM_CLASSES], curr[PM_QOS_NUM_CLASSES]; + int ret, i; + + old = pm_qos_enabled; + ret = param_set_bool(arg, kp); + if (ret != 0) { + pr_warn("%s: cannot set PM QoS enable to %s\n", + __FUNCTION__, arg); + return ret; + } + spin_lock_irqsave(&pm_qos_lock, flags); + for (i = 1; i < PM_QOS_NUM_CLASSES; i++) + prev[i] = pm_qos_read_value(pm_qos_array[i]->constraints); + if (old && !pm_qos_enabled) { + /* got disabled */ + for (i = 1; i < PM_QOS_NUM_CLASSES; i++) { + curr[i] = pm_qos_array[i]->constraints->default_value; + pm_qos_set_value(pm_qos_array[i]->constraints, curr[i]); + } + } else if (!old && pm_qos_enabled) { + /* got enabled */ + for (i = 1; i < PM_QOS_NUM_CLASSES; i++) { + curr[i] = pm_qos_get_value(pm_qos_array[i]->constraints); + pm_qos_set_value(pm_qos_array[i]->constraints, curr[i]); + } + } + spin_unlock_irqrestore(&pm_qos_lock, flags); + for (i = 1; i < PM_QOS_NUM_CLASSES; i++) + if (prev[i] != curr[i]) + blocking_notifier_call_chain( + pm_qos_array[i]->constraints->notifiers, + (unsigned long)curr[i], + NULL); + + return ret; +} + +static int pm_qos_enabled_get(char *buffer, const struct kernel_param *kp) +{ + return param_get_bool(buffer, kp); +} + +static struct kernel_param_ops pm_qos_enabled_ops = { + .set = pm_qos_enabled_set, + .get = pm_qos_enabled_get, +}; + +module_param_cb(enable, &pm_qos_enabled_ops, &pm_qos_enabled, 0644); + /** * pm_qos_add_notifier - sets notification entry for changes to target value * @pm_qos_class: identifies which qos target changes should be notified. -- cgit v1.2.3