Commit e210faa2 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Thomas Gleixner

scsi/bnx2i: Convert to hotplug state machine

Install the callbacks via the state machine. No functional change.

This is the minimal fixup so we can remove the hotplug notifier mess
completely.

The real rework of this driver to use work queues is still stuck in
review/testing on the SCSI mailing list.
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: linux-scsi@vger.kernel.org
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Chad Dupuis <chad.dupuis@qlogic.com>
Cc: QLogic-Storage-Upstream@qlogic.com
Cc: Johannes Thumshirn <jth@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Link: http://lkml.kernel.org/r/20161221192111.836895753@linutronix.deSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent c53b005d
...@@ -70,14 +70,6 @@ u64 iscsi_error_mask = 0x00; ...@@ -70,14 +70,6 @@ u64 iscsi_error_mask = 0x00;
DEFINE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu); DEFINE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu);
static int bnx2i_cpu_callback(struct notifier_block *nfb,
unsigned long action, void *hcpu);
/* notification function for CPU hotplug events */
static struct notifier_block bnx2i_cpu_notifier = {
.notifier_call = bnx2i_cpu_callback,
};
/** /**
* bnx2i_identify_device - identifies NetXtreme II device type * bnx2i_identify_device - identifies NetXtreme II device type
* @hba: Adapter structure pointer * @hba: Adapter structure pointer
...@@ -461,41 +453,21 @@ static void bnx2i_percpu_thread_destroy(unsigned int cpu) ...@@ -461,41 +453,21 @@ static void bnx2i_percpu_thread_destroy(unsigned int cpu)
kthread_stop(thread); kthread_stop(thread);
} }
static int bnx2i_cpu_online(unsigned int cpu)
/**
* bnx2i_cpu_callback - Handler for CPU hotplug events
*
* @nfb: The callback data block
* @action: The event triggering the callback
* @hcpu: The index of the CPU that the event is for
*
* This creates or destroys per-CPU data for iSCSI
*
* Returns NOTIFY_OK always.
*/
static int bnx2i_cpu_callback(struct notifier_block *nfb,
unsigned long action, void *hcpu)
{ {
unsigned cpu = (unsigned long)hcpu; pr_info("bnx2i: CPU %x online: Create Rx thread\n", cpu);
bnx2i_percpu_thread_create(cpu);
return 0;
}
switch (action) { static int bnx2i_cpu_dead(unsigned int cpu)
case CPU_ONLINE: {
case CPU_ONLINE_FROZEN: pr_info("CPU %x offline: Remove Rx thread\n", cpu);
printk(KERN_INFO "bnx2i: CPU %x online: Create Rx thread\n", bnx2i_percpu_thread_destroy(cpu);
cpu); return 0;
bnx2i_percpu_thread_create(cpu);
break;
case CPU_DEAD:
case CPU_DEAD_FROZEN:
printk(KERN_INFO "CPU %x offline: Remove Rx thread\n", cpu);
bnx2i_percpu_thread_destroy(cpu);
break;
default:
break;
}
return NOTIFY_OK;
} }
static enum cpuhp_state bnx2i_online_state;
/** /**
* bnx2i_mod_init - module init entry point * bnx2i_mod_init - module init entry point
...@@ -539,18 +511,28 @@ static int __init bnx2i_mod_init(void) ...@@ -539,18 +511,28 @@ static int __init bnx2i_mod_init(void)
p->iothread = NULL; p->iothread = NULL;
} }
cpu_notifier_register_begin(); get_online_cpus();
for_each_online_cpu(cpu) for_each_online_cpu(cpu)
bnx2i_percpu_thread_create(cpu); bnx2i_percpu_thread_create(cpu);
/* Initialize per CPU interrupt thread */ err = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
__register_hotcpu_notifier(&bnx2i_cpu_notifier); "scsi/bnx2i:online",
bnx2i_cpu_online, NULL);
cpu_notifier_register_done(); if (err < 0)
goto remove_threads;
bnx2i_online_state = err;
cpuhp_setup_state_nocalls(CPUHP_SCSI_BNX2I_DEAD, "scsi/bnx2i:dead",
NULL, bnx2i_cpu_dead);
put_online_cpus();
return 0; return 0;
remove_threads:
for_each_online_cpu(cpu)
bnx2i_percpu_thread_destroy(cpu);
put_online_cpus();
cnic_unregister_driver(CNIC_ULP_ISCSI);
unreg_xport: unreg_xport:
iscsi_unregister_transport(&bnx2i_iscsi_transport); iscsi_unregister_transport(&bnx2i_iscsi_transport);
out: out:
...@@ -587,14 +569,14 @@ static void __exit bnx2i_mod_exit(void) ...@@ -587,14 +569,14 @@ static void __exit bnx2i_mod_exit(void)
} }
mutex_unlock(&bnx2i_dev_lock); mutex_unlock(&bnx2i_dev_lock);
cpu_notifier_register_begin(); get_online_cpus();
for_each_online_cpu(cpu) for_each_online_cpu(cpu)
bnx2i_percpu_thread_destroy(cpu); bnx2i_percpu_thread_destroy(cpu);
__unregister_hotcpu_notifier(&bnx2i_cpu_notifier); cpuhp_remove_state_nocalls(bnx2i_online_state);
cpuhp_remove_state_nocalls(CPUHP_SCSI_BNX2I_DEAD);
cpu_notifier_register_done(); 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);
......
...@@ -42,6 +42,7 @@ enum cpuhp_state { ...@@ -42,6 +42,7 @@ enum cpuhp_state {
CPUHP_PCI_XGENE_DEAD, CPUHP_PCI_XGENE_DEAD,
CPUHP_IOMMU_INTEL_DEAD, CPUHP_IOMMU_INTEL_DEAD,
CPUHP_SCSI_BNX2FC_DEAD, CPUHP_SCSI_BNX2FC_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