From patchwork Fri Apr 4 02:18:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 3935471 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 2775B9F357 for ; Fri, 4 Apr 2014 02:19:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 39ECC2035D for ; Fri, 4 Apr 2014 02:19:40 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (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 2D09D2034F for ; Fri, 4 Apr 2014 02:19:39 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WVtiN-0004rg-S6; Fri, 04 Apr 2014 02:18:44 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WVti7-0003tp-7K; Fri, 04 Apr 2014 02:18:27 +0000 Received: from mail-ie0-f169.google.com ([209.85.223.169]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WVtho-0003pL-JR for linux-arm-kernel@lists.infradead.org; Fri, 04 Apr 2014 02:18:12 +0000 Received: by mail-ie0-f169.google.com with SMTP id to1so2795693ieb.28 for ; Thu, 03 Apr 2014 19:17:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BVbk/p+l0ifO5bfDSYYQZAME3vYsulbUltnHbrfwpzw=; b=EZLRoBAg+TW95Xw6hodCBjWCICXIHDm4Em6ypEbzR84d3ZaLMV9vWVf20JexSyx7br H4+hE4UotlerCfnVGBdQ9i/567XMtLGNVgMQmFGZOIygyaNwJ9gkh64DXbHRdFMWFuvF B6QBWzZlD1nwWGB956IQQI3J4Gnau6IxOscQZn7ewA18qqB+KpF7XjWER7h3nwbLodFI kLf30/anzkDag5JkRJt2FH1wTLS08TM8k1d8291/8usewQkV1S+zbu/SkBur0plNxmRL RlF3iYyFr1kGlgfPGpcoS/jH4JnpH3tFsX/oYWebcLDr4W8KRbBP1oNvsh3xHsO9rpzl Ch6g== X-Gm-Message-State: ALoCoQkC8GfoZtUwaJ3aPSGadhGTBLNKWuNHjwv0QBEI432phJDY2rWAL6fjn96foR+FVliMjdIk X-Received: by 10.42.97.193 with SMTP id p1mr9600630icn.32.1396577866294; Thu, 03 Apr 2014 19:17:46 -0700 (PDT) Received: from localhost.localdomain (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPSA id an1sm2408017igc.0.2014.04.03.19.17.44 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Apr 2014 19:17:45 -0700 (PDT) From: Alex Elder To: mporter@linaro.org, bcm@fixthebug.org, devicetree@vger.kernel.org, arnd@arndb.de, sboyd@codeaurora.org Subject: [PATCH 1/5] ARM: introduce CPU_METHOD_OF_DECLARE_SETUP() Date: Thu, 3 Apr 2014 21:18:07 -0500 Message-Id: <1396577891-2713-2-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1396577891-2713-1-git-send-email-elder@linaro.org> References: <1396577891-2713-1-git-send-email-elder@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140403_221808_705243_97836FAD X-CRM114-Status: GOOD ( 19.35 ) X-Spam-Score: -2.6 (--) Cc: bcm-kernel-feedback-list@broadcom.com, linux-kernel@vger.kernel.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=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 The CPU_METHOD_OF_DECLARE() macro allows methods for assigning SMP/hotplug operations to CPUS to be defined using device tree, without the need for machine-dependent code. And although it allows the *method* to be specified, it does *not* allow any parameterization of that method. For example, there is no efficient way to define a machine-specific address or other property one might want to define for secondary CPUs. Define a new of_cpu_method->setup() function, which (if defined) is called for nodes found having a matching "enable-method" property. The matching node is supplied as the function's argument, allowing additional required information to be extracted from that node. A new macro CPU_METHOD_OF_DECLARE_SETUP() allows a setup method to be supplied when a method is declared. Extend the interface for set_smp_ops_by_method() so that it can return a negative error code to allow DT parsing errors to be reported by the setup function. (Note that only the first "cpu" (or "cpus") node having a matching method is used by set_smp_ops_by_method(); this logic is not changed.) Signed-off-by: Alex Elder --- arch/arm/include/asm/smp.h | 10 ++++++++-- arch/arm/kernel/devtree.c | 31 +++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h index 2ec765c..ab4a5a9 100644 --- a/arch/arm/include/asm/smp.h +++ b/arch/arm/include/asm/smp.h @@ -115,15 +115,21 @@ struct smp_operations { #endif }; +struct device_node; struct of_cpu_method { const char *method; + int (*setup)(struct device_node *node); struct smp_operations *ops; }; -#define CPU_METHOD_OF_DECLARE(name, _method, _ops) \ +#define CPU_METHOD_OF_DECLARE_SETUP(name, _method, _setup, _ops) \ static const struct of_cpu_method __cpu_method_of_table_##name \ __used __section(__cpu_method_of_table) \ - = { .method = _method, .ops = _ops } + = { .method = _method, .setup = _setup, .ops = _ops } + +#define CPU_METHOD_OF_DECLARE(name, _method, _ops) \ + CPU_METHOD_OF_DECLARE_SETUP(name, _method, NULL, _ops) + /* * set platform specific SMP operations */ diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c index c7419a5..1a0cca3 100644 --- a/arch/arm/kernel/devtree.c +++ b/arch/arm/kernel/devtree.c @@ -76,11 +76,18 @@ static int __init set_smp_ops_by_method(struct device_node *node) if (of_property_read_string(node, "enable-method", &method)) return 0; - for (; m < __cpu_method_of_table_end; m++) + for (; m < __cpu_method_of_table_end; m++) { if (!strcmp(m->method, method)) { - smp_set_ops(m->ops); - return 1; + int ret = 0; + + if (m->setup) + ret = m->setup(node); + if (!ret) + smp_set_ops(m->ops); + + return ret ? ret : 1; } + } return 0; } @@ -181,16 +188,28 @@ void __init arm_dt_init_cpu_maps(void) tmp_map[i] = hwid; - if (!found_method) + if (!found_method) { found_method = set_smp_ops_by_method(cpu); + if (WARN(found_method < 0, + "error %d getting enable-method for " + "DT /cpu %u\n", found_method, cpuidx)) { + return; + } + } } /* * Fallback to an enable-method in the cpus node if nothing found in * a cpu node. */ - if (!found_method) - set_smp_ops_by_method(cpus); + if (!found_method) { + found_method = set_smp_ops_by_method(cpus); + if (WARN(found_method < 0, + "error %d getting enable-method for " + "DT /cpus node\n", found_method)) { + return; + } + } if (!bootcpu_valid) { pr_warn("DT missing boot CPU MPIDR[23:0], fall back to default cpu_logical_map\n");