[PATCH v1 2/2] thermal: core: Add sanity check for polling_delay and passive_delay

From: Rafael J. Wysocki
Date: Fri Jul 05 2024 - 15:34:14 EST


From: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>

If polling_delay is nonzero and passive_delay is 0, the thermal zone
will use polling except when tz->passive is nonzero, which does not make
sense.

Also if polling_delay is nonzero and passive_delay is greater than
polling_delay, the thermal zone temperature will be updated less often
when tz->passive is nonzero. This does not make sense either.

Ensure that none of the above will happen.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
---
drivers/thermal/thermal_core.c | 3 +++
1 file changed, 3 insertions(+)

Index: linux-pm/drivers/thermal/thermal_core.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_core.c
+++ linux-pm/drivers/thermal/thermal_core.c
@@ -1440,6 +1440,9 @@ thermal_zone_device_register_with_trips(
td->threshold = INT_MAX;
}

+ if (polling_delay > 0 && passive_delay > polling_delay)
+ passive_delay = polling_delay;
+
thermal_set_delay_jiffies(&tz->passive_delay_jiffies, passive_delay);
thermal_set_delay_jiffies(&tz->polling_delay_jiffies, polling_delay);