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: 28415 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f70.google.com (mail-pa0-f70.google.com [209.85.220.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 64D1E2036A for ; Tue, 15 Apr 2014 13:15:05 +0000 (UTC) Received: by mail-pa0-f70.google.com with SMTP id lj1sf37029207pab.9 for ; Tue, 15 Apr 2014 06:15:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=O5qw+eFTWom5M3BWpGbqf2d5Dv1W//cmmIuVVvAwrec=; b=gTQIQOOgA69InGrOi/vQkF7/WD0Q8SPduL2nJxCtE6H44QrMnjoCvti0i8XHVRGVaD tdSZttN1HvpcUfIkKGPfKtTpnFqZYKtyDjtp/0BPbgYgdT1mJ9lhReDgIAcssKQdIl8a 6xdX1J7Etgj9gNmIuGn62yHqdJazWu/2UhOmq9HM9Js1gwT6fnuU8YTYDTXJZEdXHnQm ypA5AVMHn6+St78cQ89xV4mWMn7DNyI8HVX7GQNwMRS7G0RPEvkp2eutaqLH2CIAf4wH /KZxUnl9OMmZD6VJp4yWcCvl/e2Esxia2yfYVnlIVf3bCGzeqTEuZT1OxwsjSvwJaTjj Z++g== X-Gm-Message-State: ALoCoQlKzJZHs7I9fGLk7ZS4pFmffyt0PPLNUw+Bd6hrVvNYkkNthcDX9zkwojA7HqiiolqxZTIm X-Received: by 10.66.66.196 with SMTP id h4mr719467pat.22.1397567704552; Tue, 15 Apr 2014 06:15:04 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.33.197 with SMTP id j63ls149417qgj.4.gmail; Tue, 15 Apr 2014 06:15:04 -0700 (PDT) X-Received: by 10.53.1.69 with SMTP id be5mr1104258vdd.27.1397567704448; Tue, 15 Apr 2014 06:15:04 -0700 (PDT) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id i7si3386242vei.193.2014.04.15.06.15.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Apr 2014 06:15:04 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.169; Received: by mail-ve0-f169.google.com with SMTP id pa12so9491939veb.28 for ; Tue, 15 Apr 2014 06:15:04 -0700 (PDT) X-Received: by 10.58.185.145 with SMTP id fc17mr1406823vec.14.1397567704359; Tue, 15 Apr 2014 06:15:04 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp230633vcb; Tue, 15 Apr 2014 06:15:03 -0700 (PDT) X-Received: by 10.67.1.202 with SMTP id bi10mr1935335pad.68.1397567703611; Tue, 15 Apr 2014 06:15:03 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u6si10797981paa.339.2014.04.15.06.15.02; Tue, 15 Apr 2014 06:15:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755095AbaDONOz (ORCPT + 26 others); Tue, 15 Apr 2014 09:14:55 -0400 Received: from mail-ie0-f171.google.com ([209.85.223.171]:40700 "EHLO mail-ie0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753831AbaDONM5 (ORCPT ); Tue, 15 Apr 2014 09:12:57 -0400 Received: by mail-ie0-f171.google.com with SMTP id ar20so9333046iec.2 for ; Tue, 15 Apr 2014 06:12:57 -0700 (PDT) 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 Cc: bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.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> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: elder@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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");