ACPI: thermal: Carry out trip point updates under zone lock
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 17 Aug 2023 09:24:27 +0000 (11:24 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 17 Aug 2023 09:24:27 +0000 (11:24 +0200)
commit68f4f0378c0cee5c6b6308c1fd6eb7677f354cad
tree7b7cda45c829e412b6b676f63971183fe1854538
parentbf07b4a3ba3446ba4bbe1ddac235162dbda2ce57
ACPI: thermal: Carry out trip point updates under zone lock

There is a race condition between acpi_thermal_trips_update() and
acpi_thermal_check_fn(), because the trip points may get updated while
the latter is running which in theory may lead to inconsistent results.
For example, if two trips are updated together, using the temperature
value of one of them from before the update and the temperature value
of the other one from after the update may not lead to the expected
outcome.

Moreover, if thermal_get_trend() runs when a trip points update is in
progress, it may end up using stale trip point temperatures.

To address this, make acpi_thermal_trips_update() call
thermal_zone_device_exec() to carry out the trip points update and
use a new  acpi_thermal_adjust_thermal_zone() wrapper around
__acpi_thermal_trips_update() as the callback function for the latter.

While at it, change the acpi_thermal_trips_update() return data type
to void as that function always returns 0 anyway.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/thermal.c