* Re: [PATCH 3/5] Thermal: Get cpu frequency via cpu cooling table
[not found] <CADGdYn4uusfk5gQ+tf8=VvaTLzTHkkfZJ9cLBojTwy8fT7vPoA@mail.gmail.com>
@ 2013-02-07 1:44 ` amit daniel kachhap
0 siblings, 0 replies; 2+ messages in thread
From: amit daniel kachhap @ 2013-02-07 1:44 UTC (permalink / raw)
To: Zhang Rui; +Cc: linux-pm, Gu1, Hongbo Zhang, amit kachhap
Few comments below,
On Wed, Feb 6, 2013 at 5:41 PM, amit kachhap <amit.kachhap@gmail.com> wrote:
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> ---
> drivers/thermal/cpu_cooling.c | 45 ++++++++---------------------------------
> 1 file changed, 8 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
> index 08f12c7..57bb669 100644
> --- a/drivers/thermal/cpu_cooling.c
> +++ b/drivers/thermal/cpu_cooling.c
> @@ -186,46 +186,17 @@ get_cpu_cooling_table(unsigned int cpu)
> */
> static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level)
> {
> - int ret = 0, i = 0;
> - unsigned long level_index;
> - bool descend = false;
> - struct cpufreq_frequency_table *table =
> - cpufreq_frequency_get_table(cpu);
> - if (!table)
> - return ret;
> -
> - while (table[i].frequency != CPUFREQ_TABLE_END) {
> - if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
> - continue;
> -
> - /*check if table in ascending or descending order*/
> - if ((table[i + 1].frequency != CPUFREQ_TABLE_END) &&
> - (table[i + 1].frequency < table[i].frequency)
> - && !descend) {
> - descend = true;
> - }
> + struct cpufreq_frequency_table *table;
> + unsigned int freq;
>
> - /*return if level matched and table in descending order*/
> - if (descend && i == level)
> - return table[i].frequency;
> - i++;
> - }
> - i--;
> + table = get_cpu_cooling_table(cpu);
> + if (IS_ERR(table))
> + return -EINVAL;
>
> - if (level > i || descend)
> - return ret;
> - level_index = i - level;
> + freq = table[level].frequency;
>
> - /*Scan the table in reverse order and match the level*/
> - while (i >= 0) {
> - if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
> - continue;
> - /*return if level matched*/
> - if (i == level_index)
> - return table[i].frequency;
> - i--;
> - }
> - return ret;
> + kfree(table);
> + return 0;
return freq instead of return 0.
> }
>
> /**
> --
> 1.7.9.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 0/5] Thermal: cpu cooling fix
@ 2013-02-06 4:30 Zhang Rui
2013-02-06 4:30 ` [PATCH 3/5] Thermal: Get cpu frequency via cpu cooling table Zhang Rui
0 siblings, 1 reply; 2+ messages in thread
From: Zhang Rui @ 2013-02-06 4:30 UTC (permalink / raw)
To: linux-pm; +Cc: amit.daniel, gu1, hongbo.zhang, Zhang Rui
the per_cpu cpufreq_frequency_table contains all the frequency entries
which are reported by platform code.
But this table is not clean enough because it may contain invalid,
duplicate entries, and it may be in either descending or asceding order.
converting between cpu frequency and cooling state using this table
in cpufreq cooling code is painful as each cooling state of
cpu cooling device must have a valid and unique frequency.
thus cpu cooling table is introduced in this patch set.
CPU cooling table is a table that
1. each entry represents a cpu cooling state,
aka, a different cpu frequency.
2. no invalid entry in this table
3. no duplicate entry in this table
4. the frequency of all the entries are in descending order, aka,
table[0] equals maximum frequency and cooling state 0.
And this is the table we are using inside cpufreq cooling generic code.
Besides, all the cpufreq cooling users, e.g. exynos, should touch
neither per_cpu cpufreq_frequency_table nor the cpu cooling table.
it should invoke cpufreq cooling API to do cooling_state/frequency
transition.
I just run build test here. It would be great that some of you
can test it on exynos.
any comments?
thanks,
rui
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 3/5] Thermal: Get cpu frequency via cpu cooling table
2013-02-06 4:30 [PATCH 0/5] Thermal: cpu cooling fix Zhang Rui
@ 2013-02-06 4:30 ` Zhang Rui
0 siblings, 0 replies; 2+ messages in thread
From: Zhang Rui @ 2013-02-06 4:30 UTC (permalink / raw)
To: linux-pm; +Cc: amit.daniel, gu1, hongbo.zhang, Zhang Rui
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
drivers/thermal/cpu_cooling.c | 45 ++++++++---------------------------------
1 file changed, 8 insertions(+), 37 deletions(-)
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 08f12c7..57bb669 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -186,46 +186,17 @@ get_cpu_cooling_table(unsigned int cpu)
*/
static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level)
{
- int ret = 0, i = 0;
- unsigned long level_index;
- bool descend = false;
- struct cpufreq_frequency_table *table =
- cpufreq_frequency_get_table(cpu);
- if (!table)
- return ret;
-
- while (table[i].frequency != CPUFREQ_TABLE_END) {
- if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
- continue;
-
- /*check if table in ascending or descending order*/
- if ((table[i + 1].frequency != CPUFREQ_TABLE_END) &&
- (table[i + 1].frequency < table[i].frequency)
- && !descend) {
- descend = true;
- }
+ struct cpufreq_frequency_table *table;
+ unsigned int freq;
- /*return if level matched and table in descending order*/
- if (descend && i == level)
- return table[i].frequency;
- i++;
- }
- i--;
+ table = get_cpu_cooling_table(cpu);
+ if (IS_ERR(table))
+ return -EINVAL;
- if (level > i || descend)
- return ret;
- level_index = i - level;
+ freq = table[level].frequency;
- /*Scan the table in reverse order and match the level*/
- while (i >= 0) {
- if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
- continue;
- /*return if level matched*/
- if (i == level_index)
- return table[i].frequency;
- i--;
- }
- return ret;
+ kfree(table);
+ return 0;
}
/**
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-02-07 1:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CADGdYn4uusfk5gQ+tf8=VvaTLzTHkkfZJ9cLBojTwy8fT7vPoA@mail.gmail.com>
2013-02-07 1:44 ` [PATCH 3/5] Thermal: Get cpu frequency via cpu cooling table amit daniel kachhap
2013-02-06 4:30 [PATCH 0/5] Thermal: cpu cooling fix Zhang Rui
2013-02-06 4:30 ` [PATCH 3/5] Thermal: Get cpu frequency via cpu cooling table Zhang Rui
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.