linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Elder <elder@linaro.org>
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	[thread overview]
Message-ID: <1396577891-2713-2-git-send-email-elder@linaro.org> (raw)
In-Reply-To: <1396577891-2713-1-git-send-email-elder@linaro.org>

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 <elder@linaro.org>
---
 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");
-- 
1.7.9.5


  reply	other threads:[~2014-04-04  2:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-04  2:18 [PATCH 0/5] ARM: SMP: support Broadcom mobile SoCs Alex Elder
2014-04-04  2:18 ` Alex Elder [this message]
2014-04-04  2:18 ` [PATCH 2/5] ARM: add SMP support for " Alex Elder
2014-04-04  2:26   ` Alex Elder
2014-04-04 15:30   ` Tim Kryger
2014-04-04 18:56     ` Alex Elder
2014-04-15 12:30       ` Alex Elder
2014-04-04 17:55   ` Stephen Boyd
2014-04-04 19:30     ` Alex Elder
2014-05-05 22:02     ` Alex Elder
2014-05-06  1:43       ` Stephen Boyd
2014-05-06  4:05         ` Alex Elder
2014-04-04  2:18 ` [PATCH 3/5] ARM: configs: enable SMP in bcm_defconfig Alex Elder
2014-04-04 10:21   ` Alex Elder
2014-04-04  2:18 ` [PATCH 4/5] ARM: dts: enable SMP support for bcm28155 Alex Elder
2014-04-04  2:18 ` [PATCH 5/5] ARM: dts: enable SMP support for bcm21664 Alex Elder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1396577891-2713-2-git-send-email-elder@linaro.org \
    --to=elder@linaro.org \
    --cc=arnd@arndb.de \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=bcm@fixthebug.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mporter@linaro.org \
    --cc=sboyd@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).