linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Stephen Boyd <sboyd@codeaurora.org>
Cc: "linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	David Brown <davidb@codeaurora.org>,
	Rohit Vaswani <rvaswani@codeaurora.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-arm-msm@vger.kernel.org" <linux-arm-msm@vger.kernel.org>,
	Kumar Gala <galak@codeaurora.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Russell King <linux@arm.linux.org.uk>
Subject: Re: [PATCH v2 4/9] ARM: Introduce CPU_METHOD_OF_DECLARE() for cpu hotplug/smp
Date: Wed, 8 Jan 2014 15:06:12 +0000	[thread overview]
Message-ID: <20140108150612.GC11753@e106331-lin.cambridge.arm.com> (raw)
In-Reply-To: <1387845593-10050-5-git-send-email-sboyd@codeaurora.org>

On Tue, Dec 24, 2013 at 12:39:48AM +0000, Stephen Boyd wrote:
> The goal of multi-platform kernels is to remove the need for mach
> directories and machine descriptors. To further that goal,
> introduce CPU_METHOD_OF_DECLARE() to allow cpu hotplug/smp
> support to be separated from the machine descriptors.
> Implementers should specify an enable-method property in their
> cpus node and then implement a matching set of smp_ops in their
> hotplug/smp code, wiring it up with the CPU_METHOD_OF_DECLARE()
> macro. When the kernel is compiled we'll collect all the
> enable-method smp_ops into one section for use at boot.
> 
> At boot time we'll look for an enable-method in each cpu node and
> try to match that against all known CPU enable methods in the
> kernel. If there are no enable-methods in the cpu nodes we
> fallback to the cpus node and try to use any enable-method found
> there. If that doesn't work we fall back to the old way of using
> the machine descriptor.

Nice!

> 
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: <devicetree@vger.kernel.org>
> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
> ---
>  arch/arm/include/asm/smp.h        |  9 +++++++++
>  arch/arm/kernel/devtree.c         | 40 +++++++++++++++++++++++++++++++++++++++
>  include/asm-generic/vmlinux.lds.h | 10 ++++++++++
>  3 files changed, 59 insertions(+)
> 
> diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
> index 22a3b9b..772435b 100644
> --- a/arch/arm/include/asm/smp.h
> +++ b/arch/arm/include/asm/smp.h
> @@ -114,6 +114,15 @@ struct smp_operations {
>  #endif
>  };
>  
> +struct of_cpu_method {
> +	const char *method;
> +	struct smp_operations *ops;
> +};
> +
> +#define CPU_METHOD_OF_DECLARE(name, _method, _ops)			\
> +	static const struct of_cpu_method __cpu_method_of_table_##name	\
> +		__used __section(__cpu_method_of_table)			\
> +		= { .method = _method, .ops = _ops }
>  /*
>   * set platform specific SMP operations
>   */
> diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
> index 739c3df..91cc3f8 100644
> --- a/arch/arm/kernel/devtree.c
> +++ b/arch/arm/kernel/devtree.c
> @@ -18,6 +18,7 @@
>  #include <linux/of_fdt.h>
>  #include <linux/of_irq.h>
>  #include <linux/of_platform.h>
> +#include <linux/smp.h>
>  
>  #include <asm/cputype.h>
>  #include <asm/setup.h>
> @@ -63,6 +64,34 @@ void __init arm_dt_memblock_reserve(void)
>  	}
>  }
>  
> +#ifdef CONFIG_SMP
> +extern struct of_cpu_method __cpu_method_of_table_begin[];
> +extern struct of_cpu_method __cpu_method_of_table_end[];
> +
> +static int __init set_smp_ops_by_method(struct device_node *node)
> +{
> +	const char *method;
> +	struct of_cpu_method *m = __cpu_method_of_table_begin;
> +
> +	if (of_property_read_string(node, "enable-method", &method))
> +		return 0;
> +
> +	for (; m < __cpu_method_of_table_end; m++)
> +		if (!strcmp(m->method, method)) {
> +			smp_set_ops(m->ops);
> +			return 1;
> +		}
> +
> +	return 0;
> +}
> +#else
> +static inline int set_smp_ops_by_method(struct device_node *node)
> +{
> +	return 1;
> +}
> +#endif

I was going to comment that this would look nicer using an error code or
0, rather than 0 or 1, but I see that would make the call sites more
complicated / less legible.

> +
> +
>  /*
>   * arm_dt_init_cpu_maps - Function retrieves cpu nodes from the device tree
>   * and builds the cpu logical map array containing MPIDR values related to
> @@ -79,6 +108,7 @@ void __init arm_dt_init_cpu_maps(void)
>  	 * read as 0.
>  	 */
>  	struct device_node *cpu, *cpus;
> +	int found_method = 0;
>  	u32 i, j, cpuidx = 1;
>  	u32 mpidr = is_smp() ? read_cpuid_mpidr() & MPIDR_HWID_BITMASK : 0;
>  
> @@ -150,8 +180,18 @@ void __init arm_dt_init_cpu_maps(void)
>  		}
>  
>  		tmp_map[i] = hwid;
> +
> +		if (!found_method)
> +			found_method = set_smp_ops_by_method(cpu);
>  	}
>  
> +	/*
> +	 * 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 (!bootcpu_valid) {
>  		pr_warn("DT missing boot CPU MPIDR[23:0], fall back to default cpu_logical_map\n");
>  		return;
> diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> index bc2121f..bd02ca7 100644
> --- a/include/asm-generic/vmlinux.lds.h
> +++ b/include/asm-generic/vmlinux.lds.h
> @@ -167,6 +167,15 @@
>  #define CLK_OF_TABLES()
>  #endif
>  
> +#ifdef CONFIG_SMP
> +#define CPU_METHOD_OF_TABLES() . = ALIGN(8);				    \
> +			   VMLINUX_SYMBOL(__cpu_method_of_table_begin) = .; \
> +			   *(__cpu_method_of_table)			    \
> +			   VMLINUX_SYMBOL(__cpu_method_of_table_end) = .;
> +#else
> +#define CPU_METHOD_OF_TABLES()
> +#endif

I suspect we'll use this on arm64 in future, where we might need this
even on UP systems (for PSCI's cpu_suspend method). However, I think
that can change that as and when we require it.

> +
>  #define KERNEL_DTB()							\
>  	STRUCT_ALIGN();							\
>  	VMLINUX_SYMBOL(__dtb_start) = .;				\
> @@ -491,6 +500,7 @@
>  	MEM_DISCARD(init.rodata)					\
>  	CLK_OF_TABLES()							\
>  	CLKSRC_OF_TABLES()						\
> +	CPU_METHOD_OF_TABLES()						\
>  	KERNEL_DTB()							\
>  	IRQCHIP_OF_MATCH_TABLE()

Enthusiastically Acked-by: Mark Rutland <mark.rutland@arm.com>

Cheers,
Mark.

  reply	other threads:[~2014-01-08 15:06 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-24  0:39 [PATCH v2 0/9] CPU enable method based SMP/hotplug + MSM conversion Stephen Boyd
2013-12-24  0:39 ` [PATCH v2 1/9] devicetree: bindings: Document Krait/Scorpion cpus and enable-method Stephen Boyd
     [not found]   ` <1387845593-10050-2-git-send-email-sboyd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2014-01-08 14:21     ` Mark Rutland
2014-01-08 23:21       ` Stephen Boyd
2013-12-24  0:39 ` [PATCH v2 2/9] devicetree: bindings: Document qcom,kpss-acc Stephen Boyd
2014-01-08 14:25   ` Mark Rutland
2014-01-08 14:32     ` Mark Rutland
2014-01-08 23:02       ` Stephen Boyd
2013-12-24  0:39 ` [PATCH v2 3/9] devicetree: bindings: Document qcom,saw2 node Stephen Boyd
2014-01-08 14:36   ` Mark Rutland
2014-01-08 15:21     ` Mark Rutland
2013-12-24  0:39 ` [PATCH v2 4/9] ARM: Introduce CPU_METHOD_OF_DECLARE() for cpu hotplug/smp Stephen Boyd
2014-01-08 15:06   ` Mark Rutland [this message]
2013-12-24  0:39 ` [PATCH v2 5/9] ARM: msm: Remove pen_release usage Stephen Boyd
2013-12-24  0:39 ` [PATCH v2 6/9] ARM: msm: Re-organize platsmp to make it extensible Stephen Boyd
2013-12-24  0:39 ` [PATCH v2 7/9] ARM: msm: Add SMP support for KPSSv1 Stephen Boyd
2013-12-24  0:39 ` [PATCH v2 8/9] ARM: msm: Add SMP support for KPSSv2 Stephen Boyd
2013-12-24  0:39 ` [PATCH v2 9/9] ARM: dts: msm: Add nodes necessary for SMP boot Stephen Boyd
     [not found] ` <1387845593-10050-1-git-send-email-sboyd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2014-01-06 22:19   ` [PATCH v2 0/9] CPU enable method based SMP/hotplug + MSM conversion Stephen Boyd
2014-01-08 15:20     ` Mark Rutland
2014-01-08 21:37 ` Arnd Bergmann
2014-01-09  1:50   ` Stephen Boyd
     [not found]     ` <52CE005A.3070802-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2014-01-23 22:04       ` Kumar Gala
2014-02-07 21:13 ` [PATCH v2 10/9] ARM: msm: Remove board-dt.c Stephen Boyd

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=20140108150612.GC11753@e106331-lin.cambridge.arm.com \
    --to=mark.rutland@arm.com \
    --cc=arnd@arndb.de \
    --cc=davidb@codeaurora.org \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=rvaswani@codeaurora.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).