From patchwork Tue Apr 15 13:12:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 3992901 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 7ADF99F2CC for ; Tue, 15 Apr 2014 13:15:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7886D20221 for ; Tue, 15 Apr 2014 13:15:47 +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 8C1BB20220 for ; Tue, 15 Apr 2014 13:15:46 +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 1Wa3B8-0006TF-G4; Tue, 15 Apr 2014 13:13:34 +0000 Received: from mail-ie0-f174.google.com ([209.85.223.174]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wa3At-0006Jx-4V for linux-arm-kernel@lists.infradead.org; Tue, 15 Apr 2014 13:13:19 +0000 Received: by mail-ie0-f174.google.com with SMTP id rp18so9269175iec.19 for ; Tue, 15 Apr 2014 06:12:57 -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=iEHcxgb+FpKjG8ZdS0z3MXRPa9b9Hd0eBfK2d1f8T1ki1Spbdgy0BlB019Ze0fzbVr EgXLTZT3MNtXRMkAlpkKBDPKA3DMfX3Lcw9q69g4NaLiRwi1K7V5lxMEBDTq4xLS8bzT 2UGWP+1WgRgXoZouSX1snrLb9qCvbnjLrVmY8ZoAbaWVZfZFBaDtiiR9HvzErufVIejZ YAH9UDNYITADlgqQfjYhOVWzn2T3vdCHwQ9BEt9gLsRsldQDzLHJd5lepWbOS9PWoGQ4 TAVMQo3WLecFV8CRuSgTT+mZaHxmkOxxDoRhBFyXQwXNkryJZOc/Uz8+AeB0MoB1VwN/ 69Yw== X-Gm-Message-State: ALoCoQmV/6YgV6yzidNxZTd+s3Jhd4NAKFrzX/497JOxnLe7sgu+iWveY36bNi7kf2ShwW/yPhMP X-Received: by 10.50.122.8 with SMTP id lo8mr23210977igb.31.1397567576984; Tue, 15 Apr 2014 06:12:56 -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 lp5sm5450880igb.1.2014.04.15.06.12.55 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Apr 2014 06:12:56 -0700 (PDT) From: Alex Elder To: mporter@linaro.org, bcm@fixthebug.org, linux@arm.linux.org.uk, devicetree@vger.kernel.org, arnd@arndb.de, sboyd@codeaurora.org Subject: [PATCH v2 1/5] ARM: introduce CPU_METHOD_OF_DECLARE_SETUP() Date: Tue, 15 Apr 2014 08:12:50 -0500 Message-Id: <1397567574-31599-2-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1397567574-31599-1-git-send-email-elder@linaro.org> References: <1397567574-31599-1-git-send-email-elder@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140415_061319_218648_BCC97E6F X-CRM114-Status: GOOD ( 19.46 ) X-Spam-Score: -0.7 (/) 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=-2.6 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 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");