linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] thermal/core: Clear all mitigation when thermal zone is disabled
@ 2022-01-07 18:56 Manaf Meethalavalappu Pallikunhi
  2022-01-10 17:55 ` Thara Gopinath
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Manaf Meethalavalappu Pallikunhi @ 2022-01-07 18:56 UTC (permalink / raw)
  To: Rafael J . Wysocki, Daniel Lezcano, Amit Kucheria, Zhang Rui,
	Thara Gopinath, Matthias Kaehlcke
  Cc: linux-pm, linux-kernel, Manaf Meethalavalappu Pallikunhi

Whenever a thermal zone is in trip violated state, there is a chance
that the same thermal zone mode can be disabled either via thermal
core API or via thermal zone sysfs. Once it is disabled, the framework
bails out any re-evaluation of thermal zone. It leads to a case where
if it is already in mitigation state, it will stay the same state
until it is re-enabled.

To avoid above mentioned issue, on thermal zone disable request
reset thermal zone and clear mitigation for each trip explicitly.

Signed-off-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com>
---
 drivers/thermal/thermal_core.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 51374f4..e288c82 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -447,10 +447,18 @@ static int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
 
 	thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
 
-	if (mode == THERMAL_DEVICE_ENABLED)
+	if (mode == THERMAL_DEVICE_ENABLED) {
 		thermal_notify_tz_enable(tz->id);
-	else
+	} else {
+		int trip;
+
+		/* make sure all previous throttlings are cleared */
+		thermal_zone_device_init(tz);
+		for (trip = 0; trip < tz->trips; trip++)
+			handle_thermal_trip(tz, trip);
+
 		thermal_notify_tz_disable(tz->id);
+	}
 
 	return ret;
 }


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-01-25 15:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-07 18:56 [PATCH v3] thermal/core: Clear all mitigation when thermal zone is disabled Manaf Meethalavalappu Pallikunhi
2022-01-10 17:55 ` Thara Gopinath
2022-01-10 20:45   ` Manaf Meethalavalappu Pallikunhi
2022-01-19 19:05     ` Manaf Meethalavalappu Pallikunhi
2022-01-19 19:12       ` Daniel Lezcano
2022-01-19 20:03 ` Rafael J. Wysocki
2022-01-23 20:51 ` Daniel Lezcano
2022-01-24  1:05   ` Pandruvada, Srinivas
2022-01-25 15:48     ` Manaf Meethalavalappu Pallikunhi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).