2024-04-10 17:48:05

by Rafael J. Wysocki

[permalink] [raw]
Subject: [PATCH v1 05/16] thermal: core: Introduce .manage() callback for thermal governors

From: Rafael J. Wysocki <[email protected]>

Introduce a new thermal governor callback called .manage() that will be
invoked once per thermal zone update after processing all of the trip
points in the core.

This will allow governors that look at multiple trip points together
to check all of them in a consistent configuration, so they don't need
to play tricks with skipping .throttle() invocations that they are not
interested in and they can avoid carrying out the same computations for
multiple times in one cycle.

Signed-off-by: Rafael J. Wysocki <[email protected]>
---
drivers/thermal/thermal_core.c | 3 +++
drivers/thermal/thermal_core.h | 2 ++
2 files changed, 5 insertions(+)

Index: linux-pm/drivers/thermal/thermal_core.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_core.c
+++ linux-pm/drivers/thermal/thermal_core.c
@@ -516,6 +516,9 @@ void __thermal_zone_device_update(struct
governor->trip_crossed(tz, &td->trip, false);
}

+ if (governor->manage)
+ governor->manage(tz);
+
monitor_thermal_zone(tz);
}

Index: linux-pm/drivers/thermal/thermal_core.h
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_core.h
+++ linux-pm/drivers/thermal/thermal_core.h
@@ -31,6 +31,7 @@ struct thermal_trip_desc {
* @unbind_from_tz: callback called when a governor is unbound from a
* thermal zone.
* @trip_crossed: called for trip points that have just been crossed
+ * @manage: called on thermal zone temperature updates
* @throttle: callback called for every trip point even if temperature is
* below the trip point temperature
* @update_tz: callback called when thermal zone internals have changed, e.g.
@@ -44,6 +45,7 @@ struct thermal_governor {
void (*trip_crossed)(struct thermal_zone_device *tz,
const struct thermal_trip *trip,
bool crossed_up);
+ void (*manage)(struct thermal_zone_device *tz);
int (*throttle)(struct thermal_zone_device *tz,
const struct thermal_trip *trip);
void (*update_tz)(struct thermal_zone_device *tz,





2024-04-19 09:44:11

by Lukasz Luba

[permalink] [raw]
Subject: Re: [PATCH v1 05/16] thermal: core: Introduce .manage() callback for thermal governors



On 4/10/24 17:08, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <[email protected]>
>
> Introduce a new thermal governor callback called .manage() that will be
> invoked once per thermal zone update after processing all of the trip
> points in the core.
>
> This will allow governors that look at multiple trip points together
> to check all of them in a consistent configuration, so they don't need
> to play tricks with skipping .throttle() invocations that they are not
> interested in and they can avoid carrying out the same computations for
> multiple times in one cycle.
>
> Signed-off-by: Rafael J. Wysocki <[email protected]>
> ---
> drivers/thermal/thermal_core.c | 3 +++
> drivers/thermal/thermal_core.h | 2 ++
> 2 files changed, 5 insertions(+)
>
> Index: linux-pm/drivers/thermal/thermal_core.c
> ===================================================================
> --- linux-pm.orig/drivers/thermal/thermal_core.c
> +++ linux-pm/drivers/thermal/thermal_core.c
> @@ -516,6 +516,9 @@ void __thermal_zone_device_update(struct
> governor->trip_crossed(tz, &td->trip, false);
> }
>
> + if (governor->manage)
> + governor->manage(tz);
> +
> monitor_thermal_zone(tz);
> }
>
> Index: linux-pm/drivers/thermal/thermal_core.h
> ===================================================================
> --- linux-pm.orig/drivers/thermal/thermal_core.h
> +++ linux-pm/drivers/thermal/thermal_core.h
> @@ -31,6 +31,7 @@ struct thermal_trip_desc {
> * @unbind_from_tz: callback called when a governor is unbound from a
> * thermal zone.
> * @trip_crossed: called for trip points that have just been crossed
> + * @manage: called on thermal zone temperature updates
> * @throttle: callback called for every trip point even if temperature is
> * below the trip point temperature
> * @update_tz: callback called when thermal zone internals have changed, e.g.
> @@ -44,6 +45,7 @@ struct thermal_governor {
> void (*trip_crossed)(struct thermal_zone_device *tz,
> const struct thermal_trip *trip,
> bool crossed_up);
> + void (*manage)(struct thermal_zone_device *tz);
> int (*throttle)(struct thermal_zone_device *tz,
> const struct thermal_trip *trip);
> void (*update_tz)(struct thermal_zone_device *tz,
>
>
>

LGTM

Reviewed-by: Lukasz Luba <[email protected]>

2024-04-23 17:10:02

by Daniel Lezcano

[permalink] [raw]
Subject: Re: [PATCH v1 05/16] thermal: core: Introduce .manage() callback for thermal governors

On 10/04/2024 18:08, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <[email protected]>
>
> Introduce a new thermal governor callback called .manage() that will be
> invoked once per thermal zone update after processing all of the trip
> points in the core.
>
> This will allow governors that look at multiple trip points together
> to check all of them in a consistent configuration, so they don't need
> to play tricks with skipping .throttle() invocations that they are not
> interested in and they can avoid carrying out the same computations for
> multiple times in one cycle.
>
> Signed-off-by: Rafael J. Wysocki <[email protected]>

Acked-by: Daniel Lezcano <[email protected]>

--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog