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

Configure Feed

Select the types of activity you want to include in your feed.

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()

+50 -25
+25 -10
drivers/thermal/thermal_core.c
··· 467 467 governor->trip_crossed(tz, trip, crossed_up); 468 468 } 469 469 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 + 470 485 static int thermal_trip_notify_cmp(void *ascending, const struct list_head *a, 471 486 const struct list_head *b) 472 487 { ··· 521 506 handle_thermal_trip(tz, td, &way_up_list, &way_down_list); 522 507 523 508 list_sort(&way_up_list, &way_up_list, thermal_trip_notify_cmp); 524 - list_for_each_entry(td, &way_up_list, notify_list_node) { 525 - thermal_notify_tz_trip_up(tz, &td->trip); 526 - thermal_debug_tz_trip_up(tz, &td->trip); 527 - thermal_governor_trip_crossed(governor, tz, &td->trip, true); 528 - } 509 + list_for_each_entry(td, &way_up_list, notify_list_node) 510 + thermal_trip_crossed(tz, &td->trip, governor, true); 529 511 530 512 list_sort(NULL, &way_down_list, thermal_trip_notify_cmp); 531 - list_for_each_entry(td, &way_down_list, notify_list_node) { 532 - thermal_notify_tz_trip_down(tz, &td->trip); 533 - thermal_debug_tz_trip_down(tz, &td->trip); 534 - thermal_governor_trip_crossed(governor, tz, &td->trip, false); 535 - } 513 + list_for_each_entry(td, &way_down_list, notify_list_node) 514 + thermal_trip_crossed(tz, &td->trip, governor, false); 536 515 537 516 if (governor->manage) 538 517 governor->manage(tz); ··· 601 592 mutex_unlock(&tz->lock); 602 593 } 603 594 EXPORT_SYMBOL_GPL(thermal_zone_device_update); 595 + 596 + void thermal_zone_trip_down(struct thermal_zone_device *tz, 597 + const struct thermal_trip *trip) 598 + { 599 + thermal_trip_crossed(tz, trip, thermal_get_tz_governor(tz), false); 600 + } 604 601 605 602 int for_each_thermal_governor(int (*cb)(struct thermal_governor *, void *), 606 603 void *data)
+2
drivers/thermal/thermal_core.h
··· 246 246 void thermal_zone_trip_updated(struct thermal_zone_device *tz, 247 247 const struct thermal_trip *trip); 248 248 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); 249 251 250 252 /* sysfs I/F */ 251 253 int thermal_zone_create_device_groups(struct thermal_zone_device *tz);
+11 -7
drivers/thermal/thermal_debugfs.c
··· 91 91 * 92 92 * @timestamp: the trip crossing timestamp 93 93 * @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 94 96 * @count: the number of times the zone temperature was above the trip point 95 97 * @max: maximum recorded temperature above the trip point 96 98 * @min: minimum recorded temperature above the trip point ··· 101 99 struct trip_stats { 102 100 ktime_t timestamp; 103 101 ktime_t duration; 102 + int trip_temp; 103 + int trip_hyst; 104 104 int count; 105 105 int max; 106 106 int min; ··· 578 574 struct thermal_debugfs *thermal_dbg = tz->debugfs; 579 575 int trip_id = thermal_zone_trip_id(tz, trip); 580 576 ktime_t now = ktime_get(); 577 + struct trip_stats *trip_stats; 581 578 582 579 if (!thermal_dbg) 583 580 return; ··· 644 639 tz_dbg->trips_crossed[tz_dbg->nr_trips++] = trip_id; 645 640 646 641 tze = list_first_entry(&tz_dbg->tz_episodes, struct tz_episode, node); 647 - tze->trip_stats[trip_id].timestamp = now; 642 + trip_stats = &tze->trip_stats[trip_id]; 643 + trip_stats->trip_temp = trip->temperature; 644 + trip_stats->trip_hyst = trip->hysteresis; 645 + trip_stats->timestamp = now; 648 646 649 647 unlock: 650 648 mutex_unlock(&thermal_dbg->lock); ··· 802 794 const struct thermal_trip *trip = &td->trip; 803 795 struct trip_stats *trip_stats; 804 796 805 - /* Skip invalid trips. */ 806 - if (trip->temperature == THERMAL_TEMP_INVALID) 807 - continue; 808 - 809 797 /* 810 798 * There is no possible mitigation happening at the 811 799 * critical trip point, so the stats will be always ··· 840 836 seq_printf(s, "| %*d | %*s | %*d | %*d | %c%*lld | %*d | %*d | %*d |\n", 841 837 4 , trip_id, 842 838 8, type, 843 - 9, trip->temperature, 844 - 9, trip->hysteresis, 839 + 9, trip_stats->trip_temp, 840 + 9, trip_stats->trip_hyst, 845 841 c, 10, duration_ms, 846 842 9, trip_stats->avg, 847 843 9, trip_stats->min,
+12 -8
drivers/thermal/thermal_trip.c
··· 152 152 if (trip->temperature == temp) 153 153 return; 154 154 155 + trip->temperature = temp; 156 + thermal_notify_tz_trip_change(tz, trip); 157 + 155 158 if (temp == THERMAL_TEMP_INVALID) { 156 159 struct thermal_trip_desc *td = trip_to_trip_desc(trip); 157 160 158 - if (trip->type == THERMAL_TRIP_PASSIVE && 159 - tz->temperature >= td->threshold) { 161 + if (tz->temperature >= td->threshold) { 160 162 /* 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. 163 166 */ 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); 166 172 } 167 173 /* 168 174 * Invalidate the threshold to avoid triggering a spurious ··· 176 170 */ 177 171 td->threshold = INT_MAX; 178 172 } 179 - trip->temperature = temp; 180 - thermal_notify_tz_trip_change(tz, trip); 181 173 } 182 174 EXPORT_SYMBOL_GPL(thermal_zone_set_trip_temp);