Skip to content

Commit 2df0193

Browse files
committed
Merge tag 'thermal-6.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull thermal control fixes from Rafael Wysocki: "Fix issues related to the handling of invalid trip points in the thermal core and in the thermal debug code that have been overlooked by some recent thermal control core changes" * tag 'thermal-6.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: thermal: trip: Trigger trip down notifications when trips involved in mitigation become invalid thermal: core: Introduce thermal_trip_crossed() thermal/debugfs: Allow tze_seq_show() to print statistics for invalid trips thermal/debugfs: Print initial trip temperature and hysteresis in tze_seq_show()
2 parents 5533525 + ae2170d commit 2df0193

File tree

4 files changed

+50
-25
lines changed

4 files changed

+50
-25
lines changed

drivers/thermal/thermal_core.c

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,21 @@ static void thermal_governor_trip_crossed(struct thermal_governor *governor,
467467
governor->trip_crossed(tz, trip, crossed_up);
468468
}
469469

470+
static void thermal_trip_crossed(struct thermal_zone_device *tz,
471+
const struct thermal_trip *trip,
472+
struct thermal_governor *governor,
473+
bool crossed_up)
474+
{
475+
if (crossed_up) {
476+
thermal_notify_tz_trip_up(tz, trip);
477+
thermal_debug_tz_trip_up(tz, trip);
478+
} else {
479+
thermal_notify_tz_trip_down(tz, trip);
480+
thermal_debug_tz_trip_down(tz, trip);
481+
}
482+
thermal_governor_trip_crossed(governor, tz, trip, crossed_up);
483+
}
484+
470485
static int thermal_trip_notify_cmp(void *ascending, const struct list_head *a,
471486
const struct list_head *b)
472487
{
@@ -506,18 +521,12 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
506521
handle_thermal_trip(tz, td, &way_up_list, &way_down_list);
507522

508523
list_sort(&way_up_list, &way_up_list, thermal_trip_notify_cmp);
509-
list_for_each_entry(td, &way_up_list, notify_list_node) {
510-
thermal_notify_tz_trip_up(tz, &td->trip);
511-
thermal_debug_tz_trip_up(tz, &td->trip);
512-
thermal_governor_trip_crossed(governor, tz, &td->trip, true);
513-
}
524+
list_for_each_entry(td, &way_up_list, notify_list_node)
525+
thermal_trip_crossed(tz, &td->trip, governor, true);
514526

515527
list_sort(NULL, &way_down_list, thermal_trip_notify_cmp);
516-
list_for_each_entry(td, &way_down_list, notify_list_node) {
517-
thermal_notify_tz_trip_down(tz, &td->trip);
518-
thermal_debug_tz_trip_down(tz, &td->trip);
519-
thermal_governor_trip_crossed(governor, tz, &td->trip, false);
520-
}
528+
list_for_each_entry(td, &way_down_list, notify_list_node)
529+
thermal_trip_crossed(tz, &td->trip, governor, false);
521530

522531
if (governor->manage)
523532
governor->manage(tz);
@@ -593,6 +602,12 @@ void thermal_zone_device_update(struct thermal_zone_device *tz,
593602
}
594603
EXPORT_SYMBOL_GPL(thermal_zone_device_update);
595604

605+
void thermal_zone_trip_down(struct thermal_zone_device *tz,
606+
const struct thermal_trip *trip)
607+
{
608+
thermal_trip_crossed(tz, trip, thermal_get_tz_governor(tz), false);
609+
}
610+
596611
int for_each_thermal_governor(int (*cb)(struct thermal_governor *, void *),
597612
void *data)
598613
{

drivers/thermal/thermal_core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ int thermal_zone_trip_id(const struct thermal_zone_device *tz,
246246
void thermal_zone_trip_updated(struct thermal_zone_device *tz,
247247
const struct thermal_trip *trip);
248248
int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp);
249+
void thermal_zone_trip_down(struct thermal_zone_device *tz,
250+
const struct thermal_trip *trip);
249251

250252
/* sysfs I/F */
251253
int thermal_zone_create_device_groups(struct thermal_zone_device *tz);

drivers/thermal/thermal_debugfs.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ struct cdev_record {
9191
*
9292
* @timestamp: the trip crossing timestamp
9393
* @duration: total time when the zone temperature was above the trip point
94+
* @trip_temp: trip temperature at mitigation start
95+
* @trip_hyst: trip hysteresis at mitigation start
9496
* @count: the number of times the zone temperature was above the trip point
9597
* @max: maximum recorded temperature above the trip point
9698
* @min: minimum recorded temperature above the trip point
@@ -99,6 +101,8 @@ struct cdev_record {
99101
struct trip_stats {
100102
ktime_t timestamp;
101103
ktime_t duration;
104+
int trip_temp;
105+
int trip_hyst;
102106
int count;
103107
int max;
104108
int min;
@@ -574,6 +578,7 @@ void thermal_debug_tz_trip_up(struct thermal_zone_device *tz,
574578
struct thermal_debugfs *thermal_dbg = tz->debugfs;
575579
int trip_id = thermal_zone_trip_id(tz, trip);
576580
ktime_t now = ktime_get();
581+
struct trip_stats *trip_stats;
577582

578583
if (!thermal_dbg)
579584
return;
@@ -639,7 +644,10 @@ void thermal_debug_tz_trip_up(struct thermal_zone_device *tz,
639644
tz_dbg->trips_crossed[tz_dbg->nr_trips++] = trip_id;
640645

641646
tze = list_first_entry(&tz_dbg->tz_episodes, struct tz_episode, node);
642-
tze->trip_stats[trip_id].timestamp = now;
647+
trip_stats = &tze->trip_stats[trip_id];
648+
trip_stats->trip_temp = trip->temperature;
649+
trip_stats->trip_hyst = trip->hysteresis;
650+
trip_stats->timestamp = now;
643651

644652
unlock:
645653
mutex_unlock(&thermal_dbg->lock);
@@ -794,10 +802,6 @@ static int tze_seq_show(struct seq_file *s, void *v)
794802
const struct thermal_trip *trip = &td->trip;
795803
struct trip_stats *trip_stats;
796804

797-
/* Skip invalid trips. */
798-
if (trip->temperature == THERMAL_TEMP_INVALID)
799-
continue;
800-
801805
/*
802806
* There is no possible mitigation happening at the
803807
* critical trip point, so the stats will be always
@@ -836,8 +840,8 @@ static int tze_seq_show(struct seq_file *s, void *v)
836840
seq_printf(s, "| %*d | %*s | %*d | %*d | %c%*lld | %*d | %*d | %*d |\n",
837841
4 , trip_id,
838842
8, type,
839-
9, trip->temperature,
840-
9, trip->hysteresis,
843+
9, trip_stats->trip_temp,
844+
9, trip_stats->trip_hyst,
841845
c, 10, duration_ms,
842846
9, trip_stats->avg,
843847
9, trip_stats->min,

drivers/thermal/thermal_trip.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,25 +152,29 @@ void thermal_zone_set_trip_temp(struct thermal_zone_device *tz,
152152
if (trip->temperature == temp)
153153
return;
154154

155+
trip->temperature = temp;
156+
thermal_notify_tz_trip_change(tz, trip);
157+
155158
if (temp == THERMAL_TEMP_INVALID) {
156159
struct thermal_trip_desc *td = trip_to_trip_desc(trip);
157160

158-
if (trip->type == THERMAL_TRIP_PASSIVE &&
159-
tz->temperature >= td->threshold) {
161+
if (tz->temperature >= td->threshold) {
160162
/*
161-
* The trip has been crossed, so the thermal zone's
162-
* passive count needs to be adjusted.
163+
* The trip has been crossed on the way up, so some
164+
* adjustments are needed to compensate for the lack
165+
* of it going forward.
163166
*/
164-
tz->passive--;
165-
WARN_ON_ONCE(tz->passive < 0);
167+
if (trip->type == THERMAL_TRIP_PASSIVE) {
168+
tz->passive--;
169+
WARN_ON_ONCE(tz->passive < 0);
170+
}
171+
thermal_zone_trip_down(tz, trip);
166172
}
167173
/*
168174
* Invalidate the threshold to avoid triggering a spurious
169175
* trip crossing notification when the trip becomes valid.
170176
*/
171177
td->threshold = INT_MAX;
172178
}
173-
trip->temperature = temp;
174-
thermal_notify_tz_trip_change(tz, trip);
175179
}
176180
EXPORT_SYMBOL_GPL(thermal_zone_set_trip_temp);

0 commit comments

Comments
 (0)