aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGregory CLEMENT <gregory.clement@free-electrons.com>2014-10-30 07:39:44 -0400
committerJason Cooper <jason@lakedaemon.net>2014-11-21 21:14:38 -0500
commit626d686487bfd8136c4543bee7b6b2e52c33b3f8 (patch)
tree617c305f570d0d3f9550709e1acb6884824d5be5
parentf5789cbb22a01c0750d12cb54c4bbd416e04f7ff (diff)
ARM: mvebu: Implement the CPU hotplug support for the Armada 38x SoCs
This commit implements the CPU hotplug support for the Marvell Armada 38x platform. Similarly to what was done for the Armada XP, this commit: * Implements the ->cpu_die() function of SMP operations by calling armada_38x_do_cpu_suspend() to enter the deep idle state for CPUs going offline. * Implements a dummy ->cpu_kill() function, simply needed for the kernel to know we have CPU hotplug support. * The mvebu_cortex_a9_boot_secondary() function makes sure to wake up the CPU if waiting in deep idle state by sending an IPI before deasserting the CPUs from reset. This is because mvebu_cortex_a9_boot_secondary() is now used in two different situations: for the initial boot of secondary CPUs (where CPU reset deassert is used to wake up CPUs) and for CPU hotplug (where an IPI is used to take CPU out of deep idle). * At boot time, we exit from the idle state in the ->smp_secondary_init() hook. This commit has been tested using CPU hotplug through sysfs (/sys/devices/system/cpu/cpuX/online) and using kexec. Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com> Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Reviewed-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Link: https://lkml.kernel.org/r/1414669184-16785-5-git-send-email-gregory.clement@free-electrons.com Signed-off-by: Jason Cooper <jason@lakedaemon.net>
-rw-r--r--arch/arm/mach-mvebu/platsmp-a9.c53
-rw-r--r--arch/arm/mach-mvebu/pmsu.c2
-rw-r--r--arch/arm/mach-mvebu/pmsu.h1
3 files changed, 53 insertions, 3 deletions
diff --git a/arch/arm/mach-mvebu/platsmp-a9.c b/arch/arm/mach-mvebu/platsmp-a9.c
index 47a71a924b96..2ec1a42b4321 100644
--- a/arch/arm/mach-mvebu/platsmp-a9.c
+++ b/arch/arm/mach-mvebu/platsmp-a9.c
@@ -43,21 +43,70 @@ static int __cpuinit mvebu_cortex_a9_boot_secondary(unsigned int cpu,
43 else 43 else
44 mvebu_pmsu_set_cpu_boot_addr(hw_cpu, mvebu_cortex_a9_secondary_startup); 44 mvebu_pmsu_set_cpu_boot_addr(hw_cpu, mvebu_cortex_a9_secondary_startup);
45 smp_wmb(); 45 smp_wmb();
46
47 /*
48 * Doing this before deasserting the CPUs is needed to wake up CPUs
49 * in the offline state after using CPU hotplug.
50 */
51 arch_send_wakeup_ipi_mask(cpumask_of(cpu));
52
46 ret = mvebu_cpu_reset_deassert(hw_cpu); 53 ret = mvebu_cpu_reset_deassert(hw_cpu);
47 if (ret) { 54 if (ret) {
48 pr_err("Could not start the secondary CPU: %d\n", ret); 55 pr_err("Could not start the secondary CPU: %d\n", ret);
49 return ret; 56 return ret;
50 } 57 }
51 arch_send_wakeup_ipi_mask(cpumask_of(cpu));
52 58
53 return 0; 59 return 0;
54} 60}
61/*
62 * When a CPU is brought back online, either through CPU hotplug, or
63 * because of the boot of a kexec'ed kernel, the PMSU configuration
64 * for this CPU might be in the deep idle state, preventing this CPU
65 * from receiving interrupts. Here, we therefore take out the current
66 * CPU from this state, which was entered by armada_38x_cpu_die()
67 * below.
68 */
69static void armada_38x_secondary_init(unsigned int cpu)
70{
71 mvebu_v7_pmsu_idle_exit();
72}
73
74#ifdef CONFIG_HOTPLUG_CPU
75static void armada_38x_cpu_die(unsigned int cpu)
76{
77 /*
78 * CPU hotplug is implemented by putting offline CPUs into the
79 * deep idle sleep state.
80 */
81 armada_38x_do_cpu_suspend(true);
82}
83
84/*
85 * We need a dummy function, so that platform_can_cpu_hotplug() knows
86 * we support CPU hotplug. However, the function does not need to do
87 * anything, because CPUs going offline can enter the deep idle state
88 * by themselves, without any help from a still alive CPU.
89 */
90static int armada_38x_cpu_kill(unsigned int cpu)
91{
92 return 1;
93}
94#endif
55 95
56static struct smp_operations mvebu_cortex_a9_smp_ops __initdata = { 96static struct smp_operations mvebu_cortex_a9_smp_ops __initdata = {
57 .smp_boot_secondary = mvebu_cortex_a9_boot_secondary, 97 .smp_boot_secondary = mvebu_cortex_a9_boot_secondary,
58}; 98};
59 99
100static struct smp_operations armada_38x_smp_ops __initdata = {
101 .smp_boot_secondary = mvebu_cortex_a9_boot_secondary,
102 .smp_secondary_init = armada_38x_secondary_init,
103#ifdef CONFIG_HOTPLUG_CPU
104 .cpu_die = armada_38x_cpu_die,
105 .cpu_kill = armada_38x_cpu_kill,
106#endif
107};
108
60CPU_METHOD_OF_DECLARE(mvebu_armada_375_smp, "marvell,armada-375-smp", 109CPU_METHOD_OF_DECLARE(mvebu_armada_375_smp, "marvell,armada-375-smp",
61 &mvebu_cortex_a9_smp_ops); 110 &mvebu_cortex_a9_smp_ops);
62CPU_METHOD_OF_DECLARE(mvebu_armada_380_smp, "marvell,armada-380-smp", 111CPU_METHOD_OF_DECLARE(mvebu_armada_380_smp, "marvell,armada-380-smp",
63 &mvebu_cortex_a9_smp_ops); 112 &armada_38x_smp_ops);
diff --git a/arch/arm/mach-mvebu/pmsu.c b/arch/arm/mach-mvebu/pmsu.c
index 5af58927a56d..5a757f929927 100644
--- a/arch/arm/mach-mvebu/pmsu.c
+++ b/arch/arm/mach-mvebu/pmsu.c
@@ -311,7 +311,7 @@ static int armada_370_xp_cpu_suspend(unsigned long deepidle)
311 return cpu_suspend(deepidle, armada_370_xp_pmsu_idle_enter); 311 return cpu_suspend(deepidle, armada_370_xp_pmsu_idle_enter);
312} 312}
313 313
314static int armada_38x_do_cpu_suspend(unsigned long deepidle) 314int armada_38x_do_cpu_suspend(unsigned long deepidle)
315{ 315{
316 unsigned long flags = 0; 316 unsigned long flags = 0;
317 317
diff --git a/arch/arm/mach-mvebu/pmsu.h b/arch/arm/mach-mvebu/pmsu.h
index e1eb4959a2d4..c2c95db4f648 100644
--- a/arch/arm/mach-mvebu/pmsu.h
+++ b/arch/arm/mach-mvebu/pmsu.h
@@ -19,4 +19,5 @@ int mvebu_setup_boot_addr_wa(unsigned int crypto_eng_target,
19void mvebu_v7_pmsu_idle_exit(void); 19void mvebu_v7_pmsu_idle_exit(void);
20 20
21int armada_370_xp_pmsu_idle_enter(unsigned long deepidle); 21int armada_370_xp_pmsu_idle_enter(unsigned long deepidle);
22int armada_38x_do_cpu_suspend(unsigned long deepidle);
22#endif /* __MACH_370_XP_PMSU_H */ 23#endif /* __MACH_370_XP_PMSU_H */