aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@codeaurora.org>2013-10-30 21:21:09 -0400
committerKumar Gala <galak@codeaurora.org>2014-02-11 16:00:37 -0500
commit6c3ff8b11a16ec69199ab85b74a5fae6d9c59db7 (patch)
tree79bf0dffed2a312578dd2a75048f6d65d21a6e8d
parentcf1e8f0cd665e2a9966d2bee4e11ecc0938ff166 (diff)
ARM: Introduce CPU_METHOD_OF_DECLARE() for cpu hotplug/smp
The goal of multi-platform kernels is to remove the need for mach directories and machine descriptors. To further that goal, introduce CPU_METHOD_OF_DECLARE() to allow cpu hotplug/smp support to be separated from the machine descriptors. Implementers should specify an enable-method property in their cpus node and then implement a matching set of smp_ops in their hotplug/smp code, wiring it up with the CPU_METHOD_OF_DECLARE() macro. When the kernel is compiled we'll collect all the enable-method smp_ops into one section for use at boot. At boot time we'll look for an enable-method in each cpu node and try to match that against all known CPU enable methods in the kernel. If there are no enable-methods in the cpu nodes we fallback to the cpus node and try to use any enable-method found there. If that doesn't work we fall back to the old way of using the machine descriptor. Acked-by: Mark Rutland <mark.rutland@arm.com> Cc: Russell King <linux@arm.linux.org.uk> Cc: <devicetree@vger.kernel.org> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Kumar Gala <galak@codeaurora.org>
-rw-r--r--arch/arm/include/asm/smp.h9
-rw-r--r--arch/arm/kernel/devtree.c40
-rw-r--r--include/asm-generic/vmlinux.lds.h10
3 files changed, 59 insertions, 0 deletions
diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
index 22a3b9b5d4a1..772435b08207 100644
--- a/arch/arm/include/asm/smp.h
+++ b/arch/arm/include/asm/smp.h
@@ -114,6 +114,15 @@ struct smp_operations {
114#endif 114#endif
115}; 115};
116 116
117struct of_cpu_method {
118 const char *method;
119 struct smp_operations *ops;
120};
121
122#define CPU_METHOD_OF_DECLARE(name, _method, _ops) \
123 static const struct of_cpu_method __cpu_method_of_table_##name \
124 __used __section(__cpu_method_of_table) \
125 = { .method = _method, .ops = _ops }
117/* 126/*
118 * set platform specific SMP operations 127 * set platform specific SMP operations
119 */ 128 */
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index f751714d52c1..c7419a585ddc 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -18,6 +18,7 @@
18#include <linux/of_fdt.h> 18#include <linux/of_fdt.h>
19#include <linux/of_irq.h> 19#include <linux/of_irq.h>
20#include <linux/of_platform.h> 20#include <linux/of_platform.h>
21#include <linux/smp.h>
21 22
22#include <asm/cputype.h> 23#include <asm/cputype.h>
23#include <asm/setup.h> 24#include <asm/setup.h>
@@ -63,6 +64,34 @@ void __init arm_dt_memblock_reserve(void)
63 } 64 }
64} 65}
65 66
67#ifdef CONFIG_SMP
68extern struct of_cpu_method __cpu_method_of_table_begin[];
69extern struct of_cpu_method __cpu_method_of_table_end[];
70
71static int __init set_smp_ops_by_method(struct device_node *node)
72{
73 const char *method;
74 struct of_cpu_method *m = __cpu_method_of_table_begin;
75
76 if (of_property_read_string(node, "enable-method", &method))
77 return 0;
78
79 for (; m < __cpu_method_of_table_end; m++)
80 if (!strcmp(m->method, method)) {
81 smp_set_ops(m->ops);
82 return 1;
83 }
84
85 return 0;
86}
87#else
88static inline int set_smp_ops_by_method(struct device_node *node)
89{
90 return 1;
91}
92#endif
93
94
66/* 95/*
67 * arm_dt_init_cpu_maps - Function retrieves cpu nodes from the device tree 96 * arm_dt_init_cpu_maps - Function retrieves cpu nodes from the device tree
68 * and builds the cpu logical map array containing MPIDR values related to 97 * and builds the cpu logical map array containing MPIDR values related to
@@ -79,6 +108,7 @@ void __init arm_dt_init_cpu_maps(void)
79 * read as 0. 108 * read as 0.
80 */ 109 */
81 struct device_node *cpu, *cpus; 110 struct device_node *cpu, *cpus;
111 int found_method = 0;
82 u32 i, j, cpuidx = 1; 112 u32 i, j, cpuidx = 1;
83 u32 mpidr = is_smp() ? read_cpuid_mpidr() & MPIDR_HWID_BITMASK : 0; 113 u32 mpidr = is_smp() ? read_cpuid_mpidr() & MPIDR_HWID_BITMASK : 0;
84 114
@@ -150,8 +180,18 @@ void __init arm_dt_init_cpu_maps(void)
150 } 180 }
151 181
152 tmp_map[i] = hwid; 182 tmp_map[i] = hwid;
183
184 if (!found_method)
185 found_method = set_smp_ops_by_method(cpu);
153 } 186 }
154 187
188 /*
189 * Fallback to an enable-method in the cpus node if nothing found in
190 * a cpu node.
191 */
192 if (!found_method)
193 set_smp_ops_by_method(cpus);
194
155 if (!bootcpu_valid) { 195 if (!bootcpu_valid) {
156 pr_warn("DT missing boot CPU MPIDR[23:0], fall back to default cpu_logical_map\n"); 196 pr_warn("DT missing boot CPU MPIDR[23:0], fall back to default cpu_logical_map\n");
157 return; 197 return;
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index bc2121fa9132..bd02ca7a1d55 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -167,6 +167,15 @@
167#define CLK_OF_TABLES() 167#define CLK_OF_TABLES()
168#endif 168#endif
169 169
170#ifdef CONFIG_SMP
171#define CPU_METHOD_OF_TABLES() . = ALIGN(8); \
172 VMLINUX_SYMBOL(__cpu_method_of_table_begin) = .; \
173 *(__cpu_method_of_table) \
174 VMLINUX_SYMBOL(__cpu_method_of_table_end) = .;
175#else
176#define CPU_METHOD_OF_TABLES()
177#endif
178
170#define KERNEL_DTB() \ 179#define KERNEL_DTB() \
171 STRUCT_ALIGN(); \ 180 STRUCT_ALIGN(); \
172 VMLINUX_SYMBOL(__dtb_start) = .; \ 181 VMLINUX_SYMBOL(__dtb_start) = .; \
@@ -491,6 +500,7 @@
491 MEM_DISCARD(init.rodata) \ 500 MEM_DISCARD(init.rodata) \
492 CLK_OF_TABLES() \ 501 CLK_OF_TABLES() \
493 CLKSRC_OF_TABLES() \ 502 CLKSRC_OF_TABLES() \
503 CPU_METHOD_OF_TABLES() \
494 KERNEL_DTB() \ 504 KERNEL_DTB() \
495 IRQCHIP_OF_MATCH_TABLE() 505 IRQCHIP_OF_MATCH_TABLE()
496 506