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 127 MODULE_PARM_DESC(log_fka, " Print message to kernel log when fcoe is " 128 128 "initiating a FIP keep alive when debug logging is enabled."); 129 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 130 static inline struct net_device *bnx2fc_netdev(const struct fc_lport *lport) 138 131 { 139 132 return ((struct bnx2fc_interface *) ··· 2615 2622 kthread_stop(thread); 2616 2623 } 2617 2624 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 2625 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; 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; 2649 2638 } 2650 2639 2651 2640 static int bnx2fc_slave_configure(struct scsi_device *sdev) ··· 2638 2663 scsi_change_queue_depth(sdev, bnx2fc_queue_depth); 2639 2664 return 0; 2640 2665 } 2666 + 2667 + static enum cpuhp_state bnx2fc_online_state; 2641 2668 2642 2669 /** 2643 2670 * bnx2fc_mod_init - module init entry point ··· 2701 2724 spin_lock_init(&p->fp_work_lock); 2702 2725 } 2703 2726 2704 - cpu_notifier_register_begin(); 2727 + get_online_cpus(); 2705 2728 2706 - for_each_online_cpu(cpu) { 2729 + for_each_online_cpu(cpu) 2707 2730 bnx2fc_percpu_thread_create(cpu); 2708 - } 2709 2731 2710 - /* Initialize per CPU interrupt thread */ 2711 - __register_hotcpu_notifier(&bnx2fc_cpu_notifier); 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; 2712 2738 2713 - cpu_notifier_register_done(); 2739 + cpuhp_setup_state_nocalls(CPUHP_SCSI_BNX2FC_DEAD, "scsi/bnx2fc:dead", 2740 + NULL, bnx2fc_cpu_dead); 2741 + put_online_cpus(); 2714 2742 2715 2743 cnic_register_driver(CNIC_ULP_FCOE, &bnx2fc_cnic_cb); 2716 2744 2717 2745 return 0; 2718 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); 2719 2752 free_wq: 2720 2753 destroy_workqueue(bnx2fc_wq); 2721 2754 release_bt: ··· 2784 2797 if (l2_thread) 2785 2798 kthread_stop(l2_thread); 2786 2799 2787 - cpu_notifier_register_begin(); 2788 - 2800 + get_online_cpus(); 2789 2801 /* Destroy per cpu threads */ 2790 2802 for_each_online_cpu(cpu) { 2791 2803 bnx2fc_percpu_thread_destroy(cpu); 2792 2804 } 2793 2805 2794 - __unregister_hotcpu_notifier(&bnx2fc_cpu_notifier); 2806 + cpuhp_remove_state_nocalls(bnx2fc_online_state); 2807 + cpuhp_remove_state_nocalls(CPUHP_SCSI_BNX2FC_DEAD); 2795 2808 2796 - cpu_notifier_register_done(); 2809 + put_online_cpus(); 2797 2810 2798 2811 destroy_workqueue(bnx2fc_wq); 2799 2812 /*
+1
include/linux/cpuhotplug.h
··· 41 41 CPUHP_NET_DEV_DEAD, 42 42 CPUHP_PCI_XGENE_DEAD, 43 43 CPUHP_IOMMU_INTEL_DEAD, 44 + CPUHP_SCSI_BNX2FC_DEAD, 44 45 CPUHP_WORKQUEUE_PREP, 45 46 CPUHP_POWER_NUMA_PREPARE, 46 47 CPUHP_HRTIMERS_PREPARE,