aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2016-08-18 08:57:30 -0400
committerThomas Gleixner <tglx@linutronix.de>2016-09-06 12:30:26 -0400
commit68e694dcef246f0c8f6738b3aa628f8aa7186796 (patch)
tree6a158613861bf87aa31c13a23da52f7537f746c4
parent9a20ea4b4c34764416e935090d6e5ede02d1bada (diff)
powerpc/powermac: Convert to hotplug state machine
Install the callbacks via the state machine. I assume here that the powermac has two CPUs and so only one can go up or down at a time. The variable smp_core99_host_open is here to ensure that we do not try to open or close the i2c host twice if something goes wrong and we invoke the prepare or online callback twice due to rollback. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: rt@linutronix.de Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: linuxppc-dev@lists.ozlabs.org Link: http://lkml.kernel.org/r/20160818125731.27256-16-bigeasy@linutronix.de Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--arch/powerpc/platforms/powermac/smp.c50
-rw-r--r--include/linux/cpuhotplug.h1
2 files changed, 26 insertions, 25 deletions
diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
index 834868b9fdc9..366e4f510fcf 100644
--- a/arch/powerpc/platforms/powermac/smp.c
+++ b/arch/powerpc/platforms/powermac/smp.c
@@ -852,37 +852,33 @@ static void smp_core99_setup_cpu(int cpu_nr)
852 852
853#ifdef CONFIG_PPC64 853#ifdef CONFIG_PPC64
854#ifdef CONFIG_HOTPLUG_CPU 854#ifdef CONFIG_HOTPLUG_CPU
855static int smp_core99_cpu_notify(struct notifier_block *self, 855static unsigned int smp_core99_host_open;
856 unsigned long action, void *hcpu) 856
857static int smp_core99_cpu_prepare(unsigned int cpu)
857{ 858{
858 int rc; 859 int rc;
859 860
860 switch(action & ~CPU_TASKS_FROZEN) { 861 /* Open i2c bus if it was used for tb sync */
861 case CPU_UP_PREPARE: 862 if (pmac_tb_clock_chip_host && !smp_core99_host_open) {
862 /* Open i2c bus if it was used for tb sync */ 863 rc = pmac_i2c_open(pmac_tb_clock_chip_host, 1);
863 if (pmac_tb_clock_chip_host) { 864 if (rc) {
864 rc = pmac_i2c_open(pmac_tb_clock_chip_host, 1); 865 pr_err("Failed to open i2c bus for time sync\n");
865 if (rc) { 866 return notifier_from_errno(rc);
866 pr_err("Failed to open i2c bus for time sync\n");
867 return notifier_from_errno(rc);
868 }
869 } 867 }
870 break; 868 smp_core99_host_open = 1;
871 case CPU_ONLINE:
872 case CPU_UP_CANCELED:
873 /* Close i2c bus if it was used for tb sync */
874 if (pmac_tb_clock_chip_host)
875 pmac_i2c_close(pmac_tb_clock_chip_host);
876 break;
877 default:
878 break;
879 } 869 }
880 return NOTIFY_OK; 870 return 0;
881} 871}
882 872
883static struct notifier_block smp_core99_cpu_nb = { 873static int smp_core99_cpu_online(unsigned int cpu)
884 .notifier_call = smp_core99_cpu_notify, 874{
885}; 875 /* Close i2c bus if it was used for tb sync */
876 if (pmac_tb_clock_chip_host && smp_core99_host_open) {
877 pmac_i2c_close(pmac_tb_clock_chip_host);
878 smp_core99_host_open = 0;
879 }
880 return 0;
881}
886#endif /* CONFIG_HOTPLUG_CPU */ 882#endif /* CONFIG_HOTPLUG_CPU */
887 883
888static void __init smp_core99_bringup_done(void) 884static void __init smp_core99_bringup_done(void)
@@ -902,7 +898,11 @@ static void __init smp_core99_bringup_done(void)
902 g5_phy_disable_cpu1(); 898 g5_phy_disable_cpu1();
903 } 899 }
904#ifdef CONFIG_HOTPLUG_CPU 900#ifdef CONFIG_HOTPLUG_CPU
905 register_cpu_notifier(&smp_core99_cpu_nb); 901 cpuhp_setup_state_nocalls(CPUHP_POWERPC_PMAC_PREPARE,
902 "powerpc/pmac:prepare", smp_core99_cpu_prepare,
903 NULL);
904 cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "powerpc/pmac:online",
905 smp_core99_cpu_online, NULL);
906#endif 906#endif
907 907
908 if (ppc_md.progress) 908 if (ppc_md.progress)
diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
index e8608774b5da..33fba43ad292 100644
--- a/include/linux/cpuhotplug.h
+++ b/include/linux/cpuhotplug.h
@@ -31,6 +31,7 @@ enum cpuhp_state {
31 CPUHP_MD_RAID5_PREPARE, 31 CPUHP_MD_RAID5_PREPARE,
32 CPUHP_RCUTREE_PREP, 32 CPUHP_RCUTREE_PREP,
33 CPUHP_CPUIDLE_COUPLED_PREPARE, 33 CPUHP_CPUIDLE_COUPLED_PREPARE,
34 CPUHP_POWERPC_PMAC_PREPARE,
34 CPUHP_NOTIFY_PREPARE, 35 CPUHP_NOTIFY_PREPARE,
35 CPUHP_TIMERS_DEAD, 36 CPUHP_TIMERS_DEAD,
36 CPUHP_BRINGUP_CPU, 37 CPUHP_BRINGUP_CPU,