History

scsi/bnx2i: 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 e210faa1 parent c53b0052 files · +31 −48Browse files

Unified · Split

2 files
  1. drivers/scsi/bnx2i/bnx2i_init.c +30 −48
  2. include/linux/cpuhotplug.h +1 −0
drivers/scsi/bnx2i/bnx2i_init.c+30−48
@@ -70,14 +70,6 @@ u64 iscsi_error_mask = 0x00; · 69 unmodified lines
7070
7171 DEFINE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu);
7272
73−static int bnx2i_cpu_callback(struct notifier_block *nfb,
74− unsigned long action, void *hcpu);
75−/* notification function for CPU hotplug events */
76−static struct notifier_block bnx2i_cpu_notifier = {
77− .notifier_call = bnx2i_cpu_callback,
78−};
79−
80−
8173 /**
8274 * bnx2i_identify_device - identifies NetXtreme II device type
8375 * @hba: Adapter structure pointer
@@ -461,41 +453,21 @@ static void bnx2i_percpu_thread_destroy(unsigned int cpu) · 377 unmodified lines
461453 kthread_stop(thread);
462454 }
463455
464−
465−/**
466− * bnx2i_cpu_callback - Handler for CPU hotplug events
467− *
468− * @nfb: The callback data block
469− * @action: The event triggering the callback
470− * @hcpu: The index of the CPU that the event is for
471− *
472− * This creates or destroys per-CPU data for iSCSI
473− *
474− * Returns NOTIFY_OK always.
475− */
476−static int bnx2i_cpu_callback(struct notifier_block *nfb,
477− unsigned long action, void *hcpu)
456+static int bnx2i_cpu_online(unsigned int cpu)
478457 {
479− unsigned cpu = (unsigned long)hcpu;
458+ pr_info("bnx2i: CPU %x online: Create Rx thread\n", cpu);
459+ bnx2i_percpu_thread_create(cpu);
460+ return 0;
461+}
480462
481− switch (action) {
482− case CPU_ONLINE:
483− case CPU_ONLINE_FROZEN:
484− printk(KERN_INFO "bnx2i: CPU %x online: Create Rx thread\n",
485− cpu);
486− bnx2i_percpu_thread_create(cpu);
487− break;
488− case CPU_DEAD:
489− case CPU_DEAD_FROZEN:
490− printk(KERN_INFO "CPU %x offline: Remove Rx thread\n", cpu);
491− bnx2i_percpu_thread_destroy(cpu);
492− break;
493− default:
494− break;
495− }
496− return NOTIFY_OK;
463+static int bnx2i_cpu_dead(unsigned int cpu)
464+{
465+ pr_info("CPU %x offline: Remove Rx thread\n", cpu);
466+ bnx2i_percpu_thread_destroy(cpu);
467+ return 0;
497468 }
498469
470+static enum cpuhp_state bnx2i_online_state;
499471
500472 /**
501473 * bnx2i_mod_init - module init entry point
@@ -539,18 +511,28 @@ static int __init bnx2i_mod_init(void) · 37 unmodified lines
539511 p->iothread = NULL;
540512 }
541513
542− cpu_notifier_register_begin();
514+ get_online_cpus();
543515
544516 for_each_online_cpu(cpu)
545517 bnx2i_percpu_thread_create(cpu);
546518
547− /* Initialize per CPU interrupt thread */
548− __register_hotcpu_notifier(&bnx2i_cpu_notifier);
549−
550− cpu_notifier_register_done();
519+ err = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
520+ "scsi/bnx2i:online",
521+ bnx2i_cpu_online, NULL);
522+ if (err < 0)
523+ goto remove_threads;
524+ bnx2i_online_state = err;
551525
526+ cpuhp_setup_state_nocalls(CPUHP_SCSI_BNX2I_DEAD, "scsi/bnx2i:dead",
527+ NULL, bnx2i_cpu_dead);
528+ put_online_cpus();
552529 return 0;
553530
531+remove_threads:
532+ for_each_online_cpu(cpu)
533+ bnx2i_percpu_thread_destroy(cpu);
534+ put_online_cpus();
535+ cnic_unregister_driver(CNIC_ULP_ISCSI);
554536 unreg_xport:
555537 iscsi_unregister_transport(&bnx2i_iscsi_transport);
556538 out:
@@ -587,14 +569,14 @@ static void __exit bnx2i_mod_exit(void) · 30 unmodified lines
587569 }
588570 mutex_unlock(&bnx2i_dev_lock);
589571
590− cpu_notifier_register_begin();
572+ get_online_cpus();
591573
592574 for_each_online_cpu(cpu)
593575 bnx2i_percpu_thread_destroy(cpu);
594576
595− __unregister_hotcpu_notifier(&bnx2i_cpu_notifier);
596−
597− cpu_notifier_register_done();
577+ cpuhp_remove_state_nocalls(bnx2i_online_state);
578+ cpuhp_remove_state_nocalls(CPUHP_SCSI_BNX2I_DEAD);
579+ put_online_cpus();
598580
599581 iscsi_unregister_transport(&bnx2i_iscsi_transport);
600582 cnic_unregister_driver(CNIC_ULP_ISCSI);
include/linux/cpuhotplug.h+1−0
@@ -42,6 +42,7 @@ enum cpuhp_state { · 41 unmodified lines
4242 CPUHP_PCI_XGENE_DEAD,
4343 CPUHP_IOMMU_INTEL_DEAD,
4444 CPUHP_SCSI_BNX2FC_DEAD,
45+ CPUHP_SCSI_BNX2I_DEAD,
4546 CPUHP_WORKQUEUE_PREP,
4647 CPUHP_POWER_NUMA_PREPARE,
4748 CPUHP_HRTIMERS_PREPARE,