Skip to contentSkip to conversation

thermal: intel_powerclamp: Return last requested state as cur_state

PATCH Superseded Srinivas Pandruvada 2 participants 4 messages Feb 1, 2023 – Feb 3, 2023 Thermal

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal: intel_powerclamp: Return last requested state as cur_state

When the user is reading cur_state from the thermal cooling device for Intel powerclamp device:
- It returns the idle ratio from Package C-state counters when there is active idle injection session.
- -1, when there is no active idle injection session.

This information is not very useful as the package C-state counters vary a lot from read to read. Instead just return the last requested cur_state.

---
 drivers/thermal/intel/intel_powerclamp.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/thermal/intel/intel_powerclamp.c +1 -11
index 2f4cbfdf26a0..72a45cf2708c 100644
@@ -590,17 +590,7 @@ static int powerclamp_get_max_state(struct thermal_cooling_device *cdev,
 static int powerclamp_get_cur_state(struct thermal_cooling_device *cdev,
 				 unsigned long *state)
 {
-	if (clamping) {
-		if (poll_pkg_cstate_enable)
-			*state = pkg_cstate_ratio_cur;
-		else
-			*state = set_target_ratio;
-	} else {
-		/* to save power, do not poll idle ratio while not clamping */
-		*state = -1; /* indicates invalid state */
-	}
-
-	return 0;
+	return set_target_ratio;
 }
 
 static int powerclamp_set_cur_state(struct thermal_cooling_device *cdev,
Signature · 1 line
2.39.1
#1 lore raw
Quoted 25 lines · Srinivas Pandruvada

When the user is reading cur_state from the thermal cooling device for Intel powerclamp device:
- It returns the idle ratio from Package C-state counters when there is active idle injection session.
- -1, when there is no active idle injection session.

This information is not very useful as the package C-state counters vary a lot from read to read. Instead just return the last requested cur_state.

---
 drivers/thermal/intel/intel_powerclamp.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/thermal/intel/intel_powerclamp.c +0 -2
index 2f4cbfdf26a0..72a45cf2708c 100644
@@ -590,17 +590,7 @@ static int powerclamp_get_max_state(struct thermal_cooling_device *cdev,
 static int powerclamp_get_cur_state(struct thermal_cooling_device *cdev,
                                 unsigned long *state)
 {
-       if (clamping) {
-               if (poll_pkg_cstate_enable)

drivers/thermal/intel/intel_powerclamp.c static int powerclamp_get_max_state(struct thermal_cooling_device *cdev, · line 593

Quoted 10 lines
drivers/thermal/intel/intel_powerclamp.c +1 -9
-                       *state = pkg_cstate_ratio_cur;
-               else
-                       *state = set_target_ratio;
-       } else {
-               /* to save power, do not poll idle ratio while not clamping */
-               *state = -1; /* indicates invalid state */
-       }
-
-       return 0;
+       return set_target_ratio;

*state = set_target_ratio;
return 0;

drivers/thermal/intel/intel_powerclamp.c static int powerclamp_get_max_state(struct thermal_cooling_device *cdev,

Quoted 4 lines
drivers/thermal/intel/intel_powerclamp.c +0 -1
 }
 
 static int powerclamp_set_cur_state(struct thermal_cooling_device *cdev,
--

And please rebase it on top of the idle_inject series (which is being added to my bleeding-edge branch right now).

#2 lore raw
Quoted 40 lines · Rafael J. Wysocki
Quoted 38 lines · Srinivas Pandruvada

When the user is reading cur_state from the thermal cooling device for
Intel powerclamp device:
- It returns the idle ratio from Package C-state counters when there is active idle injection session.
- -1, when there is no active idle injection session.

This information is not very useful as the package C-state counters vary
a lot from read to read. Instead just return the last requested cur_state.

Signed-off-by: Srinivas Pandruvada <[email protected]>
---
 drivers/thermal/intel/intel_powerclamp.c | 12 +-----------

 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/thermal/intel/intel_powerclamp.c +0 -0
index 2f4cbfdf26a0..72a45cf2708c 100644
@@ -590,17 +590,7 @@ static int powerclamp_get_max_state(struct
 thermal_cooling_device *cdev,

 static int powerclamp_get_cur_state(struct thermal_cooling_device *cdev,
                                 unsigned long *state) {
-       if (clamping) {
-               if (poll_pkg_cstate_enable)
-                       *state = pkg_cstate_ratio_cur; -               else
-                       *state = set_target_ratio;
-       } else {
-               /* to save power, do not poll idle ratio while not clamping */

Quoted 9 lines
Quoted 5 lines

-               *state = -1; /* indicates invalid state */ -       }
-
-       return 0;
+       return set_target_ratio;

*state = set_target_ratio;
return 0;

Sorry.

What a blunder! Sent patch from 37000 ft. Should never do that.

Thanks,
Srinivas

Quoted 8 lines
Quoted 5 lines

 }

 static int powerclamp_set_cur_state(struct thermal_cooling_device *cdev,
--

And please rebase it on top of the idle_inject series (which is being added to my bleeding-edge branch right now).

#3 lore raw
Quoted 51 lines · srinivas pandruvada
Quoted 40 lines · Rafael J. Wysocki
Quoted 38 lines · Srinivas Pandruvada

When the user is reading cur_state from the thermal cooling device for
Intel powerclamp device:
- It returns the idle ratio from Package C-state counters when there is active idle injection session.
- -1, when there is no active idle injection session.

This information is not very useful as the package C-state counters vary
a lot from read to read. Instead just return the last requested cur_state.

Signed-off-by: Srinivas Pandruvada
<[email protected]>

---
 drivers/thermal/intel/intel_powerclamp.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/thermal/intel/intel_powerclamp.c +0 -7
index 2f4cbfdf26a0..72a45cf2708c 100644
@@ -590,17 +590,7 @@ static int powerclamp_get_max_state(struct
 thermal_cooling_device *cdev,
 static int powerclamp_get_cur_state(struct thermal_cooling_device
 *cdev,
                                 unsigned long *state)
 {
-       if (clamping) {
-               if (poll_pkg_cstate_enable)
-                       *state = pkg_cstate_ratio_cur;
-               else
-                       *state = set_target_ratio;
-       } else {
-               /* to save power, do not poll idle ratio while not

clamping */

Quoted 9 lines

drivers/thermal/intel/intel_powerclamp.c static int powerclamp_get_max_state(struct thermal_cooling_device *cdev, · line 593

Quoted 5 lines
drivers/thermal/intel/intel_powerclamp.c +1 -4
-               *state = -1; /* indicates invalid state */
-       }
-
-       return 0;
+       return set_target_ratio;

*state = set_target_ratio;
return 0;

Quoted 3 lines

Sorry.

What a blunder! Sent patch from 37000 ft. Should never do that.

No worries.

I didn't realize that you were traveling.

I can prepare this patch myself just fine if that helps.