aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTushar Khandelwal <tushar.khandelwal@arm.com>2017-07-12 17:47:34 +0100
committerRyan Harkin <ryan.harkin@linaro.org>2017-07-27 09:53:34 +0100
commitbce538696f89fd7a7dde3b3294fe04f167a85ff8 (patch)
treee5514ab92fdd4f79ad393be71761aa3c3da95654
parentbe72fb17bad24271204ec81965fc2dd7aa703f7d (diff)
drivers: base: fix for base support required by scmi cpufreq
this patch add api's used by scmi driver which are not present in 4.4 kernel and should be backported from 4.12 to avoid changing the scmi driver for the same mainline reference patch: 8cd2f6e8f34e75198063a6d84675b18bdb106824 Change-Id: Id20c892a7a0655fde266c9ae6ee561d3fdac0e5e Signed-off-by: Tushar Khandelwal <tushar.khandelwal@arm.com>
-rw-r--r--drivers/base/power/opp/core.c37
-rw-r--r--drivers/base/power/opp/cpu.c20
-rw-r--r--include/linux/pm_opp.h3
3 files changed, 60 insertions, 0 deletions
diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index d8f4cc22856c..6ec59bd30f26 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -1842,6 +1842,43 @@ struct srcu_notifier_head *dev_pm_opp_get_notifier(struct device *dev)
}
EXPORT_SYMBOL_GPL(dev_pm_opp_get_notifier);
+void dev_pm_opp_remove_table(struct device *dev)
+{
+ struct opp_table *opp_table;
+ struct dev_pm_opp *opp, *tmp;
+
+ /* Hold our table modification lock here */
+ mutex_lock(&opp_table_lock);
+
+ /* Check for existing table for 'dev' */
+ opp_table = _find_opp_table(dev);
+ if (IS_ERR(opp_table)) {
+ int error = PTR_ERR(opp_table);
+
+ if (error != -ENODEV)
+ WARN(1, "%s: opp_table: %d\n",
+ IS_ERR_OR_NULL(dev) ?
+ "Invalid device" : dev_name(dev),
+ error);
+ goto unlock;
+ }
+
+ /* Find if opp_table manages a single device */
+ if (list_is_singular(&opp_table->dev_list)) {
+ /* Free static OPPs */
+ list_for_each_entry_safe(opp, tmp, &opp_table->opp_list, node) {
+ if (!opp->dynamic)
+ _opp_remove(opp_table, opp, true);
+ }
+ } else {
+ _remove_opp_dev(_find_opp_dev(dev, opp_table), opp_table);
+ }
+
+unlock:
+ mutex_unlock(&opp_table_lock);
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_remove_table);
+
#ifdef CONFIG_OF
/**
* dev_pm_opp_of_remove_table() - Free OPP table entries created from static DT
diff --git a/drivers/base/power/opp/cpu.c b/drivers/base/power/opp/cpu.c
index ba2bdbd932ef..a23c66f5acd7 100644
--- a/drivers/base/power/opp/cpu.c
+++ b/drivers/base/power/opp/cpu.c
@@ -160,6 +160,26 @@ unlock:
}
EXPORT_SYMBOL_GPL(dev_pm_opp_set_sharing_cpus);
+void dev_pm_opp_cpumask_remove_table(cpumask_var_t cpumask)
+{
+ struct device *cpu_dev;
+ int cpu;
+
+ WARN_ON(cpumask_empty(cpumask));
+
+ for_each_cpu(cpu, cpumask) {
+ cpu_dev = get_cpu_device(cpu);
+ if (!cpu_dev) {
+ pr_err("%s: failed to get cpu%d device\n", __func__,
+ cpu);
+ continue;
+ }
+
+ dev_pm_opp_remove_table(cpu_dev);
+ }
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_cpumask_remove_table);
+
#ifdef CONFIG_OF
void dev_pm_opp_of_cpumask_remove_table(cpumask_var_t cpumask)
{
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index cccaf4a29e9f..8c86c11a9008 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -65,6 +65,7 @@ void dev_pm_opp_put_prop_name(struct device *dev);
int dev_pm_opp_set_regulator(struct device *dev, const char *name);
void dev_pm_opp_put_regulator(struct device *dev);
int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq);
+void dev_pm_opp_cpumask_remove_table(cpumask_var_t cpumask);
#else
static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
{
@@ -183,7 +184,9 @@ static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_f
#if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
int dev_pm_opp_of_add_table(struct device *dev);
void dev_pm_opp_of_remove_table(struct device *dev);
+void dev_pm_opp_remove_table(struct device *dev);
int dev_pm_opp_of_cpumask_add_table(cpumask_var_t cpumask);
+void dev_pm_opp_cpumask_remove_table(cpumask_var_t cpumask);
void dev_pm_opp_of_cpumask_remove_table(cpumask_var_t cpumask);
int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask);
int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask);