aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2016-12-21 14:19:50 -0500
committerThomas Gleixner <tglx@linutronix.de>2016-12-25 04:47:42 -0500
commitc53b005dd64bdcf5acac00bd55ecf94dda22dc4f (patch)
tree0625d6e42c1011e1455ccaa03067d92e73972ebe
parentdc280d93623927570da279e99393879dbbab39e7 (diff)
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: Sebastian 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.de Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--drivers/scsi/bnx2fc/bnx2fc_fcoe.c79
-rw-r--r--include/linux/cpuhotplug.h1
2 files changed, 34 insertions, 46 deletions
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 0990130821fa..c639d5a02656 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -127,13 +127,6 @@ module_param_named(log_fka, bnx2fc_log_fka, uint, S_IRUGO|S_IWUSR);
127MODULE_PARM_DESC(log_fka, " Print message to kernel log when fcoe is " 127MODULE_PARM_DESC(log_fka, " Print message to kernel log when fcoe is "
128 "initiating a FIP keep alive when debug logging is enabled."); 128 "initiating a FIP keep alive when debug logging is enabled.");
129 129
130static int bnx2fc_cpu_callback(struct notifier_block *nfb,
131 unsigned long action, void *hcpu);
132/* notification function for CPU hotplug events */
133static struct notifier_block bnx2fc_cpu_notifier = {
134 .notifier_call = bnx2fc_cpu_callback,
135};
136
137static inline struct net_device *bnx2fc_netdev(const struct fc_lport *lport) 130static inline struct net_device *bnx2fc_netdev(const struct fc_lport *lport)
138{ 131{
139 return ((struct bnx2fc_interface *) 132 return ((struct bnx2fc_interface *)
@@ -2622,37 +2615,19 @@ static void bnx2fc_percpu_thread_destroy(unsigned int cpu)
2622 kthread_stop(thread); 2615 kthread_stop(thread);
2623} 2616}
2624 2617
2625/** 2618
2626 * bnx2fc_cpu_callback - Handler for CPU hotplug events 2619static int bnx2fc_cpu_online(unsigned int cpu)
2627 *
2628 * @nfb: The callback data block
2629 * @action: The event triggering the callback
2630 * @hcpu: The index of the CPU that the event is for
2631 *
2632 * This creates or destroys per-CPU data for fcoe
2633 *
2634 * Returns NOTIFY_OK always.
2635 */
2636static int bnx2fc_cpu_callback(struct notifier_block *nfb,
2637 unsigned long action, void *hcpu)
2638{ 2620{
2639 unsigned cpu = (unsigned long)hcpu; 2621 printk(PFX "CPU %x online: Create Rx thread\n", cpu);
2622 bnx2fc_percpu_thread_create(cpu);
2623 return 0;
2624}
2640 2625
2641 switch (action) { 2626static int bnx2fc_cpu_dead(unsigned int cpu)
2642 case CPU_ONLINE: 2627{
2643 case CPU_ONLINE_FROZEN: 2628 printk(PFX "CPU %x offline: Remove Rx thread\n", cpu);
2644 printk(PFX "CPU %x online: Create Rx thread\n", cpu); 2629 bnx2fc_percpu_thread_destroy(cpu);
2645 bnx2fc_percpu_thread_create(cpu); 2630 return 0;
2646 break;
2647 case CPU_DEAD:
2648 case CPU_DEAD_FROZEN:
2649 printk(PFX "CPU %x offline: Remove Rx thread\n", cpu);
2650 bnx2fc_percpu_thread_destroy(cpu);
2651 break;
2652 default:
2653 break;
2654 }
2655 return NOTIFY_OK;
2656} 2631}
2657 2632
2658static int bnx2fc_slave_configure(struct scsi_device *sdev) 2633static int bnx2fc_slave_configure(struct scsi_device *sdev)
@@ -2664,6 +2639,8 @@ static int bnx2fc_slave_configure(struct scsi_device *sdev)
2664 return 0; 2639 return 0;
2665} 2640}
2666 2641
2642static enum cpuhp_state bnx2fc_online_state;
2643
2667/** 2644/**
2668 * bnx2fc_mod_init - module init entry point 2645 * bnx2fc_mod_init - module init entry point
2669 * 2646 *
@@ -2724,21 +2701,31 @@ static int __init bnx2fc_mod_init(void)
2724 spin_lock_init(&p->fp_work_lock); 2701 spin_lock_init(&p->fp_work_lock);
2725 } 2702 }
2726 2703
2727 cpu_notifier_register_begin(); 2704 get_online_cpus();
2728 2705
2729 for_each_online_cpu(cpu) { 2706 for_each_online_cpu(cpu)
2730 bnx2fc_percpu_thread_create(cpu); 2707 bnx2fc_percpu_thread_create(cpu);
2731 }
2732 2708
2733 /* Initialize per CPU interrupt thread */ 2709 rc = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
2734 __register_hotcpu_notifier(&bnx2fc_cpu_notifier); 2710 "scsi/bnx2fc:online",
2711 bnx2fc_cpu_online, NULL);
2712 if (rc < 0)
2713 goto stop_threads;
2714 bnx2fc_online_state = rc;
2735 2715
2736 cpu_notifier_register_done(); 2716 cpuhp_setup_state_nocalls(CPUHP_SCSI_BNX2FC_DEAD, "scsi/bnx2fc:dead",
2717 NULL, bnx2fc_cpu_dead);
2718 put_online_cpus();
2737 2719
2738 cnic_register_driver(CNIC_ULP_FCOE, &bnx2fc_cnic_cb); 2720 cnic_register_driver(CNIC_ULP_FCOE, &bnx2fc_cnic_cb);
2739 2721
2740 return 0; 2722 return 0;
2741 2723
2724stop_threads:
2725 for_each_online_cpu(cpu)
2726 bnx2fc_percpu_thread_destroy(cpu);
2727 put_online_cpus();
2728 kthread_stop(l2_thread);
2742free_wq: 2729free_wq:
2743 destroy_workqueue(bnx2fc_wq); 2730 destroy_workqueue(bnx2fc_wq);
2744release_bt: 2731release_bt:
@@ -2797,16 +2784,16 @@ static void __exit bnx2fc_mod_exit(void)
2797 if (l2_thread) 2784 if (l2_thread)
2798 kthread_stop(l2_thread); 2785 kthread_stop(l2_thread);
2799 2786
2800 cpu_notifier_register_begin(); 2787 get_online_cpus();
2801
2802 /* Destroy per cpu threads */ 2788 /* Destroy per cpu threads */
2803 for_each_online_cpu(cpu) { 2789 for_each_online_cpu(cpu) {
2804 bnx2fc_percpu_thread_destroy(cpu); 2790 bnx2fc_percpu_thread_destroy(cpu);
2805 } 2791 }
2806 2792
2807 __unregister_hotcpu_notifier(&bnx2fc_cpu_notifier); 2793 cpuhp_remove_state_nocalls(bnx2fc_online_state);
2794 cpuhp_remove_state_nocalls(CPUHP_SCSI_BNX2FC_DEAD);
2808 2795
2809 cpu_notifier_register_done(); 2796 put_online_cpus();
2810 2797
2811 destroy_workqueue(bnx2fc_wq); 2798 destroy_workqueue(bnx2fc_wq);
2812 /* 2799 /*
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index 2ab7bf53d529..ab0e54d25647 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -41,6 +41,7 @@ enum cpuhp_state {
41 CPUHP_NET_DEV_DEAD, 41 CPUHP_NET_DEV_DEAD,
42 CPUHP_PCI_XGENE_DEAD, 42 CPUHP_PCI_XGENE_DEAD,
43 CPUHP_IOMMU_INTEL_DEAD, 43 CPUHP_IOMMU_INTEL_DEAD,
44 CPUHP_SCSI_BNX2FC_DEAD,
44 CPUHP_WORKQUEUE_PREP, 45 CPUHP_WORKQUEUE_PREP,
45 CPUHP_POWER_NUMA_PREPARE, 46 CPUHP_POWER_NUMA_PREPARE,
46 CPUHP_HRTIMERS_PREPARE, 47 CPUHP_HRTIMERS_PREPARE,