From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Lukasz Luba <lukasz.luba@arm.com>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Zhang Rui <rui.zhang@intel.com>
Subject: [PATCH v2 2/5] thermal: trip: Make thermal_zone_set_trips() use trip thresholds
Date: Tue, 28 May 2024 18:51:11 +0200 [thread overview]
Message-ID: <2340783.ElGaqSPkdT@kreacher> (raw)
In-Reply-To: <12458899.O9o76ZdvQC@kreacher>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Modify thermal_zone_set_trips() to use trip thresholds instead of
computing the low temperature for each trip to avoid deriving both
the high and low temperature levels from the same trip (which may
happen if the zone temperature falls into the hysteresis range of
one trip).
Accordingly, make __thermal_zone_device_update() call
thermal_zone_set_trips() later, when threshold values have been
updated for all trips.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
v1 -> v2: Rebase.
---
drivers/thermal/thermal_core.c | 4 ++--
drivers/thermal/thermal_trip.c | 14 ++++----------
2 files changed, 6 insertions(+), 12 deletions(-)
Index: linux-pm/drivers/thermal/thermal_core.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_core.c
+++ linux-pm/drivers/thermal/thermal_core.c
@@ -513,13 +513,13 @@ void __thermal_zone_device_update(struct
if (tz->temperature == THERMAL_TEMP_INVALID)
return;
- thermal_zone_set_trips(tz);
-
tz->notify_event = event;
for_each_trip_desc(tz, td)
handle_thermal_trip(tz, td, &way_up_list, &way_down_list);
+ thermal_zone_set_trips(tz);
+
list_sort(&way_up_list, &way_up_list, thermal_trip_notify_cmp);
list_for_each_entry(td, &way_up_list, notify_list_node)
thermal_trip_crossed(tz, &td->trip, governor, true);
Index: linux-pm/drivers/thermal/thermal_trip.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_trip.c
+++ linux-pm/drivers/thermal/thermal_trip.c
@@ -88,17 +88,11 @@ void thermal_zone_set_trips(struct therm
return;
for_each_trip_desc(tz, td) {
- const struct thermal_trip *trip = &td->trip;
- int trip_low;
+ if (td->threshold < tz->temperature && td->threshold > low)
+ low = td->threshold;
- trip_low = trip->temperature - trip->hysteresis;
-
- if (trip_low < tz->temperature && trip_low > low)
- low = trip_low;
-
- if (trip->temperature > tz->temperature &&
- trip->temperature < high)
- high = trip->temperature;
+ if (td->threshold > tz->temperature && td->threshold < high)
+ high = td->threshold;
}
/* No need to change trip points */
next prev parent reply other threads:[~2024-05-28 16:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-28 16:47 [PATCH v2 0/5] thermal: core: Assorted improvements for v6.11 Rafael J. Wysocki
2024-05-28 16:50 ` [PATCH v2 1/5] thermal: trip: Rename __thermal_zone_set_trips() to thermal_zone_set_trips() Rafael J. Wysocki
2024-06-10 13:54 ` Daniel Lezcano
2024-05-28 16:51 ` Rafael J. Wysocki [this message]
2024-06-10 18:01 ` [PATCH v2 2/5] thermal: trip: Make thermal_zone_set_trips() use trip thresholds Daniel Lezcano
2024-06-11 18:43 ` Rafael J. Wysocki
2024-05-28 16:52 ` [PATCH v2 3/5] thermal: trip: Use READ_ONCE() for lockless access to trip properties Rafael J. Wysocki
2024-05-28 16:54 ` [PATCH v2 4/5] thermal: gov_bang_bang: Drop unnecessary cooling device target state checks Rafael J. Wysocki
2024-05-28 16:54 ` [PATCH v2 5/5] thermal: core: Avoid calling .trip_crossed() for critical and hot trips Rafael J. Wysocki
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=2340783.ElGaqSPkdT@kreacher \
--to=rjw@rjwysocki.net \
--cc=daniel.lezcano@linaro.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 \
--cc=srinivas.pandruvada@linux.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