Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <rafael.j.wysocki@intel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>

+39
+1
drivers/thermal/thermal_core.c
··· 1648 1648 1649 1649 tz->suspended = false; 1650 1650 1651 + thermal_debug_tz_resume(tz); 1651 1652 thermal_zone_device_init(tz); 1652 1653 __thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED); 1653 1654
+36
drivers/thermal/thermal_debugfs.c
··· 926 926 thermal_debugfs_remove_id(thermal_dbg); 927 927 kfree(trips_crossed); 928 928 } 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 + }
+2
drivers/thermal/thermal_debugfs.h
··· 7 7 void thermal_debug_cdev_state_update(const struct thermal_cooling_device *cdev, int state); 8 8 void thermal_debug_tz_add(struct thermal_zone_device *tz); 9 9 void thermal_debug_tz_remove(struct thermal_zone_device *tz); 10 + void thermal_debug_tz_resume(struct thermal_zone_device *tz); 10 11 void thermal_debug_tz_trip_up(struct thermal_zone_device *tz, 11 12 const struct thermal_trip *trip); 12 13 void thermal_debug_tz_trip_down(struct thermal_zone_device *tz, ··· 21 20 int state) {} 22 21 static inline void thermal_debug_tz_add(struct thermal_zone_device *tz) {} 23 22 static inline void thermal_debug_tz_remove(struct thermal_zone_device *tz) {} 23 + static inline void thermal_debug_tz_resume(struct thermal_zone_device *tz) {} 24 24 static inline void thermal_debug_tz_trip_up(struct thermal_zone_device *tz, 25 25 const struct thermal_trip *trip) {}; 26 26 static inline void thermal_debug_tz_trip_down(struct thermal_zone_device *tz,