Skip to content

Commit 9b73b50

Browse files
committed
thermal/debugfs: Do not extend mitigation episodes beyond system resume
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 <[email protected]> Acked-by: Daniel Lezcano <[email protected]>
1 parent 8b95bed commit 9b73b50

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

drivers/thermal/thermal_core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,7 @@ static void thermal_zone_device_resume(struct work_struct *work)
16481648

16491649
tz->suspended = false;
16501650

1651+
thermal_debug_tz_resume(tz);
16511652
thermal_zone_device_init(tz);
16521653
__thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
16531654

drivers/thermal/thermal_debugfs.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,3 +926,39 @@ void thermal_debug_tz_remove(struct thermal_zone_device *tz)
926926
thermal_debugfs_remove_id(thermal_dbg);
927927
kfree(trips_crossed);
928928
}
929+
930+
void thermal_debug_tz_resume(struct thermal_zone_device *tz)
931+
{
932+
struct thermal_debugfs *thermal_dbg = tz->debugfs;
933+
ktime_t now = ktime_get();
934+
struct tz_debugfs *tz_dbg;
935+
struct tz_episode *tze;
936+
int i;
937+
938+
if (!thermal_dbg)
939+
return;
940+
941+
mutex_lock(&thermal_dbg->lock);
942+
943+
tz_dbg = &thermal_dbg->tz_dbg;
944+
945+
if (!tz_dbg->nr_trips)
946+
goto out;
947+
948+
/*
949+
* A mitigation episode was in progress before the preceding system
950+
* suspend transition, so close it because the zone handling is starting
951+
* over from scratch.
952+
*/
953+
tze = list_first_entry(&tz_dbg->tz_episodes, struct tz_episode, node);
954+
955+
for (i = 0; i < tz_dbg->nr_trips; i++)
956+
tz_episode_close_trip(tze, tz_dbg->trips_crossed[i], now);
957+
958+
tze->duration = ktime_sub(now, tze->timestamp);
959+
960+
tz_dbg->nr_trips = 0;
961+
962+
out:
963+
mutex_unlock(&thermal_dbg->lock);
964+
}

drivers/thermal/thermal_debugfs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ void thermal_debug_cdev_remove(struct thermal_cooling_device *cdev);
77
void thermal_debug_cdev_state_update(const struct thermal_cooling_device *cdev, int state);
88
void thermal_debug_tz_add(struct thermal_zone_device *tz);
99
void thermal_debug_tz_remove(struct thermal_zone_device *tz);
10+
void thermal_debug_tz_resume(struct thermal_zone_device *tz);
1011
void thermal_debug_tz_trip_up(struct thermal_zone_device *tz,
1112
const struct thermal_trip *trip);
1213
void thermal_debug_tz_trip_down(struct thermal_zone_device *tz,
@@ -20,6 +21,7 @@ static inline void thermal_debug_cdev_state_update(const struct thermal_cooling_
2021
int state) {}
2122
static inline void thermal_debug_tz_add(struct thermal_zone_device *tz) {}
2223
static inline void thermal_debug_tz_remove(struct thermal_zone_device *tz) {}
24+
static inline void thermal_debug_tz_resume(struct thermal_zone_device *tz) {}
2325
static inline void thermal_debug_tz_trip_up(struct thermal_zone_device *tz,
2426
const struct thermal_trip *trip) {};
2527
static inline void thermal_debug_tz_trip_down(struct thermal_zone_device *tz,

0 commit comments

Comments
 (0)