Skip to contentSkip to conversation

thermal: step_wise: set throttle target within thermal instance limits

PATCH Applied Andrew Bresticker 3 participants 4 messages Apr 9, 2013 – Apr 11, 2013 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal: step_wise: set throttle target within thermal instance limits

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.

---
 drivers/thermal/step_wise.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/thermal/step_wise.c +8 -2
index 407cde3..ca4f79f 100644
@@ -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) {
Signature · 1 line
1.8.1.3
reviewer Applied
#1 lore raw
Quoted 11 lines · 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.

Quoted 1 line

applied.

thanks,
rui

Quoted 35 lines
---
 drivers/thermal/step_wise.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/thermal/step_wise.c +8 -2
index 407cde3..ca4f79f 100644
@@ -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) {
#2 lore raw
Quoted 12 lines · Zhang Rui
Quoted 11 lines · 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.

Quoted 3 lines
Quoted 1 line

applied.

Rui,

Can you please add my:

Thanks,

Quoted 42 lines

thanks,
rui

Quoted 35 lines
---
  drivers/thermal/step_wise.c | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)
drivers/thermal/step_wise.c +8 -2
index 407cde3..ca4f79f 100644
@@ -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) {
reviewer
#3 lore raw
Quoted 15 lines · Eduardo Valentin
Quoted 14 lines · Zhang Rui
Quoted 12 lines · 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.

Quoted 8 lines
Quoted 1 line

applied.

Rui,

Can you please add my:

sure. Thanks for reviewing.

thanks,
rui

Quoted 45 lines

Thanks,

Quoted 42 lines

thanks,
rui

Quoted 35 lines
---
  drivers/thermal/step_wise.c | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)
drivers/thermal/step_wise.c +8 -2
index 407cde3..ca4f79f 100644
@@ -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) {