• Matthew Wilcox's avatar
    thermal: Fix potential deadlock in cpu_cooling · 088db931
    Matthew Wilcox authored
    cooling_list_lock is covering not just cpufreq_dev_count, but also the
    calls to cpufreq_register_notifier() and cpufreq_unregister_notifier().
    
    Since cooling_list_lock is also used within cpufreq_thermal_notifier(),
    lockdep reports a potential deadlock. Fix it by testing the condition
    under cooling_list_lock and dropping the lock before calling
    cpufreq_register_notifier(). And variable cpufreq_dev_count is removed
    at the same time, because it's no longer needed after the fix.
    
    Fixes: ae606089 ("thermal: convert cpu_cooling to use an IDA")
    Reported-and-Tested-by: default avatarRussell King <linux@armlinux.org.uk>
    Signed-off-by: default avatarMatthew Wilcox <mawilcox@microsoft.com>
    Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com
    Signed-off-by: default avatarZhang Rui <rui.zhang@intel.com>
    088db931
cpu_cooling.c 31.8 KB