aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/kernel
diff options
context:
space:
mode:
authorMark Rutland <mark.rutland@arm.com>2013-10-24 15:30:17 -0400
committerCatalin Marinas <catalin.marinas@arm.com>2013-10-25 06:33:20 -0400
commite8765b265a69c83504afc6901d6e137b1811d1f0 (patch)
tree906c836879d4994ca6abd5e87a5f175d81020697 /arch/arm64/kernel
parent652af899799354049b273af897b798b8f03fdd88 (diff)
arm64: read enable-method for CPU0
With the advent of CPU_HOTPLUG, the enable-method property for CPU0 may tells us something useful (i.e. how to hotplug it back on), so we must read it along with all the enable-method for all the other CPUs. Even on UP the enable-method may tell us useful information (e.g. if a core has some mechanism that might be usable for cpuidle), so we should always read it. This patch factors out the reading of the enable method, and ensures that CPU0's enable method is read regardless of whether the kernel is built with SMP support. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm64/kernel')
-rw-r--r--arch/arm64/kernel/cpu_ops.c54
-rw-r--r--arch/arm64/kernel/setup.c2
-rw-r--r--arch/arm64/kernel/smp.c18
3 files changed, 56 insertions, 18 deletions
diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c
index e2652aadd9ea..aa0c9e78dbe1 100644
--- a/arch/arm64/kernel/cpu_ops.c
+++ b/arch/arm64/kernel/cpu_ops.c
@@ -17,6 +17,9 @@
17 */ 17 */
18 18
19#include <asm/cpu_ops.h> 19#include <asm/cpu_ops.h>
20#include <asm/smp_plat.h>
21#include <linux/errno.h>
22#include <linux/of.h>
20#include <linux/string.h> 23#include <linux/string.h>
21 24
22extern const struct cpu_operations smp_spin_table_ops; 25extern const struct cpu_operations smp_spin_table_ops;
@@ -32,7 +35,7 @@ static const struct cpu_operations *supported_cpu_ops[] __initconst = {
32 NULL, 35 NULL,
33}; 36};
34 37
35const struct cpu_operations * __init cpu_get_ops(const char *name) 38static const struct cpu_operations * __init cpu_get_ops(const char *name)
36{ 39{
37 const struct cpu_operations **ops = supported_cpu_ops; 40 const struct cpu_operations **ops = supported_cpu_ops;
38 41
@@ -45,3 +48,52 @@ const struct cpu_operations * __init cpu_get_ops(const char *name)
45 48
46 return NULL; 49 return NULL;
47} 50}
51
52/*
53 * Read a cpu's enable method from the device tree and record it in cpu_ops.
54 */
55int __init cpu_read_ops(struct device_node *dn, int cpu)
56{
57 const char *enable_method = of_get_property(dn, "enable-method", NULL);
58 if (!enable_method) {
59 /*
60 * The boot CPU may not have an enable method (e.g. when
61 * spin-table is used for secondaries). Don't warn spuriously.
62 */
63 if (cpu != 0)
64 pr_err("%s: missing enable-method property\n",
65 dn->full_name);
66 return -ENOENT;
67 }
68
69 cpu_ops[cpu] = cpu_get_ops(enable_method);
70 if (!cpu_ops[cpu]) {
71 pr_err("%s: invalid enable-method property: %s\n",
72 dn->full_name, enable_method);
73 return -EOPNOTSUPP;
74 }
75
76 return 0;
77}
78
79void __init cpu_read_bootcpu_ops(void)
80{
81 struct device_node *dn = NULL;
82 u64 mpidr = cpu_logical_map(0);
83
84 while ((dn = of_find_node_by_type(dn, "cpu"))) {
85 u64 hwid;
86 const __be32 *prop;
87
88 prop = of_get_property(dn, "reg", NULL);
89 if (!prop)
90 continue;
91
92 hwid = of_read_number(prop, of_n_addr_cells(dn));
93 if (hwid == mpidr) {
94 cpu_read_ops(dn, 0);
95 of_node_put(dn);
96 return;
97 }
98 }
99}
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 055cfb80e05c..b65c132fac30 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -45,6 +45,7 @@
45#include <asm/cputype.h> 45#include <asm/cputype.h>
46#include <asm/elf.h> 46#include <asm/elf.h>
47#include <asm/cputable.h> 47#include <asm/cputable.h>
48#include <asm/cpu_ops.h>
48#include <asm/sections.h> 49#include <asm/sections.h>
49#include <asm/setup.h> 50#include <asm/setup.h>
50#include <asm/smp_plat.h> 51#include <asm/smp_plat.h>
@@ -264,6 +265,7 @@ void __init setup_arch(char **cmdline_p)
264 psci_init(); 265 psci_init();
265 266
266 cpu_logical_map(0) = read_cpuid_mpidr() & MPIDR_HWID_BITMASK; 267 cpu_logical_map(0) = read_cpuid_mpidr() & MPIDR_HWID_BITMASK;
268 cpu_read_bootcpu_ops();
267#ifdef CONFIG_SMP 269#ifdef CONFIG_SMP
268 smp_init_cpus(); 270 smp_init_cpus();
269#endif 271#endif
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 6806bc40b630..e992734d21ec 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -185,7 +185,6 @@ static void (*smp_cross_call)(const struct cpumask *, unsigned int);
185 */ 185 */
186void __init smp_init_cpus(void) 186void __init smp_init_cpus(void)
187{ 187{
188 const char *enable_method;
189 struct device_node *dn = NULL; 188 struct device_node *dn = NULL;
190 unsigned int i, cpu = 1; 189 unsigned int i, cpu = 1;
191 bool bootcpu_valid = false; 190 bool bootcpu_valid = false;
@@ -256,23 +255,8 @@ void __init smp_init_cpus(void)
256 if (cpu >= NR_CPUS) 255 if (cpu >= NR_CPUS)
257 goto next; 256 goto next;
258 257
259 /* 258 if (cpu_read_ops(dn, cpu) != 0)
260 * We currently support only the "spin-table" enable-method.
261 */
262 enable_method = of_get_property(dn, "enable-method", NULL);
263 if (!enable_method) {
264 pr_err("%s: missing enable-method property\n",
265 dn->full_name);
266 goto next; 259 goto next;
267 }
268
269 cpu_ops[cpu] = cpu_get_ops(enable_method);
270
271 if (!cpu_ops[cpu]) {
272 pr_err("%s: invalid enable-method property: %s\n",
273 dn->full_name, enable_method);
274 goto next;
275 }
276 260
277 if (cpu_ops[cpu]->cpu_init(dn, cpu)) 261 if (cpu_ops[cpu]->cpu_init(dn, cpu))
278 goto next; 262 goto next;