diff mbox series

[v3,3/6] thermal: core: Rewrite comments in handle_thermal_trip()

Message ID 3284691.aeNJFYEL58@kreacher (mailing list archive)
State In Next
Delegated to: Rafael Wysocki
Headers show
Series thermal: More separation between the core and drivers | expand

Commit Message

Rafael J. Wysocki April 2, 2024, 6:59 p.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Make the comments regarding trip crossing and threshold updates in
handle_thermal_trip() slightly more clear.

No functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---

v2 -> v3: New patch

---
 drivers/thermal/thermal_core.c |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

Comments

Lukasz Luba April 4, 2024, 10:14 p.m. UTC | #1
On 4/2/24 19:59, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Make the comments regarding trip crossing and threshold updates in
> handle_thermal_trip() slightly more clear.
> 
> No functional impact.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> 
> v2 -> v3: New patch
> 
> ---
>   drivers/thermal/thermal_core.c |   26 +++++++++++++-------------
>   1 file changed, 13 insertions(+), 13 deletions(-)
> 
> Index: linux-pm/drivers/thermal/thermal_core.c
> ===================================================================
> --- linux-pm.orig/drivers/thermal/thermal_core.c
> +++ linux-pm/drivers/thermal/thermal_core.c
> @@ -368,6 +368,13 @@ static void handle_thermal_trip(struct t
>   	if (trip->temperature == THERMAL_TEMP_INVALID)
>   		return;
>   
> +	/*
> +	 * If the trip temperature or hysteresis has been updated recently,
> +	 * the threshold needs to be computed again using the new values.
> +	 * However, its initial value still reflects the old ones and that
> +	 * is what needs to be compared with the previous zone temperature
> +	 * to decide which action to take.
> +	 */
>   	if (tz->last_temperature == THERMAL_TEMP_INVALID) {
>   		/* Initialization. */
>   		td->threshold = trip->temperature;
> @@ -375,11 +382,9 @@ static void handle_thermal_trip(struct t
>   			td->threshold -= trip->hysteresis;
>   	} else if (tz->last_temperature < td->threshold) {
>   		/*
> -		 * The trip threshold is equal to the trip temperature, unless
> -		 * the latter has changed in the meantime.  In either case,
> -		 * the trip is crossed if the current zone temperature is at
> -		 * least equal to its temperature, but otherwise ensure that
> -		 * the threshold and the trip temperature will be equal.
> +		 * There is no mitigation under way, so it needs to be started
> +		 * if the zone temperature exceeds the trip one.  The new
> +		 * threshold is then set to the low temperature of the trip.
>   		 */
>   		if (tz->temperature >= trip->temperature) {
>   			thermal_notify_tz_trip_up(tz, trip);
> @@ -390,14 +395,9 @@ static void handle_thermal_trip(struct t
>   		}
>   	} else {
>   		/*
> -		 * The previous zone temperature was above or equal to the trip
> -		 * threshold, which would be equal to the "low temperature" of
> -		 * the trip (its temperature minus its hysteresis), unless the
> -		 * trip temperature or hysteresis had changed.  In either case,
> -		 * the trip is crossed if the current zone temperature is below
> -		 * the low temperature of the trip, but otherwise ensure that
> -		 * the trip threshold will be equal to the low temperature of
> -		 * the trip.
> +		 * Mitigation is under way, so it needs to stop if the zone
> +		 * temperature falls below the low temperature of the trip.
> +		 * In that case, the trip temperature becomes the new threshold.
>   		 */
>   		if (tz->temperature < trip->temperature - trip->hysteresis) {
>   			thermal_notify_tz_trip_down(tz, trip);
> 
> 
> 

Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Daniel Lezcano April 5, 2024, 8:30 a.m. UTC | #2
On 02/04/2024 20:59, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Make the comments regarding trip crossing and threshold updates in
> handle_thermal_trip() slightly more clear.
> 
> No functional impact.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
diff mbox series

Patch

Index: linux-pm/drivers/thermal/thermal_core.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_core.c
+++ linux-pm/drivers/thermal/thermal_core.c
@@ -368,6 +368,13 @@  static void handle_thermal_trip(struct t
 	if (trip->temperature == THERMAL_TEMP_INVALID)
 		return;
 
+	/*
+	 * If the trip temperature or hysteresis has been updated recently,
+	 * the threshold needs to be computed again using the new values.
+	 * However, its initial value still reflects the old ones and that
+	 * is what needs to be compared with the previous zone temperature
+	 * to decide which action to take.
+	 */
 	if (tz->last_temperature == THERMAL_TEMP_INVALID) {
 		/* Initialization. */
 		td->threshold = trip->temperature;
@@ -375,11 +382,9 @@  static void handle_thermal_trip(struct t
 			td->threshold -= trip->hysteresis;
 	} else if (tz->last_temperature < td->threshold) {
 		/*
-		 * The trip threshold is equal to the trip temperature, unless
-		 * the latter has changed in the meantime.  In either case,
-		 * the trip is crossed if the current zone temperature is at
-		 * least equal to its temperature, but otherwise ensure that
-		 * the threshold and the trip temperature will be equal.
+		 * There is no mitigation under way, so it needs to be started
+		 * if the zone temperature exceeds the trip one.  The new
+		 * threshold is then set to the low temperature of the trip.
 		 */
 		if (tz->temperature >= trip->temperature) {
 			thermal_notify_tz_trip_up(tz, trip);
@@ -390,14 +395,9 @@  static void handle_thermal_trip(struct t
 		}
 	} else {
 		/*
-		 * The previous zone temperature was above or equal to the trip
-		 * threshold, which would be equal to the "low temperature" of
-		 * the trip (its temperature minus its hysteresis), unless the
-		 * trip temperature or hysteresis had changed.  In either case,
-		 * the trip is crossed if the current zone temperature is below
-		 * the low temperature of the trip, but otherwise ensure that
-		 * the trip threshold will be equal to the low temperature of
-		 * the trip.
+		 * Mitigation is under way, so it needs to stop if the zone
+		 * temperature falls below the low temperature of the trip.
+		 * In that case, the trip temperature becomes the new threshold.
 		 */
 		if (tz->temperature < trip->temperature - trip->hysteresis) {
 			thermal_notify_tz_trip_down(tz, trip);