diff options
author | Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> | 2014-03-10 16:39:45 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-03-20 08:43:44 -0400 |
commit | 7229b6d0b2a9e62d5eb4886dcd0137664c735718 (patch) | |
tree | 9c20d95dd9b4ab0171b83baa6e564d77d4a6f1e1 /drivers/scsi | |
parent | bc0003c93f0e68b5383fb36579f7efa267b7dc16 (diff) |
scsi, bnx2fc: 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 bnx2fc code in scsi by using this latter form of callback
registration.
Cc: Eddie Wai <eddie.wai@broadcom.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.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>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index 9b948505d118..c4ec235baead 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c | |||
@@ -2586,12 +2586,16 @@ static int __init bnx2fc_mod_init(void) | |||
2586 | spin_lock_init(&p->fp_work_lock); | 2586 | spin_lock_init(&p->fp_work_lock); |
2587 | } | 2587 | } |
2588 | 2588 | ||
2589 | cpu_notifier_register_begin(); | ||
2590 | |||
2589 | for_each_online_cpu(cpu) { | 2591 | for_each_online_cpu(cpu) { |
2590 | bnx2fc_percpu_thread_create(cpu); | 2592 | bnx2fc_percpu_thread_create(cpu); |
2591 | } | 2593 | } |
2592 | 2594 | ||
2593 | /* Initialize per CPU interrupt thread */ | 2595 | /* Initialize per CPU interrupt thread */ |
2594 | register_hotcpu_notifier(&bnx2fc_cpu_notifier); | 2596 | __register_hotcpu_notifier(&bnx2fc_cpu_notifier); |
2597 | |||
2598 | cpu_notifier_register_done(); | ||
2595 | 2599 | ||
2596 | cnic_register_driver(CNIC_ULP_FCOE, &bnx2fc_cnic_cb); | 2600 | cnic_register_driver(CNIC_ULP_FCOE, &bnx2fc_cnic_cb); |
2597 | 2601 | ||
@@ -2656,13 +2660,17 @@ static void __exit bnx2fc_mod_exit(void) | |||
2656 | if (l2_thread) | 2660 | if (l2_thread) |
2657 | kthread_stop(l2_thread); | 2661 | kthread_stop(l2_thread); |
2658 | 2662 | ||
2659 | unregister_hotcpu_notifier(&bnx2fc_cpu_notifier); | 2663 | cpu_notifier_register_begin(); |
2660 | 2664 | ||
2661 | /* Destroy per cpu threads */ | 2665 | /* Destroy per cpu threads */ |
2662 | for_each_online_cpu(cpu) { | 2666 | for_each_online_cpu(cpu) { |
2663 | bnx2fc_percpu_thread_destroy(cpu); | 2667 | bnx2fc_percpu_thread_destroy(cpu); |
2664 | } | 2668 | } |
2665 | 2669 | ||
2670 | __unregister_hotcpu_notifier(&bnx2fc_cpu_notifier); | ||
2671 | |||
2672 | cpu_notifier_register_done(); | ||
2673 | |||
2666 | destroy_workqueue(bnx2fc_wq); | 2674 | destroy_workqueue(bnx2fc_wq); |
2667 | /* | 2675 | /* |
2668 | * detach from scsi transport | 2676 | * detach from scsi transport |