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: 27725 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f198.google.com (mail-qc0-f198.google.com [209.85.216.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1DF752036E for ; Fri, 4 Apr 2014 02:20:23 +0000 (UTC) Received: by mail-qc0-f198.google.com with SMTP id r5sf6769111qcx.5 for ; Thu, 03 Apr 2014 19:20:23 -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=XIc3HUFn0n5oSolxqGaT8U8PgNKXAwjKA/r0yswKVpA=; b=Quy23XtRpOalaegNBp40prJ91IDAchx3/9q7J07RKv93sihL1C/k5ON9MMtfJag7QV 1npyta+ONHkIopIYbZfnqVbUs6CA9hWmbG1qGV68FXctNEruD7+R6+O4Gx250WDAOXuQ TrFFzgF7ufUHDdyQWBmIqeXtH/Sy0nMw4zjKtgxBV4370y8e+Jf9NViErBwu+XPnjclC E4+/2J99h40GaF1qP6uR5OxwssdrVMyc7ugNGllY8kJawvZZ7gI8lAPeuaxpa3LU+xdf vJaKMiSbsbd7KsApFWxLLyo28kP3EIbRiopP8DMKyqbShwrGLqFBQjlGpnAEwnyM2Pbg PbLg== X-Gm-Message-State: ALoCoQlb2vOCFCR1YSuDDYJN+HJA1gyAbri8KHr8Te9BeXMzSdjSn1FPsOQ80eymQ+IqA01Fj/Nc X-Received: by 10.58.112.97 with SMTP id ip1mr1976945veb.32.1396578023063; Thu, 03 Apr 2014 19:20:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.41.40 with SMTP id y37ls904142qgy.10.gmail; Thu, 03 Apr 2014 19:20:23 -0700 (PDT) X-Received: by 10.52.165.105 with SMTP id yx9mr8967883vdb.22.1396578022987; Thu, 03 Apr 2014 19:20:22 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id fc7si1546871vcb.24.2014.04.03.19.20.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Apr 2014 19:20:22 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.175 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.175; Received: by mail-ve0-f175.google.com with SMTP id oz11so959194veb.34 for ; Thu, 03 Apr 2014 19:20:22 -0700 (PDT) X-Received: by 10.58.74.38 with SMTP id q6mr2570126vev.7.1396578022884; Thu, 03 Apr 2014 19:20:22 -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.12.8 with SMTP id v8csp76391vcv; Thu, 3 Apr 2014 19:20:21 -0700 (PDT) X-Received: by 10.66.146.105 with SMTP id tb9mr11451640pab.157.1396578021355; Thu, 03 Apr 2014 19:20:21 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zt8si3927715pbc.144.2014.04.03.19.20.20; Thu, 03 Apr 2014 19:20:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-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 S1751961AbaDDCUT (ORCPT + 9 others); Thu, 3 Apr 2014 22:20:19 -0400 Received: from mail-ie0-f175.google.com ([209.85.223.175]:47431 "EHLO mail-ie0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752155AbaDDCRr (ORCPT ); Thu, 3 Apr 2014 22:17:47 -0400 Received: by mail-ie0-f175.google.com with SMTP id to1so2767936ieb.20 for ; Thu, 03 Apr 2014 19:17:46 -0700 (PDT) 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 Cc: bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.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> Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@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.175 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");