History

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.

Sebastian Andrzej Siewior committed 9 years ago

Commit c53b0051 parent dc280d92 files · +34 −46Browse files

Unified · Split

2 files
  1. drivers/scsi/bnx2fc/bnx2fc_fcoe.c +33 −46
  2. include/linux/cpuhotplug.h +1 −0
drivers/scsi/bnx2fc/bnx2fc_fcoe.c+33−46
@@ -127,13 +127,6 @@ module_param_named(log_fka, bnx2fc_log_fka, uint, S_IRUGO|S_IWUSR); · 126 unmodified lines
127127 MODULE_PARM_DESC(log_fka, " Print message to kernel log when fcoe is "
128128 "initiating a FIP keep alive when debug logging is enabled.");
129129
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−
137130 static inline struct net_device *bnx2fc_netdev(const struct fc_lport *lport)
138131 {
139132 return ((struct bnx2fc_interface *)
@@ -2622,37 +2615,19 @@ static void bnx2fc_percpu_thread_destroy(unsigned int cpu) · 2482 unmodified lines
26222615 kthread_stop(thread);
26232616 }
26242617
2625−/**
2626− * bnx2fc_cpu_callback - Handler for CPU hotplug events
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− */
2636−static int bnx2fc_cpu_callback(struct notifier_block *nfb,
2637− unsigned long action, void *hcpu)
2618+
2619+static int bnx2fc_cpu_online(unsigned int cpu)
26382620 {
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+}
26402625
2641− switch (action) {
2642− case CPU_ONLINE:
2643− case CPU_ONLINE_FROZEN:
2644− printk(PFX "CPU %x online: Create Rx thread\n", cpu);
2645− bnx2fc_percpu_thread_create(cpu);
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;
2626+static int bnx2fc_cpu_dead(unsigned int cpu)
2627+{
2628+ printk(PFX "CPU %x offline: Remove Rx thread\n", cpu);
2629+ bnx2fc_percpu_thread_destroy(cpu);
2630+ return 0;
26562631 }
26572632
26582633 static int bnx2fc_slave_configure(struct scsi_device *sdev)
@@ -2664,6 +2639,8 @@ static int bnx2fc_slave_configure(struct scsi_device *sdev) · 5 unmodified lines
26642639 return 0;
26652640 }
26662641
2642+static enum cpuhp_state bnx2fc_online_state;
2643+
26672644 /**
26682645 * bnx2fc_mod_init - module init entry point
26692646 *
@@ -2724,21 +2701,31 @@ static int __init bnx2fc_mod_init(void) · 54 unmodified lines
27242701 spin_lock_init(&p->fp_work_lock);
27252702 }
27262703
2727− cpu_notifier_register_begin();
2704+ get_online_cpus();
27282705
2729− for_each_online_cpu(cpu) {
2706+ for_each_online_cpu(cpu)
27302707 bnx2fc_percpu_thread_create(cpu);
2731− }
27322708
2733− /* Initialize per CPU interrupt thread */
2734− __register_hotcpu_notifier(&bnx2fc_cpu_notifier);
2709+ rc = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
2710+ "scsi/bnx2fc:online",
2711+ bnx2fc_cpu_online, NULL);
2712+ if (rc < 0)
2713+ goto stop_threads;
2714+ bnx2fc_online_state = rc;
27352715
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();
27372719
27382720 cnic_register_driver(CNIC_ULP_FCOE, &bnx2fc_cnic_cb);
27392721
27402722 return 0;
27412723
2724+stop_threads:
2725+ for_each_online_cpu(cpu)
2726+ bnx2fc_percpu_thread_destroy(cpu);
2727+ put_online_cpus();
2728+ kthread_stop(l2_thread);
27422729 free_wq:
27432730 destroy_workqueue(bnx2fc_wq);
27442731 release_bt:
@@ -2797,16 +2784,16 @@ static void __exit bnx2fc_mod_exit(void) · 52 unmodified lines
27972784 if (l2_thread)
27982785 kthread_stop(l2_thread);
27992786
2800− cpu_notifier_register_begin();
2801−
2787+ get_online_cpus();
28022788 /* Destroy per cpu threads */
28032789 for_each_online_cpu(cpu) {
28042790 bnx2fc_percpu_thread_destroy(cpu);
28052791 }
28062792
2807− __unregister_hotcpu_notifier(&bnx2fc_cpu_notifier);
2793+ cpuhp_remove_state_nocalls(bnx2fc_online_state);
2794+ cpuhp_remove_state_nocalls(CPUHP_SCSI_BNX2FC_DEAD);
28082795
2809− cpu_notifier_register_done();
2796+ put_online_cpus();
28102797
28112798 destroy_workqueue(bnx2fc_wq);
28122799 /*
include/linux/cpuhotplug.h+1−0
@@ -41,6 +41,7 @@ enum cpuhp_state { · 40 unmodified lines
4141 CPUHP_NET_DEV_DEAD,
4242 CPUHP_PCI_XGENE_DEAD,
4343 CPUHP_IOMMU_INTEL_DEAD,
44+ CPUHP_SCSI_BNX2FC_DEAD,
4445 CPUHP_WORKQUEUE_PREP,
4546 CPUHP_POWER_NUMA_PREPARE,
4647 CPUHP_HRTIMERS_PREPARE,