Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1383960 > unrolled thread
| Started by | Viresh Kumar <viresh.kumar@linaro.org> |
|---|---|
| First post | 2016-04-21 11:00 +0200 |
| Last post | 2016-04-27 05:00 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 06/10] PM / OPP: Add dev_pm_opp_get_sharing_cpus() Viresh Kumar <viresh.kumar@linaro.org> - 2016-04-21 11:00 +0200
Re: [PATCH 06/10] PM / OPP: Add dev_pm_opp_get_sharing_cpus() Stephen Boyd <sboyd@codeaurora.org> - 2016-04-23 00:30 +0200
Re: [PATCH 06/10] PM / OPP: Add dev_pm_opp_get_sharing_cpus() Viresh Kumar <viresh.kumar@linaro.org> - 2016-04-27 05:00 +0200
| From | Viresh Kumar <viresh.kumar@linaro.org> |
|---|---|
| Date | 2016-04-21 11:00 +0200 |
| Subject | [PATCH 06/10] PM / OPP: Add dev_pm_opp_get_sharing_cpus() |
| Message-ID | <rqiCS-6mQ-27@gated-at.bofh.it> |
OPP core allows a platform to mark OPP table as shared, when the
platform isn't using operating-points-v2 bindings.
And, so there should be a non DT way of finding out if the OPP table is
shared or not.
This patch adds dev_pm_opp_get_sharing_cpus(), which first tries to get
OPP sharing information from the opp-table (in case it is already marked
as shared), otherwise it uses the existing DT way of finding sharing
information.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/base/power/opp/cpu.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
include/linux/pm_opp.h | 6 ++++++
2 files changed, 51 insertions(+)
diff --git a/drivers/base/power/opp/cpu.c b/drivers/base/power/opp/cpu.c
index 55cbf9bd8707..9c4eb90759fb 100644
--- a/drivers/base/power/opp/cpu.c
+++ b/drivers/base/power/opp/cpu.c
@@ -329,3 +329,48 @@ int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask)
return ret;
}
EXPORT_SYMBOL_GPL(dev_pm_opp_set_sharing_cpus);
+
+/**
+ * dev_pm_opp_get_sharing_cpus() - Get cpumask of CPUs sharing OPPs with @cpu_dev
+ * @cpu_dev: CPU device for which we do this operation
+ * @cpumask: cpumask to update with information of sharing CPUs
+ *
+ * This updates the @cpumask with CPUs that are sharing OPPs with @cpu_dev.
+ *
+ * Returns -ENODEV if OPP table isn't already present.
+ *
+ * Locking: The internal opp_table and opp structures are RCU protected.
+ * Hence this function internally uses RCU updater strategy with mutex locks
+ * to keep the integrity of the internal data structures. Callers should ensure
+ * that this function is *NOT* called under RCU protection or in contexts where
+ * mutex cannot be locked.
+ */
+int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask)
+{
+ struct opp_device *opp_dev;
+ struct opp_table *opp_table;
+ int ret = 0;
+
+ mutex_lock(&opp_table_lock);
+
+ opp_table = _find_opp_table(cpu_dev);
+ if (IS_ERR(opp_table)) {
+ ret = PTR_ERR(opp_table);
+ goto unlock;
+ }
+
+ cpumask_clear(cpumask);
+
+ if (opp_table->shared_opp) {
+ list_for_each_entry(opp_dev, &opp_table->dev_list, node)
+ cpumask_set_cpu(opp_dev->dev->id, cpumask);
+ } else {
+ cpumask_set_cpu(cpu_dev->id, cpumask);
+ }
+
+unlock:
+ mutex_unlock(&opp_table_lock);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_get_sharing_cpus);
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index 5b6ad31403a5..d6effc931013 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -66,6 +66,7 @@ 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);
int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask);
+int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask);
#else
static inline unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp)
{
@@ -184,6 +185,11 @@ static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, cpumask_va
return -ENOSYS;
}
+static inline int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask)
+{
+ return -ENOSYS;
+}
+
#endif /* CONFIG_PM_OPP */
#if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
--
2.7.1.410.g6faf27b
[toc] | [next] | [standalone]
| From | Stephen Boyd <sboyd@codeaurora.org> |
|---|---|
| Date | 2016-04-23 00:30 +0200 |
| Message-ID | <rqRKj-Ux-21@gated-at.bofh.it> |
| In reply to | #1383960 |
On 04/21, Viresh Kumar wrote: > diff --git a/drivers/base/power/opp/cpu.c b/drivers/base/power/opp/cpu.c > index 55cbf9bd8707..9c4eb90759fb 100644 > --- a/drivers/base/power/opp/cpu.c > +++ b/drivers/base/power/opp/cpu.c > @@ -329,3 +329,48 @@ int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask) > return ret; > } > EXPORT_SYMBOL_GPL(dev_pm_opp_set_sharing_cpus); > + > +/** > + * dev_pm_opp_get_sharing_cpus() - Get cpumask of CPUs sharing OPPs with @cpu_dev > + * @cpu_dev: CPU device for which we do this operation > + * @cpumask: cpumask to update with information of sharing CPUs > + * > + * This updates the @cpumask with CPUs that are sharing OPPs with @cpu_dev. > + * > + * Returns -ENODEV if OPP table isn't already present. > + * > + * Locking: The internal opp_table and opp structures are RCU protected. > + * Hence this function internally uses RCU updater strategy with mutex locks > + * to keep the integrity of the internal data structures. Callers should ensure > + * that this function is *NOT* called under RCU protection or in contexts where > + * mutex cannot be locked. > + */ > +int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask) Is there a reason we use cpumask_var_t instead of struct cpumask * here? My understanding is that cpumask_var_t is for stack declarations. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
[toc] | [prev] | [next] | [standalone]
| From | Viresh Kumar <viresh.kumar@linaro.org> |
|---|---|
| Date | 2016-04-27 05:00 +0200 |
| Message-ID | <rsnRM-1Xs-3@gated-at.bofh.it> |
| In reply to | #1385509 |
On 22-04-16, 15:21, Stephen Boyd wrote: > On 04/21, Viresh Kumar wrote: > > diff --git a/drivers/base/power/opp/cpu.c b/drivers/base/power/opp/cpu.c > > index 55cbf9bd8707..9c4eb90759fb 100644 > > --- a/drivers/base/power/opp/cpu.c > > +++ b/drivers/base/power/opp/cpu.c > > @@ -329,3 +329,48 @@ int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask) > > return ret; > > } > > EXPORT_SYMBOL_GPL(dev_pm_opp_set_sharing_cpus); > > + > > +/** > > + * dev_pm_opp_get_sharing_cpus() - Get cpumask of CPUs sharing OPPs with @cpu_dev > > + * @cpu_dev: CPU device for which we do this operation > > + * @cpumask: cpumask to update with information of sharing CPUs > > + * > > + * This updates the @cpumask with CPUs that are sharing OPPs with @cpu_dev. > > + * > > + * Returns -ENODEV if OPP table isn't already present. > > + * > > + * Locking: The internal opp_table and opp structures are RCU protected. > > + * Hence this function internally uses RCU updater strategy with mutex locks > > + * to keep the integrity of the internal data structures. Callers should ensure > > + * that this function is *NOT* called under RCU protection or in contexts where > > + * mutex cannot be locked. > > + */ > > +int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask) > > Is there a reason we use cpumask_var_t instead of struct cpumask * > here? My understanding is that cpumask_var_t is for stack > declarations. Just because we have been using that *consistently* everywhere in cpufreq and OPP core. I am fine with cpumask * as well, but we should be consistent. So, I will keep it cpumask_var_t for this patch, and lets see if we want to change all occurrences of the same in cpufreq and OPP core. Sounds reasonable ? -- viresh
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web