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>

authored by Sebastian Andrzej Siewior and committed by Thomas Gleixner c53b005d dc280d93

+35 -47
+34 -47
drivers/scsi/bnx2fc/bnx2fc_fcoe.c
··· 127 MODULE_PARM_DESC(log_fka, " Print message to kernel log when fcoe is " 128 "initiating a FIP keep alive when debug logging is enabled."); 129 130 - static int bnx2fc_cpu_callback(struct notifier_block *nfb, 131 - unsigned long action, void *hcpu); 132 - /* notification function for CPU hotplug events */ 133 - static struct notifier_block bnx2fc_cpu_notifier = { 134 - .notifier_call = bnx2fc_cpu_callback, 135 - }; 136 - 137 static inline struct net_device *bnx2fc_netdev(const struct fc_lport *lport) 138 { 139 return ((struct bnx2fc_interface *) ··· 2615 kthread_stop(thread); 2616 } 2617 2618 - /** 2619 - * bnx2fc_cpu_callback - Handler for CPU hotplug events 2620 - * 2621 - * @nfb: The callback data block 2622 - * @action: The event triggering the callback 2623 - * @hcpu: The index of the CPU that the event is for 2624 - * 2625 - * This creates or destroys per-CPU data for fcoe 2626 - * 2627 - * Returns NOTIFY_OK always. 2628 - */ 2629 - static int bnx2fc_cpu_callback(struct notifier_block *nfb, 2630 - unsigned long action, void *hcpu) 2631 - { 2632 - unsigned cpu = (unsigned long)hcpu; 2633 2634 - switch (action) { 2635 - case CPU_ONLINE: 2636 - case CPU_ONLINE_FROZEN: 2637 - printk(PFX "CPU %x online: Create Rx thread\n", cpu); 2638 - bnx2fc_percpu_thread_create(cpu); 2639 - break; 2640 - case CPU_DEAD: 2641 - case CPU_DEAD_FROZEN: 2642 - printk(PFX "CPU %x offline: Remove Rx thread\n", cpu); 2643 - bnx2fc_percpu_thread_destroy(cpu); 2644 - break; 2645 - default: 2646 - break; 2647 - } 2648 - return NOTIFY_OK; 2649 } 2650 2651 static int bnx2fc_slave_configure(struct scsi_device *sdev) ··· 2638 scsi_change_queue_depth(sdev, bnx2fc_queue_depth); 2639 return 0; 2640 } 2641 2642 /** 2643 * bnx2fc_mod_init - module init entry point ··· 2701 spin_lock_init(&p->fp_work_lock); 2702 } 2703 2704 - cpu_notifier_register_begin(); 2705 2706 - for_each_online_cpu(cpu) { 2707 bnx2fc_percpu_thread_create(cpu); 2708 - } 2709 2710 - /* Initialize per CPU interrupt thread */ 2711 - __register_hotcpu_notifier(&bnx2fc_cpu_notifier); 2712 2713 - cpu_notifier_register_done(); 2714 2715 cnic_register_driver(CNIC_ULP_FCOE, &bnx2fc_cnic_cb); 2716 2717 return 0; 2718 2719 free_wq: 2720 destroy_workqueue(bnx2fc_wq); 2721 release_bt: ··· 2784 if (l2_thread) 2785 kthread_stop(l2_thread); 2786 2787 - cpu_notifier_register_begin(); 2788 - 2789 /* Destroy per cpu threads */ 2790 for_each_online_cpu(cpu) { 2791 bnx2fc_percpu_thread_destroy(cpu); 2792 } 2793 2794 - __unregister_hotcpu_notifier(&bnx2fc_cpu_notifier); 2795 2796 - cpu_notifier_register_done(); 2797 2798 destroy_workqueue(bnx2fc_wq); 2799 /*
··· 127 MODULE_PARM_DESC(log_fka, " Print message to kernel log when fcoe is " 128 "initiating a FIP keep alive when debug logging is enabled."); 129 130 static inline struct net_device *bnx2fc_netdev(const struct fc_lport *lport) 131 { 132 return ((struct bnx2fc_interface *) ··· 2622 kthread_stop(thread); 2623 } 2624 2625 2626 + static int bnx2fc_cpu_online(unsigned int cpu) 2627 + { 2628 + printk(PFX "CPU %x online: Create Rx thread\n", cpu); 2629 + bnx2fc_percpu_thread_create(cpu); 2630 + return 0; 2631 + } 2632 + 2633 + static int bnx2fc_cpu_dead(unsigned int cpu) 2634 + { 2635 + printk(PFX "CPU %x offline: Remove Rx thread\n", cpu); 2636 + bnx2fc_percpu_thread_destroy(cpu); 2637 + return 0; 2638 } 2639 2640 static int bnx2fc_slave_configure(struct scsi_device *sdev) ··· 2663 scsi_change_queue_depth(sdev, bnx2fc_queue_depth); 2664 return 0; 2665 } 2666 + 2667 + static enum cpuhp_state bnx2fc_online_state; 2668 2669 /** 2670 * bnx2fc_mod_init - module init entry point ··· 2724 spin_lock_init(&p->fp_work_lock); 2725 } 2726 2727 + get_online_cpus(); 2728 2729 + for_each_online_cpu(cpu) 2730 bnx2fc_percpu_thread_create(cpu); 2731 2732 + rc = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, 2733 + "scsi/bnx2fc:online", 2734 + bnx2fc_cpu_online, NULL); 2735 + if (rc < 0) 2736 + goto stop_threads; 2737 + bnx2fc_online_state = rc; 2738 2739 + cpuhp_setup_state_nocalls(CPUHP_SCSI_BNX2FC_DEAD, "scsi/bnx2fc:dead", 2740 + NULL, bnx2fc_cpu_dead); 2741 + put_online_cpus(); 2742 2743 cnic_register_driver(CNIC_ULP_FCOE, &bnx2fc_cnic_cb); 2744 2745 return 0; 2746 2747 + stop_threads: 2748 + for_each_online_cpu(cpu) 2749 + bnx2fc_percpu_thread_destroy(cpu); 2750 + put_online_cpus(); 2751 + kthread_stop(l2_thread); 2752 free_wq: 2753 destroy_workqueue(bnx2fc_wq); 2754 release_bt: ··· 2797 if (l2_thread) 2798 kthread_stop(l2_thread); 2799 2800 + get_online_cpus(); 2801 /* Destroy per cpu threads */ 2802 for_each_online_cpu(cpu) { 2803 bnx2fc_percpu_thread_destroy(cpu); 2804 } 2805 2806 + cpuhp_remove_state_nocalls(bnx2fc_online_state); 2807 + cpuhp_remove_state_nocalls(CPUHP_SCSI_BNX2FC_DEAD); 2808 2809 + put_online_cpus(); 2810 2811 destroy_workqueue(bnx2fc_wq); 2812 /*
+1
include/linux/cpuhotplug.h
··· 41 CPUHP_NET_DEV_DEAD, 42 CPUHP_PCI_XGENE_DEAD, 43 CPUHP_IOMMU_INTEL_DEAD, 44 CPUHP_WORKQUEUE_PREP, 45 CPUHP_POWER_NUMA_PREPARE, 46 CPUHP_HRTIMERS_PREPARE,
··· 41 CPUHP_NET_DEV_DEAD, 42 CPUHP_PCI_XGENE_DEAD, 43 CPUHP_IOMMU_INTEL_DEAD, 44 + CPUHP_SCSI_BNX2FC_DEAD, 45 CPUHP_WORKQUEUE_PREP, 46 CPUHP_POWER_NUMA_PREPARE, 47 CPUHP_HRTIMERS_PREPARE,