• Rafael J. Wysocki's avatar
    ACPI: thermal: Do not call acpi_thermal_check() directly · 81b704d3
    Rafael J. Wysocki authored
    Calling acpi_thermal_check() from acpi_thermal_notify() directly
    is problematic if _TMP triggers Notify () on the thermal zone for
    which it has been evaluated (which happens on some systems), because
    it causes a new acpi_thermal_notify() invocation to be queued up
    every time and if that takes place too often, an indefinite number of
    pending work items may accumulate in kacpi_notify_wq over time.
    
    Besides, it is not really useful to queue up a new invocation of
    acpi_thermal_check() if one of them is pending already.
    
    For these reasons, rework acpi_thermal_notify() to queue up a thermal
    check instead of calling acpi_thermal_check() directly and only allow
    one thermal check to be pending at a time.  Moreover, only allow one
    acpi_thermal_check_fn() instance at a time to run
    thermal_zone_device_update() for one thermal zone and make it return
    early if it sees other instances running for the same thermal zone.
    
    While at it, fold acpi_thermal_check() into acpi_thermal_check_fn(),
    as it is only called from there after the other changes made here.
    
    [This issue appears to have been exposed by commit 6d25be57
     ("sched/core, workqueues: Distangle worker accounting from rq
     lock"), but it is unclear why it was not visible earlier.]
    
    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=208877Reported-by: default avatarStephen Berman <stephen.berman@gmx.net>
    Diagnosed-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    Reviewed-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
    Tested-by: default avatarStephen Berman <stephen.berman@gmx.net>
    Cc: All applicable <stable@vger.kernel.org>
    81b704d3
thermal.c 31.4 KB