aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>2014-03-10 16:40:54 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-03-20 08:43:47 -0400
commitcf0485a2ac70acb1bc83f6310a7ebef3070f0333 (patch)
treefa8788be49e6d61a63634ea63e7396ed78e75013
parent99c3bf361a4afd2ad331e767b3e5e6fa3488a096 (diff)
thermal, x86-pkg-temp: Fix CPU hotplug callback registration
Subsystems that want to register CPU hotplug callbacks, as well as perform initialization for the CPUs that are already online, often do it as shown below: get_online_cpus(); for_each_online_cpu(cpu) init_cpu(cpu); register_cpu_notifier(&foobar_cpu_notifier); put_online_cpus(); This is wrong, since it is prone to ABBA deadlocks involving the cpu_add_remove_lock and the cpu_hotplug.lock (when running concurrently with CPU hotplug operations). Instead, the correct and race-free way of performing the callback registration is: cpu_notifier_register_begin(); for_each_online_cpu(cpu) init_cpu(cpu); /* Note the use of the double underscored version of the API */ __register_cpu_notifier(&foobar_cpu_notifier); cpu_notifier_register_done(); Fix the thermal x86-pkg-temp code by using this latter form of callback registration. Cc: Zhang Rui <rui.zhang@intel.com> Cc: Eduardo Valentin <eduardo.valentin@ti.com> Cc: Ingo Molnar <mingo@kernel.org> Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/thermal/x86_pkg_temp_thermal.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/thermal/x86_pkg_temp_thermal.c b/drivers/thermal/x86_pkg_temp_thermal.c
index 081fd7e6a9f0..9ea3d9d49ffc 100644
--- a/drivers/thermal/x86_pkg_temp_thermal.c
+++ b/drivers/thermal/x86_pkg_temp_thermal.c
@@ -590,12 +590,12 @@ static int __init pkg_temp_thermal_init(void)
590 platform_thermal_package_rate_control = 590 platform_thermal_package_rate_control =
591 pkg_temp_thermal_platform_thermal_rate_control; 591 pkg_temp_thermal_platform_thermal_rate_control;
592 592
593 get_online_cpus(); 593 cpu_notifier_register_begin();
594 for_each_online_cpu(i) 594 for_each_online_cpu(i)
595 if (get_core_online(i)) 595 if (get_core_online(i))
596 goto err_ret; 596 goto err_ret;
597 register_hotcpu_notifier(&pkg_temp_thermal_notifier); 597 __register_hotcpu_notifier(&pkg_temp_thermal_notifier);
598 put_online_cpus(); 598 cpu_notifier_register_done();
599 599
600 pkg_temp_debugfs_init(); /* Don't care if fails */ 600 pkg_temp_debugfs_init(); /* Don't care if fails */
601 601
@@ -604,7 +604,7 @@ static int __init pkg_temp_thermal_init(void)
604err_ret: 604err_ret:
605 for_each_online_cpu(i) 605 for_each_online_cpu(i)
606 put_core_offline(i); 606 put_core_offline(i);
607 put_online_cpus(); 607 cpu_notifier_register_done();
608 kfree(pkg_work_scheduled); 608 kfree(pkg_work_scheduled);
609 platform_thermal_package_notify = NULL; 609 platform_thermal_package_notify = NULL;
610 platform_thermal_package_rate_control = NULL; 610 platform_thermal_package_rate_control = NULL;
@@ -617,8 +617,8 @@ static void __exit pkg_temp_thermal_exit(void)
617 struct phy_dev_entry *phdev, *n; 617 struct phy_dev_entry *phdev, *n;
618 int i; 618 int i;
619 619
620 get_online_cpus(); 620 cpu_notifier_register_begin();
621 unregister_hotcpu_notifier(&pkg_temp_thermal_notifier); 621 __unregister_hotcpu_notifier(&pkg_temp_thermal_notifier);
622 mutex_lock(&phy_dev_list_mutex); 622 mutex_lock(&phy_dev_list_mutex);
623 list_for_each_entry_safe(phdev, n, &phy_dev_list, list) { 623 list_for_each_entry_safe(phdev, n, &phy_dev_list, list) {
624 /* Retore old MSR value for package thermal interrupt */ 624 /* Retore old MSR value for package thermal interrupt */
@@ -636,7 +636,7 @@ static void __exit pkg_temp_thermal_exit(void)
636 for_each_online_cpu(i) 636 for_each_online_cpu(i)
637 cancel_delayed_work_sync( 637 cancel_delayed_work_sync(
638 &per_cpu(pkg_temp_thermal_threshold_work, i)); 638 &per_cpu(pkg_temp_thermal_threshold_work, i));
639 put_online_cpus(); 639 cpu_notifier_register_done();
640 640
641 kfree(pkg_work_scheduled); 641 kfree(pkg_work_scheduled);
642 642