1 From 48f17325fef9cbebc5cb39aa78f4c1caff5d7b16 Mon Sep 17 00:00:00 2001
2 From: Stephen Boyd <sboyd@codeaurora.org>
3 Date: Wed, 30 Oct 2013 18:21:09 -0700
4 Subject: [PATCH 008/182] ARM: Introduce CPU_METHOD_OF_DECLARE() for cpu
7 The goal of multi-platform kernels is to remove the need for mach
8 directories and machine descriptors. To further that goal,
9 introduce CPU_METHOD_OF_DECLARE() to allow cpu hotplug/smp
10 support to be separated from the machine descriptors.
11 Implementers should specify an enable-method property in their
12 cpus node and then implement a matching set of smp_ops in their
13 hotplug/smp code, wiring it up with the CPU_METHOD_OF_DECLARE()
14 macro. When the kernel is compiled we'll collect all the
15 enable-method smp_ops into one section for use at boot.
17 At boot time we'll look for an enable-method in each cpu node and
18 try to match that against all known CPU enable methods in the
19 kernel. If there are no enable-methods in the cpu nodes we
20 fallback to the cpus node and try to use any enable-method found
21 there. If that doesn't work we fall back to the old way of using
22 the machine descriptor.
24 Acked-by: Mark Rutland <mark.rutland@arm.com>
25 Cc: Russell King <linux@arm.linux.org.uk>
26 Cc: <devicetree@vger.kernel.org>
27 Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
28 Signed-off-by: Kumar Gala <galak@codeaurora.org>
30 arch/arm/include/asm/smp.h | 9 +++++++++
31 arch/arm/kernel/devtree.c | 40 +++++++++++++++++++++++++++++++++++++
32 include/asm-generic/vmlinux.lds.h | 10 ++++++++++
33 3 files changed, 59 insertions(+)
35 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
36 index 22a3b9b..772435b 100644
37 --- a/arch/arm/include/asm/smp.h
38 +++ b/arch/arm/include/asm/smp.h
39 @@ -114,6 +114,15 @@ struct smp_operations {
43 +struct of_cpu_method {
45 + struct smp_operations *ops;
48 +#define CPU_METHOD_OF_DECLARE(name, _method, _ops) \
49 + static const struct of_cpu_method __cpu_method_of_table_##name \
50 + __used __section(__cpu_method_of_table) \
51 + = { .method = _method, .ops = _ops }
53 * set platform specific SMP operations
55 diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
56 index f751714..c7419a5 100644
57 --- a/arch/arm/kernel/devtree.c
58 +++ b/arch/arm/kernel/devtree.c
60 #include <linux/of_fdt.h>
61 #include <linux/of_irq.h>
62 #include <linux/of_platform.h>
63 +#include <linux/smp.h>
65 #include <asm/cputype.h>
66 #include <asm/setup.h>
67 @@ -63,6 +64,34 @@ void __init arm_dt_memblock_reserve(void)
72 +extern struct of_cpu_method __cpu_method_of_table_begin[];
73 +extern struct of_cpu_method __cpu_method_of_table_end[];
75 +static int __init set_smp_ops_by_method(struct device_node *node)
78 + struct of_cpu_method *m = __cpu_method_of_table_begin;
80 + if (of_property_read_string(node, "enable-method", &method))
83 + for (; m < __cpu_method_of_table_end; m++)
84 + if (!strcmp(m->method, method)) {
85 + smp_set_ops(m->ops);
92 +static inline int set_smp_ops_by_method(struct device_node *node)
100 * arm_dt_init_cpu_maps - Function retrieves cpu nodes from the device tree
101 * and builds the cpu logical map array containing MPIDR values related to
102 @@ -79,6 +108,7 @@ void __init arm_dt_init_cpu_maps(void)
105 struct device_node *cpu, *cpus;
106 + int found_method = 0;
107 u32 i, j, cpuidx = 1;
108 u32 mpidr = is_smp() ? read_cpuid_mpidr() & MPIDR_HWID_BITMASK : 0;
110 @@ -150,8 +180,18 @@ void __init arm_dt_init_cpu_maps(void)
116 + found_method = set_smp_ops_by_method(cpu);
120 + * Fallback to an enable-method in the cpus node if nothing found in
124 + set_smp_ops_by_method(cpus);
126 if (!bootcpu_valid) {
127 pr_warn("DT missing boot CPU MPIDR[23:0], fall back to default cpu_logical_map\n");
129 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
130 index bc2121f..bd02ca7 100644
131 --- a/include/asm-generic/vmlinux.lds.h
132 +++ b/include/asm-generic/vmlinux.lds.h
134 #define CLK_OF_TABLES()
138 +#define CPU_METHOD_OF_TABLES() . = ALIGN(8); \
139 + VMLINUX_SYMBOL(__cpu_method_of_table_begin) = .; \
140 + *(__cpu_method_of_table) \
141 + VMLINUX_SYMBOL(__cpu_method_of_table_end) = .;
143 +#define CPU_METHOD_OF_TABLES()
146 #define KERNEL_DTB() \
148 VMLINUX_SYMBOL(__dtb_start) = .; \
150 MEM_DISCARD(init.rodata) \
153 + CPU_METHOD_OF_TABLES() \
155 IRQCHIP_OF_MATCH_TABLE()