From 9e4914e8682dda16acb5eae9ba56f28c9e229320 Mon Sep 17 00:00:00 2001 From: Abhimanyu Kapur Date: Thu, 23 Jan 2014 12:24:33 -0800 Subject: [PATCH] arm64: introduce CPU_OF_TABLES for cpu ops selection Add support to arm64 to provide a dt-based method to allow soc-vendors to supply cpu_ops. Also move psci and smp_spin_table ops to use CPU_OF_TABLES. Signed-off-by: Abhimanyu Kapur Signed-off-by: Kumar Gala --- arch/arm64/include/asm/cpu_ops.h | 5 +++++ arch/arm64/kernel/cpu_ops.c | 16 +++++++++------- arch/arm64/kernel/psci.c | 1 + arch/arm64/kernel/smp_spin_table.c | 3 ++- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/asm/cpu_ops.h b/arch/arm64/include/asm/cpu_ops.h index 8f03446cf89f..41bf609206ed 100644 --- a/arch/arm64/include/asm/cpu_ops.h +++ b/arch/arm64/include/asm/cpu_ops.h @@ -71,4 +71,9 @@ static inline void __init cpu_read_bootcpu_ops(void) cpu_read_ops(0); } +#define CPU_METHOD_OF_DECLARE(name, __ops) \ + static const struct cpu_operations *__cpu_method_table_##name \ + __used __section(__cpu_method_of_table) \ + = __ops; + #endif /* ifndef __ASM_CPU_OPS_H */ diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c index b6bd7d447768..3c63506b6437 100644 --- a/arch/arm64/kernel/cpu_ops.c +++ b/arch/arm64/kernel/cpu_ops.c @@ -35,16 +35,18 @@ static const struct cpu_operations *supported_cpu_ops[] __initconst = { NULL, }; +extern struct cpu_operations __cpu_method_of_table[]; +static const struct cpu_operations *__cpu_method_of_table_sentinel + __used __section(__cpu_method_of_table_end); + static const struct cpu_operations * __init cpu_get_ops(const char *name) { - const struct cpu_operations **ops = supported_cpu_ops; - - while (*ops) { - if (!strcmp(name, (*ops)->name)) - return *ops; + const struct cpu_operations **start = (void *)__cpu_method_of_table; - ops++; - } + for (; *start; start++) { + if (!strcmp((*start)->name, name)) + return *start; + }; return NULL; } diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c index f67f35b6edb1..60b1a1d1a3d8 100644 --- a/arch/arm64/kernel/psci.c +++ b/arch/arm64/kernel/psci.c @@ -221,3 +221,4 @@ const struct cpu_operations cpu_psci_ops = { #endif }; +CPU_METHOD_OF_DECLARE(psci, &cpu_psci_ops); diff --git a/arch/arm64/kernel/smp_spin_table.c b/arch/arm64/kernel/smp_spin_table.c index aef3605a8c47..06eae9db5469 100644 --- a/arch/arm64/kernel/smp_spin_table.c +++ b/arch/arm64/kernel/smp_spin_table.c @@ -125,9 +125,10 @@ static int smp_spin_table_cpu_boot(unsigned int cpu) return 0; } -const struct cpu_operations smp_spin_table_ops = { +static const struct cpu_operations smp_spin_table_ops = { .name = "spin-table", .cpu_init = smp_spin_table_cpu_init, .cpu_prepare = smp_spin_table_cpu_prepare, .cpu_boot = smp_spin_table_cpu_boot, }; +CPU_METHOD_OF_DECLARE(spin_table, &smp_spin_table_ops); -- 2.39.5