aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2016-12-21 14:19:51 -0500
committerThomas Gleixner <tglx@linutronix.de>2016-12-25 04:47:43 -0500
commite210faa2359f92eb2e417cd8462eb980a4dbb172 (patch)
treefe640deb68b57db1594eb0ec13bdaf051b8f867d /drivers/scsi
parentc53b005dd64bdcf5acac00bd55ecf94dda22dc4f (diff)
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. 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.836895753@linutronix.de Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/bnx2i/bnx2i_init.c78
1 files changed, 30 insertions, 48 deletions
diff --git a/drivers/scsi/bnx2i/bnx2i_init.c b/drivers/scsi/bnx2i/bnx2i_init.c
index c8b410c24cf0..86afc002814c 100644
--- a/drivers/scsi/bnx2i/bnx2i_init.c
+++ b/drivers/scsi/bnx2i/bnx2i_init.c
@@ -70,14 +70,6 @@ u64 iscsi_error_mask = 0x00;
70 70
71DEFINE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu); 71DEFINE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu);
72 72
73static int bnx2i_cpu_callback(struct notifier_block *nfb,
74 unsigned long action, void *hcpu);
75/* notification function for CPU hotplug events */
76static struct notifier_block bnx2i_cpu_notifier = {
77 .notifier_call = bnx2i_cpu_callback,
78};
79
80
81/** 73/**
82 * bnx2i_identify_device - identifies NetXtreme II device type 74 * bnx2i_identify_device - identifies NetXtreme II device type
83 * @hba: Adapter structure pointer 75 * @hba: Adapter structure pointer
@@ -461,41 +453,21 @@ static void bnx2i_percpu_thread_destroy(unsigned int cpu)
461 kthread_stop(thread); 453 kthread_stop(thread);
462} 454}
463 455
464 456static int bnx2i_cpu_online(unsigned int cpu)
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 */
476static int bnx2i_cpu_callback(struct notifier_block *nfb,
477 unsigned long action, void *hcpu)
478{ 457{
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}
480 462
481 switch (action) { 463static int bnx2i_cpu_dead(unsigned int cpu)
482 case CPU_ONLINE: 464{
483 case CPU_ONLINE_FROZEN: 465 pr_info("CPU %x offline: Remove Rx thread\n", cpu);
484 printk(KERN_INFO "bnx2i: CPU %x online: Create Rx thread\n", 466 bnx2i_percpu_thread_destroy(cpu);
485 cpu); 467 return 0;
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;
497} 468}
498 469
470static enum cpuhp_state bnx2i_online_state;
499 471
500/** 472/**
501 * bnx2i_mod_init - module init entry point 473 * bnx2i_mod_init - module init entry point
@@ -539,18 +511,28 @@ static int __init bnx2i_mod_init(void)
539 p->iothread = NULL; 511 p->iothread = NULL;
540 } 512 }
541 513
542 cpu_notifier_register_begin(); 514 get_online_cpus();
543 515
544 for_each_online_cpu(cpu) 516 for_each_online_cpu(cpu)
545 bnx2i_percpu_thread_create(cpu); 517 bnx2i_percpu_thread_create(cpu);
546 518
547 /* Initialize per CPU interrupt thread */ 519 err = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
548 __register_hotcpu_notifier(&bnx2i_cpu_notifier); 520 "scsi/bnx2i:online",
549 521 bnx2i_cpu_online, NULL);
550 cpu_notifier_register_done(); 522 if (err < 0)
523 goto remove_threads;
524 bnx2i_online_state = err;
551 525
526 cpuhp_setup_state_nocalls(CPUHP_SCSI_BNX2I_DEAD, "scsi/bnx2i:dead",
527 NULL, bnx2i_cpu_dead);
528 put_online_cpus();
552 return 0; 529 return 0;
553 530
531remove_threads:
532 for_each_online_cpu(cpu)
533 bnx2i_percpu_thread_destroy(cpu);
534 put_online_cpus();
535 cnic_unregister_driver(CNIC_ULP_ISCSI);
554unreg_xport: 536unreg_xport:
555 iscsi_unregister_transport(&bnx2i_iscsi_transport); 537 iscsi_unregister_transport(&bnx2i_iscsi_transport);
556out: 538out:
@@ -587,14 +569,14 @@ static void __exit bnx2i_mod_exit(void)
587 } 569 }
588 mutex_unlock(&bnx2i_dev_lock); 570 mutex_unlock(&bnx2i_dev_lock);
589 571
590 cpu_notifier_register_begin(); 572 get_online_cpus();
591 573
592 for_each_online_cpu(cpu) 574 for_each_online_cpu(cpu)
593 bnx2i_percpu_thread_destroy(cpu); 575 bnx2i_percpu_thread_destroy(cpu);
594 576
595 __unregister_hotcpu_notifier(&bnx2i_cpu_notifier); 577 cpuhp_remove_state_nocalls(bnx2i_online_state);
596 578 cpuhp_remove_state_nocalls(CPUHP_SCSI_BNX2I_DEAD);
597 cpu_notifier_register_done(); 579 put_online_cpus();
598 580
599 iscsi_unregister_transport(&bnx2i_iscsi_transport); 581 iscsi_unregister_transport(&bnx2i_iscsi_transport);
600 cnic_unregister_driver(CNIC_ULP_ISCSI); 582 cnic_unregister_driver(CNIC_ULP_ISCSI);