linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thermal: step_wise: set throttle target within thermal instance limits
@ 2013-04-08 23:56 Andrew Bresticker
  2013-04-09 15:00 ` Eduardo Valentin
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Bresticker @ 2013-04-08 23:56 UTC (permalink / raw)
  To: Zhang Rui; +Cc: linux-pm, linux-kernel, Andrew Bresticker

When selecting a target cooling state in get_target_state(), make sure
that the state is at least as high as the minimum when the temperature
is rising and at least as low as the maximum when the temperature is
falling.  Previously the cooling level would only be incremented or
decremented by one in these cases.

Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
---
 drivers/thermal/step_wise.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
index 0cd5e9f..49992a4 100644
--- a/drivers/thermal/step_wise.c
+++ b/drivers/thermal/step_wise.c
@@ -47,9 +47,13 @@ static unsigned long get_target_state(struct thermal_instance *instance,
 	if (trend == THERMAL_TREND_RAISING) {
 		cur_state = cur_state < instance->upper ?
 			    (cur_state + 1) : instance->upper;
+		if (cur_state < instance->lower)
+			cur_state = instance->lower;
 	} else if (trend == THERMAL_TREND_DROPPING) {
 		cur_state = cur_state > instance->lower ?
 			    (cur_state - 1) : instance->lower;
+		if (cur_state > instance->upper)
+			cur_state = instance->upper;
 	}
 
 	return cur_state;
-- 
1.8.1.3


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

* Re: [PATCH] thermal: step_wise: set throttle target within thermal instance limits
  2013-04-08 23:56 [PATCH] thermal: step_wise: set throttle target within thermal instance limits Andrew Bresticker
@ 2013-04-09 15:00 ` Eduardo Valentin
  2013-04-09 17:09   ` Andrew Bresticker
  0 siblings, 1 reply; 8+ messages in thread
From: Eduardo Valentin @ 2013-04-09 15:00 UTC (permalink / raw)
  To: Andrew Bresticker; +Cc: Zhang Rui, linux-pm, linux-kernel, eduardo.valentin

Hi Andrew,

On 08-04-2013 19:56, Andrew Bresticker wrote:
> When selecting a target cooling state in get_target_state(), make sure
> that the state is at least as high as the minimum when the temperature
> is rising and at least as low as the maximum when the temperature is
> falling.  Previously the cooling level would only be incremented or
> decremented by one in these cases.
>
> Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
> ---
>   drivers/thermal/step_wise.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
> index 0cd5e9f..49992a4 100644
> --- a/drivers/thermal/step_wise.c
> +++ b/drivers/thermal/step_wise.c
> @@ -47,9 +47,13 @@ static unsigned long get_target_state(struct thermal_instance *instance,
>   	if (trend == THERMAL_TREND_RAISING) {
>   		cur_state = cur_state < instance->upper ?
>   			    (cur_state + 1) : instance->upper;
> +		if (cur_state < instance->lower)
> +			cur_state = instance->lower;
>   	} else if (trend == THERMAL_TREND_DROPPING) {
>   		cur_state = cur_state > instance->lower ?
>   			    (cur_state - 1) : instance->lower;
> +		if (cur_state > instance->upper)
> +			cur_state = instance->upper;
>   	}


In which situations cur_state will be out of the [lower;upper] 
boundaries? I mean at this point while temperature is rising, and we are 
rising the cooling level, we should be already above lower (and 
vice-versa). Can you please describe better the situation you are trying 
to cover/ that you have identified?

>
>   	return cur_state;
>


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

* Re: [PATCH] thermal: step_wise: set throttle target within thermal instance limits
  2013-04-09 15:00 ` Eduardo Valentin
@ 2013-04-09 17:09   ` Andrew Bresticker
  2013-04-09 17:17     ` Eduardo Valentin
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Bresticker @ 2013-04-09 17:09 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: Zhang Rui, linux-pm, linux-kernel

Hi Eduardo,

On Tue, Apr 9, 2013 at 8:00 AM, Eduardo Valentin
<eduardo.valentin@ti.com> wrote:
> Hi Andrew,
>
>
> On 08-04-2013 19:56, Andrew Bresticker wrote:
>>
>> When selecting a target cooling state in get_target_state(), make sure
>> that the state is at least as high as the minimum when the temperature
>> is rising and at least as low as the maximum when the temperature is
>> falling.  Previously the cooling level would only be incremented or
>> decremented by one in these cases.
>>
>> Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
>> ---
>>   drivers/thermal/step_wise.c | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
>> index 0cd5e9f..49992a4 100644
>> --- a/drivers/thermal/step_wise.c
>> +++ b/drivers/thermal/step_wise.c
>> @@ -47,9 +47,13 @@ static unsigned long get_target_state(struct
>> thermal_instance *instance,
>>         if (trend == THERMAL_TREND_RAISING) {
>>                 cur_state = cur_state < instance->upper ?
>>                             (cur_state + 1) : instance->upper;
>> +               if (cur_state < instance->lower)
>> +                       cur_state = instance->lower;
>>         } else if (trend == THERMAL_TREND_DROPPING) {
>>                 cur_state = cur_state > instance->lower ?
>>                             (cur_state - 1) : instance->lower;
>> +               if (cur_state > instance->upper)
>> +                       cur_state = instance->upper;
>>         }
>
>
>
> In which situations cur_state will be out of the [lower;upper] boundaries? I
> mean at this point while temperature is rising, and we are rising the
> cooling level, we should be already above lower (and vice-versa). Can you
> please describe better the situation you are trying to cover/ that you have
> identified?

Suppose we hit a trip point which has bounds from 5 to 10, but
cur_state is 0 because there has previously been no thermal
throttling.  In that case, we would only go to level 1, even though
the thermal instance specifies we should be between 5 and 10.  This
patch would fix it so that we go directly to level 5 instead.

I will resend this with a more descriptive commit message.

>
>>
>>         return cur_state;
>>
>

Thanks,
Andrew

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

* Re: [PATCH] thermal: step_wise: set throttle target within thermal instance limits
  2013-04-09 17:09   ` Andrew Bresticker
@ 2013-04-09 17:17     ` Eduardo Valentin
  0 siblings, 0 replies; 8+ messages in thread
From: Eduardo Valentin @ 2013-04-09 17:17 UTC (permalink / raw)
  To: Andrew Bresticker; +Cc: Eduardo Valentin, Zhang Rui, linux-pm, linux-kernel

On 09-04-2013 13:09, Andrew Bresticker wrote:
> Hi Eduardo,
>
> On Tue, Apr 9, 2013 at 8:00 AM, Eduardo Valentin
> <eduardo.valentin@ti.com> wrote:
>> Hi Andrew,
>>
>>
>> On 08-04-2013 19:56, Andrew Bresticker wrote:
>>>
>>> When selecting a target cooling state in get_target_state(), make sure
>>> that the state is at least as high as the minimum when the temperature
>>> is rising and at least as low as the maximum when the temperature is
>>> falling.  Previously the cooling level would only be incremented or
>>> decremented by one in these cases.
>>>
>>> Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
>>> ---
>>>    drivers/thermal/step_wise.c | 4 ++++
>>>    1 file changed, 4 insertions(+)
>>>
>>> diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
>>> index 0cd5e9f..49992a4 100644
>>> --- a/drivers/thermal/step_wise.c
>>> +++ b/drivers/thermal/step_wise.c
>>> @@ -47,9 +47,13 @@ static unsigned long get_target_state(struct
>>> thermal_instance *instance,
>>>          if (trend == THERMAL_TREND_RAISING) {
>>>                  cur_state = cur_state < instance->upper ?
>>>                              (cur_state + 1) : instance->upper;
>>> +               if (cur_state < instance->lower)
>>> +                       cur_state = instance->lower;
>>>          } else if (trend == THERMAL_TREND_DROPPING) {
>>>                  cur_state = cur_state > instance->lower ?
>>>                              (cur_state - 1) : instance->lower;
>>> +               if (cur_state > instance->upper)
>>> +                       cur_state = instance->upper;
>>>          }
>>
>>
>>
>> In which situations cur_state will be out of the [lower;upper] boundaries? I
>> mean at this point while temperature is rising, and we are rising the
>> cooling level, we should be already above lower (and vice-versa). Can you
>> please describe better the situation you are trying to cover/ that you have
>> identified?
>
> Suppose we hit a trip point which has bounds from 5 to 10, but
> cur_state is 0 because there has previously been no thermal
> throttling.  In that case, we would only go to level 1, even though
> the thermal instance specifies we should be between 5 and 10.  This
> patch would fix it so that we go directly to level 5 instead.
>
> I will resend this with a more descriptive commit message.

Thanks, I appreciate it.

>
>>
>>>
>>>          return cur_state;
>>>
>>
>
> Thanks,
> Andrew
>
>


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

* Re: [PATCH] thermal: step_wise: set throttle target within thermal instance limits
  2013-04-10 20:22   ` Eduardo Valentin
@ 2013-04-11 23:25     ` Zhang Rui
  0 siblings, 0 replies; 8+ messages in thread
From: Zhang Rui @ 2013-04-11 23:25 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: Andrew Bresticker, linux-pm, linux-kernel

On Wed, 2013-04-10 at 16:22 -0400, Eduardo Valentin wrote:
> On 10-04-2013 03:06, Zhang Rui wrote:
> > On Tue, 2013-04-09 at 14:59 -0700, Andrew Bresticker wrote:
> >> When selecting a target cooling state in get_target_state(), make sure
> >> that the state is at least as high as the minimum when the temperature
> >> is rising and at least as low as the maximum when the temperature is
> >> falling.  This is necessary because, in the THREAML_TREND_RAISING and
> >> THERMAL_TREND_DROPPING cases, the current state may only be incremented
> >> or decremented by one even if it is outside the bounds of the thermal
> >> instance.  This might occur, for example, if the CPU is heating up
> >> and hits a thermal trip point for the first time when it's frequency
> >> is much higher than the range specified by the thermal instance
> >> corresponding to the trip point.
> >>
> >> Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
> >
> > applied.
> 
> Rui,
> 
> Can you please add my:
> 
> Acked-by: Eduardo Valentin <eduardo.valentin@ti.com>
> 
sure. Thanks for reviewing.

thanks,
rui
> 
> Thanks,
> >
> > thanks,
> > rui
> >> ---
> >>   drivers/thermal/step_wise.c | 10 ++++++++--
> >>   1 file changed, 8 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
> >> index 407cde3..ca4f79f 100644
> >> --- a/drivers/thermal/step_wise.c
> >> +++ b/drivers/thermal/step_wise.c
> >> @@ -59,9 +59,12 @@ static unsigned long get_target_state(struct thermal_instance *instance,
> >>
> >>   	switch (trend) {
> >>   	case THERMAL_TREND_RAISING:
> >> -		if (throttle)
> >> +		if (throttle) {
> >>   			cur_state = cur_state < instance->upper ?
> >>   				    (cur_state + 1) : instance->upper;
> >> +			if (cur_state < instance->lower)
> >> +				cur_state = instance->lower;
> >> +		}
> >>   		break;
> >>   	case THERMAL_TREND_RAISE_FULL:
> >>   		if (throttle)
> >> @@ -71,8 +74,11 @@ static unsigned long get_target_state(struct thermal_instance *instance,
> >>   		if (cur_state == instance->lower) {
> >>   			if (!throttle)
> >>   				cur_state = -1;
> >> -		} else
> >> +		} else {
> >>   			cur_state -= 1;
> >> +			if (cur_state > instance->upper)
> >> +				cur_state = instance->upper;
> >> +		}
> >>   		break;
> >>   	case THERMAL_TREND_DROP_FULL:
> >>   		if (cur_state == instance->lower) {
> >
> >
> >
> >
> 



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

* Re: [PATCH] thermal: step_wise: set throttle target within thermal instance limits
  2013-04-10  7:06 ` Zhang Rui
@ 2013-04-10 20:22   ` Eduardo Valentin
  2013-04-11 23:25     ` Zhang Rui
  0 siblings, 1 reply; 8+ messages in thread
From: Eduardo Valentin @ 2013-04-10 20:22 UTC (permalink / raw)
  To: Zhang Rui; +Cc: Andrew Bresticker, Eduardo Valentin, linux-pm, linux-kernel

On 10-04-2013 03:06, Zhang Rui wrote:
> On Tue, 2013-04-09 at 14:59 -0700, Andrew Bresticker wrote:
>> When selecting a target cooling state in get_target_state(), make sure
>> that the state is at least as high as the minimum when the temperature
>> is rising and at least as low as the maximum when the temperature is
>> falling.  This is necessary because, in the THREAML_TREND_RAISING and
>> THERMAL_TREND_DROPPING cases, the current state may only be incremented
>> or decremented by one even if it is outside the bounds of the thermal
>> instance.  This might occur, for example, if the CPU is heating up
>> and hits a thermal trip point for the first time when it's frequency
>> is much higher than the range specified by the thermal instance
>> corresponding to the trip point.
>>
>> Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
>
> applied.

Rui,

Can you please add my:

Acked-by: Eduardo Valentin <eduardo.valentin@ti.com>


Thanks,
>
> thanks,
> rui
>> ---
>>   drivers/thermal/step_wise.c | 10 ++++++++--
>>   1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
>> index 407cde3..ca4f79f 100644
>> --- a/drivers/thermal/step_wise.c
>> +++ b/drivers/thermal/step_wise.c
>> @@ -59,9 +59,12 @@ static unsigned long get_target_state(struct thermal_instance *instance,
>>
>>   	switch (trend) {
>>   	case THERMAL_TREND_RAISING:
>> -		if (throttle)
>> +		if (throttle) {
>>   			cur_state = cur_state < instance->upper ?
>>   				    (cur_state + 1) : instance->upper;
>> +			if (cur_state < instance->lower)
>> +				cur_state = instance->lower;
>> +		}
>>   		break;
>>   	case THERMAL_TREND_RAISE_FULL:
>>   		if (throttle)
>> @@ -71,8 +74,11 @@ static unsigned long get_target_state(struct thermal_instance *instance,
>>   		if (cur_state == instance->lower) {
>>   			if (!throttle)
>>   				cur_state = -1;
>> -		} else
>> +		} else {
>>   			cur_state -= 1;
>> +			if (cur_state > instance->upper)
>> +				cur_state = instance->upper;
>> +		}
>>   		break;
>>   	case THERMAL_TREND_DROP_FULL:
>>   		if (cur_state == instance->lower) {
>
>
>
>


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

* Re: [PATCH] thermal: step_wise: set throttle target within thermal instance limits
  2013-04-09 21:59 Andrew Bresticker
@ 2013-04-10  7:06 ` Zhang Rui
  2013-04-10 20:22   ` Eduardo Valentin
  0 siblings, 1 reply; 8+ messages in thread
From: Zhang Rui @ 2013-04-10  7:06 UTC (permalink / raw)
  To: Andrew Bresticker; +Cc: Eduardo Valentin, linux-pm, linux-kernel

On Tue, 2013-04-09 at 14:59 -0700, Andrew Bresticker wrote:
> When selecting a target cooling state in get_target_state(), make sure
> that the state is at least as high as the minimum when the temperature
> is rising and at least as low as the maximum when the temperature is
> falling.  This is necessary because, in the THREAML_TREND_RAISING and
> THERMAL_TREND_DROPPING cases, the current state may only be incremented
> or decremented by one even if it is outside the bounds of the thermal
> instance.  This might occur, for example, if the CPU is heating up
> and hits a thermal trip point for the first time when it's frequency
> is much higher than the range specified by the thermal instance
> corresponding to the trip point.
> 
> Signed-off-by: Andrew Bresticker <abrestic@chromium.org>

applied.

thanks,
rui
> ---
>  drivers/thermal/step_wise.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
> index 407cde3..ca4f79f 100644
> --- a/drivers/thermal/step_wise.c
> +++ b/drivers/thermal/step_wise.c
> @@ -59,9 +59,12 @@ static unsigned long get_target_state(struct thermal_instance *instance,
>  
>  	switch (trend) {
>  	case THERMAL_TREND_RAISING:
> -		if (throttle)
> +		if (throttle) {
>  			cur_state = cur_state < instance->upper ?
>  				    (cur_state + 1) : instance->upper;
> +			if (cur_state < instance->lower)
> +				cur_state = instance->lower;
> +		}
>  		break;
>  	case THERMAL_TREND_RAISE_FULL:
>  		if (throttle)
> @@ -71,8 +74,11 @@ static unsigned long get_target_state(struct thermal_instance *instance,
>  		if (cur_state == instance->lower) {
>  			if (!throttle)
>  				cur_state = -1;
> -		} else
> +		} else {
>  			cur_state -= 1;
> +			if (cur_state > instance->upper)
> +				cur_state = instance->upper;
> +		}
>  		break;
>  	case THERMAL_TREND_DROP_FULL:
>  		if (cur_state == instance->lower) {



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

* [PATCH] thermal: step_wise: set throttle target within thermal instance limits
@ 2013-04-09 21:59 Andrew Bresticker
  2013-04-10  7:06 ` Zhang Rui
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Bresticker @ 2013-04-09 21:59 UTC (permalink / raw)
  To: Zhang Rui, Eduardo Valentin; +Cc: linux-pm, linux-kernel, Andrew Bresticker

When selecting a target cooling state in get_target_state(), make sure
that the state is at least as high as the minimum when the temperature
is rising and at least as low as the maximum when the temperature is
falling.  This is necessary because, in the THREAML_TREND_RAISING and
THERMAL_TREND_DROPPING cases, the current state may only be incremented
or decremented by one even if it is outside the bounds of the thermal
instance.  This might occur, for example, if the CPU is heating up
and hits a thermal trip point for the first time when it's frequency
is much higher than the range specified by the thermal instance
corresponding to the trip point.

Signed-off-by: Andrew Bresticker <abrestic@chromium.org>
---
 drivers/thermal/step_wise.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c
index 407cde3..ca4f79f 100644
--- a/drivers/thermal/step_wise.c
+++ b/drivers/thermal/step_wise.c
@@ -59,9 +59,12 @@ static unsigned long get_target_state(struct thermal_instance *instance,
 
 	switch (trend) {
 	case THERMAL_TREND_RAISING:
-		if (throttle)
+		if (throttle) {
 			cur_state = cur_state < instance->upper ?
 				    (cur_state + 1) : instance->upper;
+			if (cur_state < instance->lower)
+				cur_state = instance->lower;
+		}
 		break;
 	case THERMAL_TREND_RAISE_FULL:
 		if (throttle)
@@ -71,8 +74,11 @@ static unsigned long get_target_state(struct thermal_instance *instance,
 		if (cur_state == instance->lower) {
 			if (!throttle)
 				cur_state = -1;
-		} else
+		} else {
 			cur_state -= 1;
+			if (cur_state > instance->upper)
+				cur_state = instance->upper;
+		}
 		break;
 	case THERMAL_TREND_DROP_FULL:
 		if (cur_state == instance->lower) {
-- 
1.8.1.3


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

end of thread, other threads:[~2013-04-11 23:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-08 23:56 [PATCH] thermal: step_wise: set throttle target within thermal instance limits Andrew Bresticker
2013-04-09 15:00 ` Eduardo Valentin
2013-04-09 17:09   ` Andrew Bresticker
2013-04-09 17:17     ` Eduardo Valentin
2013-04-09 21:59 Andrew Bresticker
2013-04-10  7:06 ` Zhang Rui
2013-04-10 20:22   ` Eduardo Valentin
2013-04-11 23:25     ` Zhang Rui

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).