diff mbox series

[v1] thermal: devfreq_cooling: Fix perf state when calculate dfc res_util

Message ID 20240320075704.1924897-1-ye.zhang@rock-chips.com (mailing list archive)
State New
Headers show
Series [v1] thermal: devfreq_cooling: Fix perf state when calculate dfc res_util | expand

Commit Message

Ye Zhang March 20, 2024, 7:57 a.m. UTC
The EM power table is sorted ascending,can't index the table by cooling
device state,so convert cooling state to performance state by
dfc->max_state - dfc->capped_state.

Signed-off-by: Ye Zhang <ye.zhang@rock-chips.com>
---
 drivers/thermal/devfreq_cooling.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Lukasz Luba March 20, 2024, 2:15 p.m. UTC | #1
Hi Ye,

On 3/20/24 07:57, Ye Zhang wrote:
> The EM power table is sorted ascending,can't index the table by cooling
> device state,so convert cooling state to performance state by
> dfc->max_state - dfc->capped_state.
> 
> Signed-off-by: Ye Zhang <ye.zhang@rock-chips.com>
> ---
>   drivers/thermal/devfreq_cooling.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c
> index 50dec24e967a..8fd7cf1932cd 100644
> --- a/drivers/thermal/devfreq_cooling.c
> +++ b/drivers/thermal/devfreq_cooling.c
> @@ -214,7 +214,7 @@ static int devfreq_cooling_get_requested_power(struct thermal_cooling_device *cd
>   
>   		res = dfc->power_ops->get_real_power(df, power, freq, voltage);
>   		if (!res) {
> -			state = dfc->capped_state;
> +			state = dfc->max_state - dfc->capped_state;
>   
>   			/* Convert EM power into milli-Watts first */
>   			rcu_read_lock();

Thank you for the patch. Good catch! It's under the device driver
callback optional thing: get_real_power().

Please send the v2 with extended explanation about the section
of the code, which is triggered by the get_real_power() presence.
Also, please add the tags, so it can be collected by stable kernel.

Fixes: 615510fe13bd2434610 ("thermal: devfreq_cooling: remove old power 
model and use EM")
Cc: 5.11+ <stable@vger.kernel.org> # 5.11+

BTW, how did you trigger that issue? Do you have such a driver
which provides this get_real_power() callback?

Regards,
Lukasz
Lukasz Luba March 21, 2024, 8:44 a.m. UTC | #2
On 3/21/24 08:37, 张烨 wrote:
> 
> Hi Lukasz,
> 
> Regarding your question about how I triggered the issue andifI have a 
> driver that provides the get_real_power() callback:
> 
> I encountered thisissue whilecalculating the GPU power consumption onthe 
> Rockchip RK3399 platform. The GPU model isMali T860, which isan ARM 
> Midgard GPU. The driver version isr18p0-01rel0, andit provides the 
> get_real_power() callback.Best regards, Ye Zhang

Yes that would trigger the issue. Thank you Ye for
sharing that.

BTW, I also use RK3399 for my mainline kernel development.
I use the Rock Pi 4SE with the mainline GPU driver
'panfrost'. That GPU driver doesn't support the get_real_power()
callback, but maybe it would be worth to add it...

Please send the v2 and I will add my reviewed-by tag for it.

Regards,
Lukasz
diff mbox series

Patch

diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c
index 50dec24e967a..8fd7cf1932cd 100644
--- a/drivers/thermal/devfreq_cooling.c
+++ b/drivers/thermal/devfreq_cooling.c
@@ -214,7 +214,7 @@  static int devfreq_cooling_get_requested_power(struct thermal_cooling_device *cd
 
 		res = dfc->power_ops->get_real_power(df, power, freq, voltage);
 		if (!res) {
-			state = dfc->capped_state;
+			state = dfc->max_state - dfc->capped_state;
 
 			/* Convert EM power into milli-Watts first */
 			rcu_read_lock();