Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

MIPS/BUS/CDMM: Convert to hotplug state machine

Install the callbacks via the state machine and let the core invoke
the callbacks on the already online CPUs.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20160818125731.27256-14-bigeasy@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Sebastian Andrzej Siewior and committed by
Thomas Gleixner
e8483b57 dfc616d8

+12 -58
+12 -58
drivers/bus/mips_cdmm.c
··· 596 596 BUILD_PERDEV_HELPER(cpu_up) /* int mips_cdmm_cpu_up_helper(...) */ 597 597 598 598 /** 599 - * mips_cdmm_bus_down() - Tear down the CDMM bus. 600 - * @data: Pointer to unsigned int CPU number. 599 + * mips_cdmm_cpu_down_prep() - Callback for CPUHP DOWN_PREP: 600 + * Tear down the CDMM bus. 601 + * @cpu: unsigned int CPU number. 601 602 * 602 603 * This function is executed on the hotplugged CPU and calls the CDMM 603 604 * driver cpu_down callback for all devices on that CPU. 604 605 */ 605 - static long mips_cdmm_bus_down(void *data) 606 + static int mips_cdmm_cpu_down_prep(unsigned int cpu) 606 607 { 607 608 struct mips_cdmm_bus *bus; 608 609 long ret; 609 610 610 611 /* Inform all the devices on the bus */ 611 - ret = bus_for_each_dev(&mips_cdmm_bustype, NULL, data, 612 + ret = bus_for_each_dev(&mips_cdmm_bustype, NULL, &cpu, 612 613 mips_cdmm_cpu_down_helper); 613 614 614 615 /* ··· 624 623 } 625 624 626 625 /** 627 - * mips_cdmm_bus_up() - Bring up the CDMM bus. 628 - * @data: Pointer to unsigned int CPU number. 626 + * mips_cdmm_cpu_online() - Callback for CPUHP ONLINE: Bring up the CDMM bus. 627 + * @cpu: unsigned int CPU number. 629 628 * 630 629 * This work_on_cpu callback function is executed on a given CPU to discover 631 630 * CDMM devices on that CPU, or to call the CDMM driver cpu_up callback for all ··· 635 634 * initialisation. When CPUs are brought online the function is 636 635 * invoked directly on the hotplugged CPU. 637 636 */ 638 - static long mips_cdmm_bus_up(void *data) 637 + static int mips_cdmm_cpu_online(unsigned int cpu) 639 638 { 640 639 struct mips_cdmm_bus *bus; 641 640 long ret; ··· 652 651 mips_cdmm_bus_discover(bus); 653 652 else 654 653 /* Inform all the devices on the bus */ 655 - ret = bus_for_each_dev(&mips_cdmm_bustype, NULL, data, 654 + ret = bus_for_each_dev(&mips_cdmm_bustype, NULL, &cpu, 656 655 mips_cdmm_cpu_up_helper); 657 656 658 657 return ret; 659 658 } 660 - 661 - /** 662 - * mips_cdmm_cpu_notify() - Take action when a CPU is going online or offline. 663 - * @nb: CPU notifier block . 664 - * @action: Event that has taken place (CPU_*). 665 - * @data: CPU number. 666 - * 667 - * This notifier is used to keep the CDMM buses updated as CPUs are offlined and 668 - * onlined. When CPUs go offline or come back online, so does their CDMM bus, so 669 - * devices must be informed. Also when CPUs come online for the first time the 670 - * devices on the CDMM bus need discovering. 671 - * 672 - * Returns: NOTIFY_OK if event was used. 673 - * NOTIFY_DONE if we didn't care. 674 - */ 675 - static int mips_cdmm_cpu_notify(struct notifier_block *nb, 676 - unsigned long action, void *data) 677 - { 678 - unsigned int cpu = (unsigned int)data; 679 - 680 - switch (action & ~CPU_TASKS_FROZEN) { 681 - case CPU_ONLINE: 682 - case CPU_DOWN_FAILED: 683 - mips_cdmm_bus_up(&cpu); 684 - break; 685 - case CPU_DOWN_PREPARE: 686 - mips_cdmm_bus_down(&cpu); 687 - break; 688 - default: 689 - return NOTIFY_DONE; 690 - } 691 - 692 - return NOTIFY_OK; 693 - } 694 - 695 - static struct notifier_block mips_cdmm_cpu_nb = { 696 - .notifier_call = mips_cdmm_cpu_notify, 697 - }; 698 659 699 660 /** 700 661 * mips_cdmm_init() - Initialise CDMM bus. ··· 666 703 */ 667 704 static int __init mips_cdmm_init(void) 668 705 { 669 - unsigned int cpu; 670 706 int ret; 671 707 672 708 /* Register the bus */ ··· 674 712 return ret; 675 713 676 714 /* We want to be notified about new CPUs */ 677 - ret = register_cpu_notifier(&mips_cdmm_cpu_nb); 678 - if (ret) { 715 + ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "bus/cdmm:online", 716 + mips_cdmm_cpu_online, mips_cdmm_cpu_down_prep); 717 + if (ret < 0) 679 718 pr_warn("cdmm: Failed to register CPU notifier\n"); 680 - goto out; 681 - } 682 719 683 - /* Discover devices on CDMM of online CPUs */ 684 - for_each_online_cpu(cpu) 685 - work_on_cpu(cpu, mips_cdmm_bus_up, &cpu); 686 - 687 - return 0; 688 - out: 689 - bus_unregister(&mips_cdmm_bustype); 690 720 return ret; 691 721 } 692 722 subsys_initcall(mips_cdmm_init);