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 70 71 71 DEFINE_PER_CPU(struct bnx2i_percpu_s, bnx2i_percpu); 72 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 73 /** 82 74 * bnx2i_identify_device - identifies NetXtreme II device type 83 75 * @hba: Adapter structure pointer ··· 453 461 kthread_stop(thread); 454 462 } 455 463 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) 464 + static int bnx2i_cpu_online(unsigned int cpu) 470 465 { 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; 466 + pr_info("bnx2i: CPU %x online: Create Rx thread\n", cpu); 467 + bnx2i_percpu_thread_create(cpu); 468 + return 0; 489 469 } 490 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; 491 479 492 480 /** 493 481 * bnx2i_mod_init - module init entry point ··· 511 539 p->iothread = NULL; 512 540 } 513 541 514 - cpu_notifier_register_begin(); 542 + get_online_cpus(); 515 543 516 544 for_each_online_cpu(cpu) 517 545 bnx2i_percpu_thread_create(cpu); 518 546 519 - /* Initialize per CPU interrupt thread */ 520 - __register_hotcpu_notifier(&bnx2i_cpu_notifier); 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; 521 553 522 - cpu_notifier_register_done(); 523 - 554 + cpuhp_setup_state_nocalls(CPUHP_SCSI_BNX2I_DEAD, "scsi/bnx2i:dead", 555 + NULL, bnx2i_cpu_dead); 556 + put_online_cpus(); 524 557 return 0; 525 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); 526 564 unreg_xport: 527 565 iscsi_unregister_transport(&bnx2i_iscsi_transport); 528 566 out: ··· 569 587 } 570 588 mutex_unlock(&bnx2i_dev_lock); 571 589 572 - cpu_notifier_register_begin(); 590 + get_online_cpus(); 573 591 574 592 for_each_online_cpu(cpu) 575 593 bnx2i_percpu_thread_destroy(cpu); 576 594 577 - __unregister_hotcpu_notifier(&bnx2i_cpu_notifier); 578 - 579 - cpu_notifier_register_done(); 595 + cpuhp_remove_state_nocalls(bnx2i_online_state); 596 + cpuhp_remove_state_nocalls(CPUHP_SCSI_BNX2I_DEAD); 597 + put_online_cpus(); 580 598 581 599 iscsi_unregister_transport(&bnx2i_iscsi_transport); 582 600 cnic_unregister_driver(CNIC_ULP_ISCSI);
+1
include/linux/cpuhotplug.h
··· 42 42 CPUHP_PCI_XGENE_DEAD, 43 43 CPUHP_IOMMU_INTEL_DEAD, 44 44 CPUHP_SCSI_BNX2FC_DEAD, 45 + CPUHP_SCSI_BNX2I_DEAD, 45 46 CPUHP_WORKQUEUE_PREP, 46 47 CPUHP_POWER_NUMA_PREPARE, 47 48 CPUHP_HRTIMERS_PREPARE,