提交 c53b005d 编写于 作者: S Sebastian Andrzej Siewior 提交者: Thomas Gleixner

scsi/bnx2fc: 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: NSebastian 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.757309869@linutronix.deSigned-off-by: NThomas Gleixner <tglx@linutronix.de>
上级 dc280d93
...@@ -127,13 +127,6 @@ module_param_named(log_fka, bnx2fc_log_fka, uint, S_IRUGO|S_IWUSR); ...@@ -127,13 +127,6 @@ module_param_named(log_fka, bnx2fc_log_fka, uint, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(log_fka, " Print message to kernel log when fcoe is " MODULE_PARM_DESC(log_fka, " Print message to kernel log when fcoe is "
"initiating a FIP keep alive when debug logging is enabled."); "initiating a FIP keep alive when debug logging is enabled.");
static int bnx2fc_cpu_callback(struct notifier_block *nfb,
unsigned long action, void *hcpu);
/* notification function for CPU hotplug events */
static struct notifier_block bnx2fc_cpu_notifier = {
.notifier_call = bnx2fc_cpu_callback,
};
static inline struct net_device *bnx2fc_netdev(const struct fc_lport *lport) static inline struct net_device *bnx2fc_netdev(const struct fc_lport *lport)
{ {
return ((struct bnx2fc_interface *) return ((struct bnx2fc_interface *)
...@@ -2622,37 +2615,19 @@ static void bnx2fc_percpu_thread_destroy(unsigned int cpu) ...@@ -2622,37 +2615,19 @@ static void bnx2fc_percpu_thread_destroy(unsigned int cpu)
kthread_stop(thread); kthread_stop(thread);
} }
/**
* bnx2fc_cpu_callback - Handler for CPU hotplug events static int bnx2fc_cpu_online(unsigned int cpu)
*
* @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 fcoe
*
* Returns NOTIFY_OK always.
*/
static int bnx2fc_cpu_callback(struct notifier_block *nfb,
unsigned long action, void *hcpu)
{ {
unsigned cpu = (unsigned long)hcpu; printk(PFX "CPU %x online: Create Rx thread\n", cpu);
bnx2fc_percpu_thread_create(cpu);
return 0;
}
switch (action) { static int bnx2fc_cpu_dead(unsigned int cpu)
case CPU_ONLINE: {
case CPU_ONLINE_FROZEN: printk(PFX "CPU %x offline: Remove Rx thread\n", cpu);
printk(PFX "CPU %x online: Create Rx thread\n", cpu); bnx2fc_percpu_thread_destroy(cpu);
bnx2fc_percpu_thread_create(cpu); return 0;
break;
case CPU_DEAD:
case CPU_DEAD_FROZEN:
printk(PFX "CPU %x offline: Remove Rx thread\n", cpu);
bnx2fc_percpu_thread_destroy(cpu);
break;
default:
break;
}
return NOTIFY_OK;
} }
static int bnx2fc_slave_configure(struct scsi_device *sdev) static int bnx2fc_slave_configure(struct scsi_device *sdev)
...@@ -2664,6 +2639,8 @@ static int bnx2fc_slave_configure(struct scsi_device *sdev) ...@@ -2664,6 +2639,8 @@ static int bnx2fc_slave_configure(struct scsi_device *sdev)
return 0; return 0;
} }
static enum cpuhp_state bnx2fc_online_state;
/** /**
* bnx2fc_mod_init - module init entry point * bnx2fc_mod_init - module init entry point
* *
...@@ -2724,21 +2701,31 @@ static int __init bnx2fc_mod_init(void) ...@@ -2724,21 +2701,31 @@ static int __init bnx2fc_mod_init(void)
spin_lock_init(&p->fp_work_lock); spin_lock_init(&p->fp_work_lock);
} }
cpu_notifier_register_begin(); get_online_cpus();
for_each_online_cpu(cpu) { for_each_online_cpu(cpu)
bnx2fc_percpu_thread_create(cpu); bnx2fc_percpu_thread_create(cpu);
}
/* Initialize per CPU interrupt thread */ rc = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
__register_hotcpu_notifier(&bnx2fc_cpu_notifier); "scsi/bnx2fc:online",
bnx2fc_cpu_online, NULL);
if (rc < 0)
goto stop_threads;
bnx2fc_online_state = rc;
cpu_notifier_register_done(); cpuhp_setup_state_nocalls(CPUHP_SCSI_BNX2FC_DEAD, "scsi/bnx2fc:dead",
NULL, bnx2fc_cpu_dead);
put_online_cpus();
cnic_register_driver(CNIC_ULP_FCOE, &bnx2fc_cnic_cb); cnic_register_driver(CNIC_ULP_FCOE, &bnx2fc_cnic_cb);
return 0; return 0;
stop_threads:
for_each_online_cpu(cpu)
bnx2fc_percpu_thread_destroy(cpu);
put_online_cpus();
kthread_stop(l2_thread);
free_wq: free_wq:
destroy_workqueue(bnx2fc_wq); destroy_workqueue(bnx2fc_wq);
release_bt: release_bt:
...@@ -2797,16 +2784,16 @@ static void __exit bnx2fc_mod_exit(void) ...@@ -2797,16 +2784,16 @@ static void __exit bnx2fc_mod_exit(void)
if (l2_thread) if (l2_thread)
kthread_stop(l2_thread); kthread_stop(l2_thread);
cpu_notifier_register_begin(); get_online_cpus();
/* Destroy per cpu threads */ /* Destroy per cpu threads */
for_each_online_cpu(cpu) { for_each_online_cpu(cpu) {
bnx2fc_percpu_thread_destroy(cpu); bnx2fc_percpu_thread_destroy(cpu);
} }
__unregister_hotcpu_notifier(&bnx2fc_cpu_notifier); cpuhp_remove_state_nocalls(bnx2fc_online_state);
cpuhp_remove_state_nocalls(CPUHP_SCSI_BNX2FC_DEAD);
cpu_notifier_register_done(); put_online_cpus();
destroy_workqueue(bnx2fc_wq); destroy_workqueue(bnx2fc_wq);
/* /*
......
...@@ -41,6 +41,7 @@ enum cpuhp_state { ...@@ -41,6 +41,7 @@ enum cpuhp_state {
CPUHP_NET_DEV_DEAD, CPUHP_NET_DEV_DEAD,
CPUHP_PCI_XGENE_DEAD, CPUHP_PCI_XGENE_DEAD,
CPUHP_IOMMU_INTEL_DEAD, CPUHP_IOMMU_INTEL_DEAD,
CPUHP_SCSI_BNX2FC_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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册