• Rafael J. Wysocki's avatar
    thermal: core: Synchronize suspend-prepare and post-suspend actions · d2278f35
    Rafael J. Wysocki authored
    After commit 5a5efdaf ("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: 5a5efdaf ("thermal: core: Resume thermal zones asynchronously")
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    d2278f35
thermal_core.h 10.2 KB