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>
Subject: [PATCH v2 2/8] thermal/debugfs: Do not extend mitigation episodes beyond system resume
Date: Tue, 28 May 2024 16:53:47 +0200 [thread overview]
Message-ID: <2337425.ElGaqSPkdT@kreacher> (raw)
In-Reply-To: <5794974.DvuYhMxLoT@kreacher>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Because thermal zone handling by the thermal core is started from
scratch during resume from system-wide suspend, prevent the debug
code from extending mitigation episodes beyond that point by ending
the mitigation episode currently in progress, if any, for each thermal
zone.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
v1 -> v2: Rebase.
---
drivers/thermal/thermal_core.c | 1 +
drivers/thermal/thermal_debugfs.c | 36 ++++++++++++++++++++++++++++++++++++
drivers/thermal/thermal_debugfs.h | 2 ++
3 files changed, 39 insertions(+)
Index: linux-pm/drivers/thermal/thermal_core.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_core.c
+++ linux-pm/drivers/thermal/thermal_core.c
@@ -1641,6 +1641,7 @@ static void thermal_zone_device_resume(s
tz->suspended = false;
+ thermal_debug_tz_resume(tz);
thermal_zone_device_init(tz);
__thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
Index: linux-pm/drivers/thermal/thermal_debugfs.c
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_debugfs.c
+++ linux-pm/drivers/thermal/thermal_debugfs.c
@@ -926,3 +926,39 @@ void thermal_debug_tz_remove(struct ther
thermal_debugfs_remove_id(thermal_dbg);
kfree(trips_crossed);
}
+
+void thermal_debug_tz_resume(struct thermal_zone_device *tz)
+{
+ struct thermal_debugfs *thermal_dbg = tz->debugfs;
+ ktime_t now = ktime_get();
+ struct tz_debugfs *tz_dbg;
+ struct tz_episode *tze;
+ int i;
+
+ if (!thermal_dbg)
+ return;
+
+ mutex_lock(&thermal_dbg->lock);
+
+ tz_dbg = &thermal_dbg->tz_dbg;
+
+ if (!tz_dbg->nr_trips)
+ goto out;
+
+ /*
+ * A mitigation episode was in progress before the preceding system
+ * suspend transition, so close it because the zone handling is starting
+ * over from scratch.
+ */
+ tze = list_first_entry(&tz_dbg->tz_episodes, struct tz_episode, node);
+
+ for (i = 0; i < tz_dbg->nr_trips; i++)
+ tz_episode_close_trip(tze, tz_dbg->trips_crossed[i], now);
+
+ tze->duration = ktime_sub(now, tze->timestamp);
+
+ tz_dbg->nr_trips = 0;
+
+out:
+ mutex_unlock(&thermal_dbg->lock);
+}
Index: linux-pm/drivers/thermal/thermal_debugfs.h
===================================================================
--- linux-pm.orig/drivers/thermal/thermal_debugfs.h
+++ linux-pm/drivers/thermal/thermal_debugfs.h
@@ -7,6 +7,7 @@ void thermal_debug_cdev_remove(struct th
void thermal_debug_cdev_state_update(const struct thermal_cooling_device *cdev, int state);
void thermal_debug_tz_add(struct thermal_zone_device *tz);
void thermal_debug_tz_remove(struct thermal_zone_device *tz);
+void thermal_debug_tz_resume(struct thermal_zone_device *tz);
void thermal_debug_tz_trip_up(struct thermal_zone_device *tz,
const struct thermal_trip *trip);
void thermal_debug_tz_trip_down(struct thermal_zone_device *tz,
@@ -20,6 +21,7 @@ static inline void thermal_debug_cdev_st
int state) {}
static inline void thermal_debug_tz_add(struct thermal_zone_device *tz) {}
static inline void thermal_debug_tz_remove(struct thermal_zone_device *tz) {}
+static inline void thermal_debug_tz_resume(struct thermal_zone_device *tz) {}
static inline void thermal_debug_tz_trip_up(struct thermal_zone_device *tz,
const struct thermal_trip *trip) {};
static inline void thermal_debug_tz_trip_down(struct thermal_zone_device *tz,
next prev parent reply other threads:[~2024-05-28 15:01 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-28 14:51 [PATCH v2 0/8] thermal/debugfs: Assorted improvements for the 6.11 cycle Rafael J. Wysocki
2024-05-28 14:52 ` [PATCH v2 1/8] thermal/debugfs: Use helper to update trip point overstepping duration Rafael J. Wysocki
2024-06-10 7:52 ` Daniel Lezcano
2024-05-28 14:53 ` Rafael J. Wysocki [this message]
2024-06-10 8:28 ` [PATCH v2 2/8] thermal/debugfs: Do not extend mitigation episodes beyond system resume Daniel Lezcano
2024-06-10 11:29 ` Rafael J. Wysocki
2024-06-10 13:39 ` Daniel Lezcano
2024-06-11 18:35 ` Rafael J. Wysocki
2024-05-28 14:55 ` [PATCH v2 3/8] thermal/debugfs: Print mitigation timestamp value in milliseconds Rafael J. Wysocki
2024-06-10 8:29 ` Daniel Lezcano
2024-05-28 14:55 ` [PATCH v2 4/8] thermal/debugfs: Fix up units in "mitigations" files Rafael J. Wysocki
2024-06-10 8:30 ` Daniel Lezcano
2024-05-28 14:57 ` [PATCH v2 5/8] thermal/debugfs: Adjust check for trips without statistics in tze_seq_show() Rafael J. Wysocki
2024-06-10 8:59 ` Daniel Lezcano
2024-05-28 14:58 ` [PATCH v2 6/8] thermal/debugfs: Compute maximum temperature for mitigation episode as a whole Rafael J. Wysocki
2024-06-10 10:33 ` Daniel Lezcano
2024-05-28 14:59 ` [PATCH v2 7/8] thermal/debugfs: Move some statements from under thermal_dbg->lock Rafael J. Wysocki
2024-06-10 13:27 ` Daniel Lezcano
2024-05-28 15:00 ` [PATCH v2 8/8] thermal: trip: Use common set of trip type names Rafael J. Wysocki
2024-06-10 13:28 ` Daniel Lezcano
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=2337425.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 \
/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;
as well as URLs for NNTP newsgroup(s).