Commit f9f22a86 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Martin K. Petersen

scsi: bnx2i: Simplify cpu hotplug code

The CPU hotplug related code of this driver can be simplified by:

1) Consolidating the callbacks into a single state. The CPU thread can be
   torn down on the CPU which goes offline. There is no point in delaying
   that to the CPU dead state

2) Let the core code invoke the online/offline callbacks and remove the
   extra for_each_online_cpu() loops.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Acked-by: default avatarChad Dupuis <chad.dupuis@cavium.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 1937f8a2
...@@ -404,12 +404,11 @@ int bnx2i_get_stats(void *handle) ...@@ -404,12 +404,11 @@ int bnx2i_get_stats(void *handle)
/** /**
* bnx2i_percpu_thread_create - Create a receive thread for an * bnx2i_cpu_online - Create a receive thread for an online CPU
* online CPU
* *
* @cpu: cpu index for the online cpu * @cpu: cpu index for the online cpu
*/ */
static void bnx2i_percpu_thread_create(unsigned int cpu) static int bnx2i_cpu_online(unsigned int cpu)
{ {
struct bnx2i_percpu_s *p; struct bnx2i_percpu_s *p;
struct task_struct *thread; struct task_struct *thread;
...@@ -419,16 +418,17 @@ static void bnx2i_percpu_thread_create(unsigned int cpu) ...@@ -419,16 +418,17 @@ static void bnx2i_percpu_thread_create(unsigned int cpu)
thread = kthread_create_on_node(bnx2i_percpu_io_thread, (void *)p, thread = kthread_create_on_node(bnx2i_percpu_io_thread, (void *)p,
cpu_to_node(cpu), cpu_to_node(cpu),
"bnx2i_thread/%d", cpu); "bnx2i_thread/%d", cpu);
if (IS_ERR(thread))
return PTR_ERR(thread);
/* bind thread to the cpu */ /* bind thread to the cpu */
if (likely(!IS_ERR(thread))) {
kthread_bind(thread, cpu); kthread_bind(thread, cpu);
p->iothread = thread; p->iothread = thread;
wake_up_process(thread); wake_up_process(thread);
} return 0;
} }
static int bnx2i_cpu_offline(unsigned int cpu)
static void bnx2i_percpu_thread_destroy(unsigned int cpu)
{ {
struct bnx2i_percpu_s *p; struct bnx2i_percpu_s *p;
struct task_struct *thread; struct task_struct *thread;
...@@ -451,19 +451,6 @@ static void bnx2i_percpu_thread_destroy(unsigned int cpu) ...@@ -451,19 +451,6 @@ static void bnx2i_percpu_thread_destroy(unsigned int cpu)
spin_unlock_bh(&p->p_work_lock); spin_unlock_bh(&p->p_work_lock);
if (thread) if (thread)
kthread_stop(thread); kthread_stop(thread);
}
static int bnx2i_cpu_online(unsigned int cpu)
{
pr_info("bnx2i: CPU %x online: Create Rx thread\n", cpu);
bnx2i_percpu_thread_create(cpu);
return 0;
}
static int bnx2i_cpu_dead(unsigned int cpu)
{
pr_info("CPU %x offline: Remove Rx thread\n", cpu);
bnx2i_percpu_thread_destroy(cpu);
return 0; return 0;
} }
...@@ -511,28 +498,14 @@ static int __init bnx2i_mod_init(void) ...@@ -511,28 +498,14 @@ static int __init bnx2i_mod_init(void)
p->iothread = NULL; p->iothread = NULL;
} }
get_online_cpus(); err = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "scsi/bnx2i:online",
bnx2i_cpu_online, bnx2i_cpu_offline);
for_each_online_cpu(cpu)
bnx2i_percpu_thread_create(cpu);
err = cpuhp_setup_state_nocalls_cpuslocked(CPUHP_AP_ONLINE_DYN,
"scsi/bnx2i:online",
bnx2i_cpu_online, NULL);
if (err < 0) if (err < 0)
goto remove_threads; goto unreg_driver;
bnx2i_online_state = err; bnx2i_online_state = err;
cpuhp_setup_state_nocalls_cpuslocked(CPUHP_SCSI_BNX2I_DEAD,
"scsi/bnx2i:dead",
NULL, bnx2i_cpu_dead);
put_online_cpus();
return 0; return 0;
remove_threads: unreg_driver:
for_each_online_cpu(cpu)
bnx2i_percpu_thread_destroy(cpu);
put_online_cpus();
cnic_unregister_driver(CNIC_ULP_ISCSI); cnic_unregister_driver(CNIC_ULP_ISCSI);
unreg_xport: unreg_xport:
iscsi_unregister_transport(&bnx2i_iscsi_transport); iscsi_unregister_transport(&bnx2i_iscsi_transport);
...@@ -552,7 +525,6 @@ static int __init bnx2i_mod_init(void) ...@@ -552,7 +525,6 @@ static int __init bnx2i_mod_init(void)
static void __exit bnx2i_mod_exit(void) static void __exit bnx2i_mod_exit(void)
{ {
struct bnx2i_hba *hba; struct bnx2i_hba *hba;
unsigned cpu = 0;
mutex_lock(&bnx2i_dev_lock); mutex_lock(&bnx2i_dev_lock);
while (!list_empty(&adapter_list)) { while (!list_empty(&adapter_list)) {
...@@ -570,14 +542,7 @@ static void __exit bnx2i_mod_exit(void) ...@@ -570,14 +542,7 @@ static void __exit bnx2i_mod_exit(void)
} }
mutex_unlock(&bnx2i_dev_lock); mutex_unlock(&bnx2i_dev_lock);
get_online_cpus(); cpuhp_remove_state(bnx2i_online_state);
for_each_online_cpu(cpu)
bnx2i_percpu_thread_destroy(cpu);
cpuhp_remove_state_nocalls_cpuslocked(bnx2i_online_state);
cpuhp_remove_state_nocalls_cpuslocked(CPUHP_SCSI_BNX2I_DEAD);
put_online_cpus();
iscsi_unregister_transport(&bnx2i_iscsi_transport); iscsi_unregister_transport(&bnx2i_iscsi_transport);
cnic_unregister_driver(CNIC_ULP_ISCSI); cnic_unregister_driver(CNIC_ULP_ISCSI);
......
...@@ -39,7 +39,6 @@ enum cpuhp_state { ...@@ -39,7 +39,6 @@ enum cpuhp_state {
CPUHP_PCI_XGENE_DEAD, CPUHP_PCI_XGENE_DEAD,
CPUHP_IOMMU_INTEL_DEAD, CPUHP_IOMMU_INTEL_DEAD,
CPUHP_LUSTRE_CFS_DEAD, CPUHP_LUSTRE_CFS_DEAD,
CPUHP_SCSI_BNX2I_DEAD,
CPUHP_WORKQUEUE_PREP, CPUHP_WORKQUEUE_PREP,
CPUHP_POWER_NUMA_PREPARE, CPUHP_POWER_NUMA_PREPARE,
CPUHP_HRTIMERS_PREPARE, CPUHP_HRTIMERS_PREPARE,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment