linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] PM / OPP: Add support for descending order for cpufreq table
@ 2014-04-30  6:28 Jonghwan Choi
  2014-04-30  8:25 ` Viresh Kumar
  0 siblings, 1 reply; 24+ messages in thread
From: Jonghwan Choi @ 2014-04-30  6:28 UTC (permalink / raw)
  To: open list
  Cc: 'Rafael J. Wysocki', 'Len Brown',
	'Amit Daniel Kachhap'

In the frequency table dts file, the frequencies are arranged in
descending order which maps 1 to 1 with other frequency parameter to
be calculated and programmed in some registers.
But the OPP library works by generating the frequencies in ascending
order which breaks the above logic.
So added OPP_TABLE_ORDER_DESCEND flag to consider descending order.

Cc: Amit Daniel Kachhap <amit.daniel@samsung.com>
Signed-off-by: Jonghwan Choi <jhbird.choi@samsung.com>
---
 drivers/base/power/opp.c |   17 ++++++++++++++++-
 include/linux/pm_opp.h   |    7 +++++--
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index 2553867..ec7d553 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -18,6 +18,7 @@
 #include <linux/cpufreq.h>
 #include <linux/device.h>
 #include <linux/list.h>
+#include <linux/list_sort.h>
 #include <linux/rculist.h>
 #include <linux/rcupdate.h>
 #include <linux/pm_opp.h>
@@ -597,10 +598,21 @@ int dev_pm_opp_disable(struct device *dev, unsigned
long freq)
 EXPORT_SYMBOL_GPL(dev_pm_opp_disable);
 
 #ifdef CONFIG_CPU_FREQ
+
+static int opp_descend_cmp(void *priv, struct list_head *a,
+                                        struct list_head *b)
+{
+        struct dev_pm_opp *ra = list_entry(a, struct dev_pm_opp, node);
+        struct dev_pm_opp *rb = list_entry(b, struct dev_pm_opp, node);
+
+        return rb->rate - ra->rate;
+}
+
 /**
  * dev_pm_opp_init_cpufreq_table() - create a cpufreq table for a device
  * @dev:	device for which we do this operation
  * @table:	Cpufreq table returned back to caller
+ * @flags:	OPP_TABLE_ORDER_DESCEND or zero
  *
  * Generate a cpufreq table for a provided device- this assumes that the
  * opp list is already initialized and ready for usage.
@@ -622,7 +634,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_disable);
  * or in contexts where mutex locking cannot be used.
  */
 int dev_pm_opp_init_cpufreq_table(struct device *dev,
-			    struct cpufreq_frequency_table **table)
+		struct cpufreq_frequency_table **table, unsigned char flags)
 {
 	struct device_opp *dev_opp;
 	struct dev_pm_opp *opp;
@@ -649,6 +661,9 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev,
 		return -ENOMEM;
 	}
 
+	if (flags & OPP_TABLE_ORDER_DESCEND)
+		list_sort(NULL, &dev_opp->opp_list, opp_descend_cmp);
+
 	list_for_each_entry(opp, &dev_opp->opp_list, node) {
 		if (opp->available) {
 			freq_table[i].driver_data = i;
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index 5151b00..cf42770 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -118,13 +118,16 @@ static inline int of_init_opp_table(struct device
*dev)
 #endif
 
 #if defined(CONFIG_CPU_FREQ) && defined(CONFIG_PM_OPP)
+
+#define OPP_TABLE_ORDER_DESCEND                (1 << 1)
+
 int dev_pm_opp_init_cpufreq_table(struct device *dev,
-			    struct cpufreq_frequency_table **table);
+		struct cpufreq_frequency_table **table, unsigned char
flags);
 void dev_pm_opp_free_cpufreq_table(struct device *dev,
 				struct cpufreq_frequency_table **table);
 #else
 static inline int dev_pm_opp_init_cpufreq_table(struct device *dev,
-			    struct cpufreq_frequency_table **table)
+		struct cpufreq_frequency_table **table, unsigned char flags)
 {
 	return -EINVAL;
 }
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2014-05-12  6:18 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-30  6:28 [PATCH 1/3] PM / OPP: Add support for descending order for cpufreq table Jonghwan Choi
2014-04-30  8:25 ` Viresh Kumar
2014-05-03  0:16   ` Jonghwan Choi
2014-05-05  5:54     ` Viresh Kumar
2014-05-05 13:38       ` Nishanth Menon
2014-05-05 14:14         ` Viresh Kumar
2014-05-05 14:23           ` Nishanth Menon
2014-05-05 14:38             ` Viresh Kumar
2014-05-05 14:46               ` Nishanth Menon
2014-05-06 23:43               ` Jonghwan Choi
2014-05-07  1:00                 ` Nishanth Menon
2014-05-07  6:04                   ` Viresh Kumar
2014-05-08  1:22                     ` Jonghwan Choi
2014-05-08  1:55                       ` Nishanth Menon
2014-05-08  2:07                         ` Jonghwan Choi
2014-05-08  5:55                           ` Viresh Kumar
2014-05-09  1:09                             ` Jonghwan Choi
2014-05-09  6:00                               ` Viresh Kumar
2014-05-09 11:59                                 ` jonghwan Choi
2014-05-09 13:23                                   ` Nishanth Menon
2014-05-11 11:38                                     ` jonghwan Choi
2014-05-12  6:18                                       ` Viresh Kumar
2014-05-08  5:50                         ` Viresh Kumar
2014-05-06 17:25           ` Sudeep Holla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).