linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [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
* [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

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-09 21:59 [PATCH] thermal: step_wise: set throttle target within thermal instance limits Andrew Bresticker
2013-04-10  7:06 ` Zhang Rui
2013-04-10 20:22   ` Eduardo Valentin
2013-04-11 23:25     ` Zhang Rui
  -- strict thread matches above, loose matches on Subject: below --
2013-04-08 23:56 Andrew Bresticker
2013-04-09 15:00 ` Eduardo Valentin
2013-04-09 17:09   ` Andrew Bresticker
2013-04-09 17:17     ` Eduardo Valentin

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