]> www.infradead.org Git - users/jedix/linux-maple.git/commit
thermal: core: Synchronize suspend-prepare and post-suspend actions
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 14 Jun 2024 15:22:25 +0000 (17:22 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 14 Jun 2024 15:36:59 +0000 (17:36 +0200)
commitd2278f3533a8c4933c52f85784ffa73e8250c524
tree3c0910d6d7e456b8d068ee60fe6e8769bb5217a1
parent83a7eefedc9b56fe7bfeff13b6c7356688ffa670
thermal: core: Synchronize suspend-prepare and post-suspend actions

After commit 5a5efdaffda5 ("thermal: core: Resume thermal zones
asynchronously") it is theoretically possible that, if a system suspend
starts immediately after a system resume, thermal_zone_device_resume()
spawned by the thermal PM notifier for one of the thermal zones at the
end of the system resume will run after the PM thermal notifier for the
suspend-prepare action.  If that happens, tz->suspended set by the latter
will be reset by the former which may lead to unexpected consequences.

To avoid that race, synchronize thermal_zone_device_resume() with the
suspend-prepare thermal PM notifier with the help of additional bool
field and completion in struct thermal_zone_device.

Note that this also ensures running __thermal_zone_device_update() at
least once for each thermal zone between system resume and the following
system suspend in case it is needed to start thermal mitigation.

Fixes: 5a5efdaffda5 ("thermal: core: Resume thermal zones asynchronously")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/thermal_core.c
drivers/thermal/thermal_core.h