Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit d045c46

Browse files
committed
Merge tag 'thermal-6.10-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull thermal control fixes from Rafael Wysocki: "These fix a possible NULL pointer dereference in a thermal governor, fix up the handling of thermal zones enabled before their temperature can be determined and fix list sorting during thermal zone temperature updates. Specifics: - Prevent the Power Allocator thermal governor from dereferencing a NULL pointer if it is bound to a tripless thermal zone (Nícolas Prado) - Prevent thermal zones enabled too early from staying effectively dormant forever because their temperature cannot be determined initially (Rafael Wysocki) - Fix list sorting during thermal zone temperature updates to ensure the proper ordering of trip crossing notifications (Rafael Wysocki)" * tag 'thermal-6.10-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: thermal: core: Fix list sorting in __thermal_zone_device_update() thermal: core: Call monitor_thermal_zone() if zone temperature is invalid thermal: gov_power_allocator: Return early in manage if trip_max is NULL
2 parents 367cbaa + 94eacc1 commit d045c46

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

drivers/thermal/gov_power_allocator.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,9 @@ static void power_allocator_manage(struct thermal_zone_device *tz)
759759
return;
760760
}
761761

762+
if (!params->trip_max)
763+
return;
764+
762765
allocate_power(tz, params->trip_max->temperature);
763766
params->update_cdevs = true;
764767
}

drivers/thermal/thermal_core.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ static void monitor_thermal_zone(struct thermal_zone_device *tz)
300300
thermal_zone_device_set_polling(tz, tz->passive_delay_jiffies);
301301
else if (tz->polling_delay_jiffies)
302302
thermal_zone_device_set_polling(tz, tz->polling_delay_jiffies);
303+
else if (tz->temperature == THERMAL_TEMP_INVALID)
304+
thermal_zone_device_set_polling(tz, msecs_to_jiffies(THERMAL_RECHECK_DELAY_MS));
303305
}
304306

305307
static struct thermal_governor *thermal_get_tz_governor(struct thermal_zone_device *tz)
@@ -482,16 +484,14 @@ static void thermal_trip_crossed(struct thermal_zone_device *tz,
482484
thermal_governor_trip_crossed(governor, tz, trip, crossed_up);
483485
}
484486

485-
static int thermal_trip_notify_cmp(void *ascending, const struct list_head *a,
487+
static int thermal_trip_notify_cmp(void *not_used, const struct list_head *a,
486488
const struct list_head *b)
487489
{
488490
struct thermal_trip_desc *tda = container_of(a, struct thermal_trip_desc,
489491
notify_list_node);
490492
struct thermal_trip_desc *tdb = container_of(b, struct thermal_trip_desc,
491493
notify_list_node);
492-
int ret = tdb->notify_temp - tda->notify_temp;
493-
494-
return ascending ? ret : -ret;
494+
return tda->notify_temp - tdb->notify_temp;
495495
}
496496

497497
void __thermal_zone_device_update(struct thermal_zone_device *tz,
@@ -511,7 +511,7 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
511511
update_temperature(tz);
512512

513513
if (tz->temperature == THERMAL_TEMP_INVALID)
514-
return;
514+
goto monitor;
515515

516516
__thermal_zone_set_trips(tz);
517517

@@ -520,19 +520,20 @@ void __thermal_zone_device_update(struct thermal_zone_device *tz,
520520
for_each_trip_desc(tz, td)
521521
handle_thermal_trip(tz, td, &way_up_list, &way_down_list);
522522

523-
list_sort(&way_up_list, &way_up_list, thermal_trip_notify_cmp);
523+
list_sort(NULL, &way_up_list, thermal_trip_notify_cmp);
524524
list_for_each_entry(td, &way_up_list, notify_list_node)
525525
thermal_trip_crossed(tz, &td->trip, governor, true);
526526

527527
list_sort(NULL, &way_down_list, thermal_trip_notify_cmp);
528-
list_for_each_entry(td, &way_down_list, notify_list_node)
528+
list_for_each_entry_reverse(td, &way_down_list, notify_list_node)
529529
thermal_trip_crossed(tz, &td->trip, governor, false);
530530

531531
if (governor->manage)
532532
governor->manage(tz);
533533

534534
thermal_debug_update_trip_stats(tz);
535535

536+
monitor:
536537
monitor_thermal_zone(tz);
537538
}
538539

drivers/thermal/thermal_core.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ struct thermal_zone_device {
133133
struct thermal_trip_desc trips[] __counted_by(num_trips);
134134
};
135135

136+
/*
137+
* Default delay after a failing thermal zone temperature check before
138+
* attempting to check it again.
139+
*/
140+
#define THERMAL_RECHECK_DELAY_MS 250
141+
136142
/* Default Thermal Governor */
137143
#if defined(CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE)
138144
#define DEFAULT_THERMAL_GOVERNOR "step_wise"

0 commit comments

Comments
 (0)