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>

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

+32 -49
+31 -49
drivers/scsi/bnx2i/bnx2i_init.c
··· 70 71 DEFINE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu); 72 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 - 81 /** 82 * bnx2i_identify_device - identifies NetXtreme II device type 83 * @hba: Adapter structure pointer ··· 453 kthread_stop(thread); 454 } 455 456 - 457 - /** 458 - * bnx2i_cpu_callback - Handler for CPU hotplug events 459 - * 460 - * @nfb: The callback data block 461 - * @action: The event triggering the callback 462 - * @hcpu: The index of the CPU that the event is for 463 - * 464 - * This creates or destroys per-CPU data for iSCSI 465 - * 466 - * Returns NOTIFY_OK always. 467 - */ 468 - static int bnx2i_cpu_callback(struct notifier_block *nfb, 469 - unsigned long action, void *hcpu) 470 { 471 - unsigned cpu = (unsigned long)hcpu; 472 - 473 - switch (action) { 474 - case CPU_ONLINE: 475 - case CPU_ONLINE_FROZEN: 476 - printk(KERN_INFO "bnx2i: CPU %x online: Create Rx thread\n", 477 - cpu); 478 - bnx2i_percpu_thread_create(cpu); 479 - break; 480 - case CPU_DEAD: 481 - case CPU_DEAD_FROZEN: 482 - printk(KERN_INFO "CPU %x offline: Remove Rx thread\n", cpu); 483 - bnx2i_percpu_thread_destroy(cpu); 484 - break; 485 - default: 486 - break; 487 - } 488 - return NOTIFY_OK; 489 } 490 491 492 /** 493 * bnx2i_mod_init - module init entry point ··· 511 p->iothread = NULL; 512 } 513 514 - cpu_notifier_register_begin(); 515 516 for_each_online_cpu(cpu) 517 bnx2i_percpu_thread_create(cpu); 518 519 - /* Initialize per CPU interrupt thread */ 520 - __register_hotcpu_notifier(&bnx2i_cpu_notifier); 521 522 - cpu_notifier_register_done(); 523 - 524 return 0; 525 526 unreg_xport: 527 iscsi_unregister_transport(&bnx2i_iscsi_transport); 528 out: ··· 569 } 570 mutex_unlock(&bnx2i_dev_lock); 571 572 - cpu_notifier_register_begin(); 573 574 for_each_online_cpu(cpu) 575 bnx2i_percpu_thread_destroy(cpu); 576 577 - __unregister_hotcpu_notifier(&bnx2i_cpu_notifier); 578 - 579 - cpu_notifier_register_done(); 580 581 iscsi_unregister_transport(&bnx2i_iscsi_transport); 582 cnic_unregister_driver(CNIC_ULP_ISCSI);
··· 70 71 DEFINE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu); 72 73 /** 74 * bnx2i_identify_device - identifies NetXtreme II device type 75 * @hba: Adapter structure pointer ··· 461 kthread_stop(thread); 462 } 463 464 + static int bnx2i_cpu_online(unsigned int cpu) 465 { 466 + pr_info("bnx2i: CPU %x online: Create Rx thread\n", cpu); 467 + bnx2i_percpu_thread_create(cpu); 468 + return 0; 469 } 470 471 + static int bnx2i_cpu_dead(unsigned int cpu) 472 + { 473 + pr_info("CPU %x offline: Remove Rx thread\n", cpu); 474 + bnx2i_percpu_thread_destroy(cpu); 475 + return 0; 476 + } 477 + 478 + static enum cpuhp_state bnx2i_online_state; 479 480 /** 481 * bnx2i_mod_init - module init entry point ··· 539 p->iothread = NULL; 540 } 541 542 + get_online_cpus(); 543 544 for_each_online_cpu(cpu) 545 bnx2i_percpu_thread_create(cpu); 546 547 + err = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, 548 + "scsi/bnx2i:online", 549 + bnx2i_cpu_online, NULL); 550 + if (err < 0) 551 + goto remove_threads; 552 + bnx2i_online_state = err; 553 554 + cpuhp_setup_state_nocalls(CPUHP_SCSI_BNX2I_DEAD, "scsi/bnx2i:dead", 555 + NULL, bnx2i_cpu_dead); 556 + put_online_cpus(); 557 return 0; 558 559 + remove_threads: 560 + for_each_online_cpu(cpu) 561 + bnx2i_percpu_thread_destroy(cpu); 562 + put_online_cpus(); 563 + cnic_unregister_driver(CNIC_ULP_ISCSI); 564 unreg_xport: 565 iscsi_unregister_transport(&bnx2i_iscsi_transport); 566 out: ··· 587 } 588 mutex_unlock(&bnx2i_dev_lock); 589 590 + get_online_cpus(); 591 592 for_each_online_cpu(cpu) 593 bnx2i_percpu_thread_destroy(cpu); 594 595 + cpuhp_remove_state_nocalls(bnx2i_online_state); 596 + cpuhp_remove_state_nocalls(CPUHP_SCSI_BNX2I_DEAD); 597 + put_online_cpus(); 598 599 iscsi_unregister_transport(&bnx2i_iscsi_transport); 600 cnic_unregister_driver(CNIC_ULP_ISCSI);
+1
include/linux/cpuhotplug.h
··· 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,
··· 42 CPUHP_PCI_XGENE_DEAD, 43 CPUHP_IOMMU_INTEL_DEAD, 44 CPUHP_SCSI_BNX2FC_DEAD, 45 + CPUHP_SCSI_BNX2I_DEAD, 46 CPUHP_WORKQUEUE_PREP, 47 CPUHP_POWER_NUMA_PREPARE, 48 CPUHP_HRTIMERS_PREPARE,