thermal: core: Sort trip point crossing notifications by temperature
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 2 Apr 2024 19:03:36 +0000 (21:03 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 8 Apr 2024 14:01:20 +0000 (16:01 +0200)
commit7454f2c42cce10a74312343b66aa2c3dee05d868
tree62ec6004a979f1a3487e8f5b1da10547d7b8b558
parent9ad18043fb35feb1d82c1e594575346f16d47dc7
thermal: core: Sort trip point crossing notifications by temperature

If multiple trip points are crossed in one go and the trips table in
the thermal zone device object is not sorted, the corresponding trip
point crossing notifications sent to user space will not be ordered
either.

Moreover, if the trips table is sorted by trip temperature in ascending
order, the trip crossing notifications on the way up will be sent in that
order too, but the trip crossing notifications on the way down will be
sent in the reverse order.

This is generally confusing and it is better to make the kernel send the
notifications in the order of growing (on the way up) or falling (on the
way down) trip temperature.

To achieve that, instead of sending a trip crossing notification and
recording a trip crossing event in the statistics right away from
handle_thermal_trip(), put the trip in question on a list that will be
sorted by __thermal_zone_device_update() after processing all of the trips
and before sending the notifications and recording trip crossing events.

Link: https://lore.kernel.org/linux-pm/20240306085428.88011-1-daniel.lezcano@linaro.org/
Reported-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
drivers/thermal/thermal_core.c
drivers/thermal/thermal_core.h