From: Gaurav Kohli <gaurav.kohli@oss.qualcomm.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@kernel.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Gaurav Kohli <gaurav.kohli@oss.qualcomm.com>
Subject: [PATCH] thermal: core: warn on non-critical trips at or above critical temp
Date: Fri, 10 Jul 2026 14:41:31 +0530 [thread overview]
Message-ID: <20260710-critical_trip-v1-1-780d0b40bb96@oss.qualcomm.com> (raw)
Thermal zones can be registered or updated with non-critical trips at or
above the critical trip temperature. Such trips cannot provide useful
mitigation before critical trip handling runs, and a HOT trip at that
temperature can coincide with shutdown.
Warn at registration time and on trip temperature changes to surface
misconfigured platform data and incorrect dynamic updates early. When
multiple critical trips exist, warn against the lowest one.
Signed-off-by: Gaurav Kohli <gaurav.kohli@oss.qualcomm.com>
---
drivers/thermal/thermal_core.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 28a20d4b475c..0e37e3787565 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -434,6 +434,38 @@ static void thermal_trip_crossed(struct thermal_zone_device *tz,
thermal_governor_trip_crossed(governor, tz, trip, upward);
}
+static void thermal_zone_check_trip_ordering(struct thermal_zone_device *tz)
+{
+ const struct thermal_trip_desc *td;
+ int crit_temp = INT_MAX;
+
+ for_each_trip_desc(tz, td) {
+ const struct thermal_trip *trip = &td->trip;
+
+ if (trip->type == THERMAL_TRIP_CRITICAL &&
+ trip->temperature != THERMAL_TEMP_INVALID &&
+ trip->temperature < crit_temp)
+ crit_temp = trip->temperature;
+ }
+
+ if (crit_temp == INT_MAX)
+ return;
+
+ for_each_trip_desc(tz, td) {
+ const struct thermal_trip *trip = &td->trip;
+
+ if (trip->type == THERMAL_TRIP_CRITICAL ||
+ trip->temperature == THERMAL_TEMP_INVALID)
+ continue;
+
+ if (trip->temperature >= crit_temp)
+ dev_warn(&tz->device,
+ "%s trip temperature %d is not below critical trip temperature %d\n",
+ thermal_trip_type_name(trip->type),
+ trip->temperature, crit_temp);
+ }
+}
+
void thermal_zone_set_trip_hyst(struct thermal_zone_device *tz,
struct thermal_trip *trip, int hyst)
{
@@ -462,6 +494,7 @@ void thermal_zone_set_trip_temp(struct thermal_zone_device *tz,
WRITE_ONCE(trip->temperature, temp);
thermal_notify_tz_trip_change(tz, trip);
+ thermal_zone_check_trip_ordering(tz);
if (old_temp == THERMAL_TEMP_INVALID) {
/*
@@ -1509,6 +1542,8 @@ thermal_zone_device_register_with_trips(const char *type,
if (result)
goto remove_id;
+ thermal_zone_check_trip_ordering(tz);
+
thermal_zone_device_init(tz);
result = thermal_zone_init_governor(tz);
---
base-commit: 4f441960e691d37c880d2cc004de06bb5b6bd5e4
change-id: 20260710-critical_trip-7b015d270e36
Best regards,
--
Gaurav Kohli <gaurav.kohli@oss.qualcomm.com>
next reply other threads:[~2026-07-10 9:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 9:11 Gaurav Kohli [this message]
2026-07-22 19:43 ` Rafael J. Wysocki (Intel)
2026-07-27 22:12 ` Daniel Lezcano
2026-08-24 16:31 ` Rafael J. Wysocki (Intel)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260710-critical_trip-v1-1-780d0b40bb96@oss.qualcomm.com \
--to=gaurav.kohli@oss.qualcomm.com \
--cc=daniel.lezcano@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®