diff mbox

[v2,4/4] ARM:TMU:fix: Avoid lockup when first frequency table entry is CPUFREQ_ENTRY_INVALID

Message ID 1366893045-31586-5-git-send-email-l.majewski@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lukasz Majewski April 25, 2013, 12:30 p.m. UTC
With the while loop, when i=0 and first entry in the frequency table is
CPUFREQ_ENTRY_INVALID, the code results in an endless loop (since i is not
incremented).

To fix this problem the for loop has been chosen. Incrementing i in the for
end block solves the problem.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
Changes for v2:
- New in v2
---
 drivers/thermal/cpu_cooling.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Eduardo Valentin April 25, 2013, 3:11 p.m. UTC | #1
Lukasz,

On 25-04-2013 08:30, Lukasz Majewski wrote:
> With the while loop, when i=0 and first entry in the frequency table is
> CPUFREQ_ENTRY_INVALID, the code results in an endless loop (since i is not
> incremented).
>
> To fix this problem the for loop has been chosen. Incrementing i in the for
> end block solves the problem.
>
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> ---
> Changes for v2:
> - New in v2

This patch wont apply on Rui's tree.

I believe this has been already fixed on Rui's tree (next branch).
Could you please check if the commit below fix your issue:
git.kernel.org/cgit/linux/kernel/git/rzhang/linux.git/commit/?h=thermal&id=fc35b35cbe24ef021ea9acfba21e54da958df747

commit fc35b35cbe24ef021ea9acfba21e54da958df747
Author: Zhang Rui <rui.zhang@intel.com>
Date:   Fri Feb 8 13:09:32 2013 +0800

     Thermal: cpufreq cooling: fix parsing per_cpu cpufreq_frequency_table



> ---
>   drivers/thermal/cpu_cooling.c |    3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
> index 8dc44cb..df79f5e8 100644
> --- a/drivers/thermal/cpu_cooling.c
> +++ b/drivers/thermal/cpu_cooling.c
> @@ -124,7 +124,7 @@ static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level)
>   	if (!table)
>   		return ret;
>
> -	while (table[i].frequency != CPUFREQ_TABLE_END) {
> +	for (; table[i].frequency != CPUFREQ_TABLE_END; i++) {
>   		if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
>   			continue;
>
> @@ -138,7 +138,6 @@ static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level)
>   		/*return if level matched and table in descending order*/
>   		if (descend && i == level)
>   			return table[i].frequency;
> -		i++;
>   	}
>   	i--;
>
>

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lukasz Majewski April 25, 2013, 3:22 p.m. UTC | #2
Hi Eduardo,

> Lukasz,
> 
> On 25-04-2013 08:30, Lukasz Majewski wrote:
> > With the while loop, when i=0 and first entry in the frequency
> > table is CPUFREQ_ENTRY_INVALID, the code results in an endless loop
> > (since i is not incremented).
> >
> > To fix this problem the for loop has been chosen. Incrementing i in
> > the for end block solves the problem.
> >
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> > ---
> > Changes for v2:
> > - New in v2
> 
> This patch wont apply on Rui's tree.
> 
> I believe this has been already fixed on Rui's tree (next branch).
> Could you please check if the commit below fix your issue:
> git.kernel.org/cgit/linux/kernel/git/rzhang/linux.git/commit/?h=thermal&id=fc35b35cbe24ef021ea9acfba21e54da958df747
> 
> commit fc35b35cbe24ef021ea9acfba21e54da958df747
> Author: Zhang Rui <rui.zhang@intel.com>
> Date:   Fri Feb 8 13:09:32 2013 +0800
> 
>      Thermal: cpufreq cooling: fix parsing per_cpu
> cpufreq_frequency_table
> 

Thanks for pointing out. It seems, that this function fixes this
problem.

As a side note, is this problem fixed at stable kernels?

> 
> 
> > ---
> >   drivers/thermal/cpu_cooling.c |    3 +--
> >   1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/thermal/cpu_cooling.c
> > b/drivers/thermal/cpu_cooling.c index 8dc44cb..df79f5e8 100644
> > --- a/drivers/thermal/cpu_cooling.c
> > +++ b/drivers/thermal/cpu_cooling.c
> > @@ -124,7 +124,7 @@ static unsigned int get_cpu_frequency(unsigned
> > int cpu, unsigned long level) if (!table)
> >   		return ret;
> >
> > -	while (table[i].frequency != CPUFREQ_TABLE_END) {
> > +	for (; table[i].frequency != CPUFREQ_TABLE_END; i++) {
> >   		if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
> >   			continue;
> >
> > @@ -138,7 +138,6 @@ static unsigned int get_cpu_frequency(unsigned
> > int cpu, unsigned long level) /*return if level matched and table
> > in descending order*/ if (descend && i == level)
> >   			return table[i].frequency;
> > -		i++;
> >   	}
> >   	i--;
> >
> >
Eduardo Valentin April 25, 2013, 3:39 p.m. UTC | #3
On 25-04-2013 11:22, Lukasz Majewski wrote:
> Hi Eduardo,
>
>> Lukasz,
>>
>> On 25-04-2013 08:30, Lukasz Majewski wrote:
>>> With the while loop, when i=0 and first entry in the frequency
>>> table is CPUFREQ_ENTRY_INVALID, the code results in an endless loop
>>> (since i is not incremented).
>>>
>>> To fix this problem the for loop has been chosen. Incrementing i in
>>> the for end block solves the problem.
>>>
>>> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
>>> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
>>> ---
>>> Changes for v2:
>>> - New in v2
>>
>> This patch wont apply on Rui's tree.
>>
>> I believe this has been already fixed on Rui's tree (next branch).
>> Could you please check if the commit below fix your issue:
>> git.kernel.org/cgit/linux/kernel/git/rzhang/linux.git/commit/?h=thermal&id=fc35b35cbe24ef021ea9acfba21e54da958df747
>>
>> commit fc35b35cbe24ef021ea9acfba21e54da958df747
>> Author: Zhang Rui <rui.zhang@intel.com>
>> Date:   Fri Feb 8 13:09:32 2013 +0800
>>
>>       Thermal: cpufreq cooling: fix parsing per_cpu
>> cpufreq_frequency_table
>>
>
> Thanks for pointing out. It seems, that this function fixes this
> problem.

OK.

>
> As a side note, is this problem fixed at stable kernels?

Good question, probably not!

>
>>
>>
>>> ---
>>>    drivers/thermal/cpu_cooling.c |    3 +--
>>>    1 file changed, 1 insertion(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/thermal/cpu_cooling.c
>>> b/drivers/thermal/cpu_cooling.c index 8dc44cb..df79f5e8 100644
>>> --- a/drivers/thermal/cpu_cooling.c
>>> +++ b/drivers/thermal/cpu_cooling.c
>>> @@ -124,7 +124,7 @@ static unsigned int get_cpu_frequency(unsigned
>>> int cpu, unsigned long level) if (!table)
>>>    		return ret;
>>>
>>> -	while (table[i].frequency != CPUFREQ_TABLE_END) {
>>> +	for (; table[i].frequency != CPUFREQ_TABLE_END; i++) {
>>>    		if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
>>>    			continue;
>>>
>>> @@ -138,7 +138,6 @@ static unsigned int get_cpu_frequency(unsigned
>>> int cpu, unsigned long level) /*return if level matched and table
>>> in descending order*/ if (descend && i == level)
>>>    			return table[i].frequency;
>>> -		i++;
>>>    	}
>>>    	i--;
>>>
>>>
>
>
>

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 8dc44cb..df79f5e8 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -124,7 +124,7 @@  static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level)
 	if (!table)
 		return ret;
 
-	while (table[i].frequency != CPUFREQ_TABLE_END) {
+	for (; table[i].frequency != CPUFREQ_TABLE_END; i++) {
 		if (table[i].frequency == CPUFREQ_ENTRY_INVALID)
 			continue;
 
@@ -138,7 +138,6 @@  static unsigned int get_cpu_frequency(unsigned int cpu, unsigned long level)
 		/*return if level matched and table in descending order*/
 		if (descend && i == level)
 			return table[i].frequency;
-		i++;
 	}
 	i--;