From patchwork Fri May 9 00:48:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 4139801 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 00B589F23C for ; Fri, 9 May 2014 00:51:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 22D1C202F8 for ; Fri, 9 May 2014 00:51:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 38F08202DD for ; Fri, 9 May 2014 00:51:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WiYzM-0004KX-3I; Fri, 09 May 2014 00:48:36 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WiYz5-0004G4-Uy; Fri, 09 May 2014 00:48:20 +0000 Received: from geoff by merlin.infradead.org with local (Exim 4.80.1 #2 (Red Hat Linux)) id 1WiYz3-0007ij-Cd; Fri, 09 May 2014 00:48:17 +0000 Message-Id: <20478f830f1d1a426fbe7a379e6f19562082ec7e.1399594544.git.geoff@infradead.org> In-Reply-To: References: From: Geoff Levand Patch-Date: Wed, 7 May 2014 13:00:31 -0700 Subject: [PATCH 2/8] arm64: Make cpu_read_ops generic To: Catalin Marinas , Will Deacon Date: Fri, 09 May 2014 00:48:17 +0000 Cc: Deepak Saxena , kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Remove the __init attribute from the cpu_read_ops() routine and the __initconst attribute from the supported_cpu_ops[] variable to allow cpu_read_ops() to be used after kernel initialization. Change cpu_read_ops() from acting on the static local variable cpu_ops to acting on a pointer to an array of struct cpu_operations passed as a cpu_read_ops() parameter. Also change any calls to cpu_read_ops() to pass the local cpu_ops variable. This change has no functional effect. The kexec_load syscall handling can re-use the cpu_read_ops() routine in its parsing of the device tree for the 2nd stage kernel. kexec_load syscall can be called after kernel init, so cannot use any routines with the __init attribute. Signed-off-by: Geoff Levand --- arch/arm64/include/asm/cpu_ops.h | 3 ++- arch/arm64/kernel/cpu_ops.c | 11 ++++++----- arch/arm64/kernel/smp.c | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/arm64/include/asm/cpu_ops.h b/arch/arm64/include/asm/cpu_ops.h index 1524130..872f61a 100644 --- a/arch/arm64/include/asm/cpu_ops.h +++ b/arch/arm64/include/asm/cpu_ops.h @@ -59,7 +59,8 @@ struct cpu_operations { }; extern const struct cpu_operations *cpu_ops[NR_CPUS]; -extern int __init cpu_read_ops(struct device_node *dn, int cpu); +extern int cpu_read_ops(struct device_node *dn, int cpu, + const struct cpu_operations **cpu_ops); extern void __init cpu_read_bootcpu_ops(void); #endif /* ifndef __ASM_CPU_OPS_H */ diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c index d62d12f..6ccba89 100644 --- a/arch/arm64/kernel/cpu_ops.c +++ b/arch/arm64/kernel/cpu_ops.c @@ -27,7 +27,7 @@ extern const struct cpu_operations cpu_psci_ops; const struct cpu_operations *cpu_ops[NR_CPUS]; -static const struct cpu_operations *supported_cpu_ops[] __initconst = { +static const struct cpu_operations *supported_cpu_ops[] = { #ifdef CONFIG_SMP &smp_spin_table_ops, &cpu_psci_ops, @@ -52,7 +52,8 @@ static const struct cpu_operations * __init cpu_get_ops(const char *name) /* * Read a cpu's enable method from the device tree and record it in cpu_ops. */ -int __init cpu_read_ops(struct device_node *dn, int cpu) +int cpu_read_ops(struct device_node *dn, int cpu, + const struct cpu_operations **cpu_ops) { const char *enable_method = of_get_property(dn, "enable-method", NULL); if (!enable_method) { @@ -66,8 +67,8 @@ int __init cpu_read_ops(struct device_node *dn, int cpu) return -ENOENT; } - cpu_ops[cpu] = cpu_get_ops(enable_method); - if (!cpu_ops[cpu]) { + *cpu_ops = cpu_get_ops(enable_method); + if (!*cpu_ops) { pr_warn("%s: unsupported enable-method property: %s\n", dn->full_name, enable_method); return -EOPNOTSUPP; @@ -83,5 +84,5 @@ void __init cpu_read_bootcpu_ops(void) pr_err("Failed to find device node for boot cpu\n"); return; } - cpu_read_ops(dn, 0); + cpu_read_ops(dn, 0, &cpu_ops[0]); } diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 020bbd5..f9241c1 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -362,7 +362,7 @@ void __init smp_init_cpus(void) if (cpu >= NR_CPUS) goto next; - if (cpu_read_ops(dn, cpu) != 0) + if (cpu_read_ops(dn, cpu, &cpu_ops[cpu])) goto next; if (cpu_ops[cpu]->cpu_init(dn, cpu))