From patchwork Thu Apr 9 17:37:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kumar Gala X-Patchwork-Id: 6189861 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0D053BF4A6 for ; Thu, 9 Apr 2015 17:40:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21DAD2037B for ; Thu, 9 Apr 2015 17:40:42 +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 2201020376 for ; Thu, 9 Apr 2015 17:40:41 +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 1YgGP9-0005En-Vo; Thu, 09 Apr 2015 17:38:15 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YgGOf-0004zb-O1 for linux-arm-kernel@lists.infradead.org; Thu, 09 Apr 2015 17:37:47 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id C95AF140DF6; Thu, 9 Apr 2015 17:37:26 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id B9D01140E3A; Thu, 9 Apr 2015 17:37:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from galak-ubuntu.qualcomm.com (rrcs-67-52-129-61.west.biz.rr.com [67.52.129.61]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: galak@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 64527140DF6; Thu, 9 Apr 2015 17:37:25 +0000 (UTC) From: Kumar Gala To: linux-arm-msm@vger.kernel.org Subject: [RFC PATCH 3/5] arm64: introduce CPU_OF_TABLES for cpu ops selection Date: Thu, 9 Apr 2015 12:37:09 -0500 Message-Id: <1428601031-5366-4-git-send-email-galak@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1428601031-5366-1-git-send-email-galak@codeaurora.org> References: <1428601031-5366-1-git-send-email-galak@codeaurora.org> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150409_103745_914119_1ABCE15E X-CRM114-Status: GOOD ( 16.44 ) X-Spam-Score: -0.0 (/) Cc: devicetree@vger.kernel.org, catalin.marinas@arm.com, Kumar Gala , will.deacon@arm.com, linux-kernel@vger.kernel.org, arm@kernel.org, Abhimanyu Kapur , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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-Virus-Scanned: ClamAV using ClamSMTP From: Abhimanyu Kapur 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 | 27 +++++++++------------------ arch/arm64/kernel/psci.c | 1 + arch/arm64/kernel/smp_spin_table.c | 3 ++- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/arch/arm64/include/asm/cpu_ops.h b/arch/arm64/include/asm/cpu_ops.h index da301ee..a7efab8 100644 --- a/arch/arm64/include/asm/cpu_ops.h +++ b/arch/arm64/include/asm/cpu_ops.h @@ -67,4 +67,9 @@ extern const struct cpu_operations *cpu_ops[NR_CPUS]; int __init cpu_read_ops(struct device_node *dn, int cpu); void __init cpu_read_bootcpu_ops(void); +#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 cce9524..ad33f98 100644 --- a/arch/arm64/kernel/cpu_ops.c +++ b/arch/arm64/kernel/cpu_ops.c @@ -22,29 +22,20 @@ #include #include -extern const struct cpu_operations smp_spin_table_ops; -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 = { -#ifdef CONFIG_SMP - &smp_spin_table_ops, -#endif - &cpu_psci_ops, - 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 * __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 9b8a70a..2f255c7 100644 --- a/arch/arm64/kernel/psci.c +++ b/arch/arm64/kernel/psci.c @@ -523,3 +523,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 14944e5..b41a8b4 100644 --- a/arch/arm64/kernel/smp_spin_table.c +++ b/arch/arm64/kernel/smp_spin_table.c @@ -119,9 +119,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);