Patchwork [1/2] ARM: mach-imx: convert logical CPU numbers to physical numbers

login
register
mail settings
Submitter Will Deacon
Date Nov. 8, 2011, 2:34 p.m.
Message ID <1320762894-11824-2-git-send-email-will.deacon@arm.com>
Download mbox | patch
Permalink /patch/124386/
State New
Headers show

Comments

Will Deacon - Nov. 8, 2011, 2:34 p.m.
This patch uses the new cpu_logical_map() macro for converting logical
CPU numbers into physical numbers when releasing CPUs during the SMP
boot and CPU hotplug paths.

Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
 arch/arm/mach-imx/src.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Sascha Hauer - Nov. 11, 2011, 9:29 a.m.
On Tue, Nov 08, 2011 at 02:34:53PM +0000, Will Deacon wrote:
> This patch uses the new cpu_logical_map() macro for converting logical
> CPU numbers into physical numbers when releasing CPUs during the SMP
> boot and CPU hotplug paths.

Shawn, is this one ok?

Sascha

> 
> Cc: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Shawn Guo <shawn.guo@linaro.org>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> ---
>  arch/arm/mach-imx/src.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/src.c b/arch/arm/mach-imx/src.c
> index 36cacbd..63ba593 100644
> --- a/arch/arm/mach-imx/src.c
> +++ b/arch/arm/mach-imx/src.c
> @@ -14,6 +14,7 @@
>  #include <linux/io.h>
>  #include <linux/of.h>
>  #include <linux/of_address.h>
> +#include <linux/smp.h>
>  #include <asm/unified.h>
>  
>  #define SRC_SCR				0x000
> @@ -27,6 +28,7 @@ void imx_enable_cpu(int cpu, bool enable)
>  {
>  	u32 mask, val;
>  
> +	cpu = cpu_logical_map(cpu);
>  	mask = 1 << (BP_SRC_SCR_CORE1_ENABLE + cpu - 1);
>  	val = readl_relaxed(src_base + SRC_SCR);
>  	val = enable ? val | mask : val & ~mask;
> @@ -35,6 +37,7 @@ void imx_enable_cpu(int cpu, bool enable)
>  
>  void imx_set_cpu_jump(int cpu, void *jump_addr)
>  {
> +	cpu = cpu_logical_map(cpu);
>  	writel_relaxed(BSYM(virt_to_phys(jump_addr)),
>  		       src_base + SRC_GPR1 + cpu * 8);
>  }
> -- 
> 1.7.4.1
> 
>
Will Deacon - Nov. 11, 2011, 10:08 a.m.
On Fri, Nov 11, 2011 at 09:29:25AM +0000, Sascha Hauer wrote:
> On Tue, Nov 08, 2011 at 02:34:53PM +0000, Will Deacon wrote:
> > This patch uses the new cpu_logical_map() macro for converting logical
> > CPU numbers into physical numbers when releasing CPUs during the SMP
> > boot and CPU hotplug paths.
> 
> Shawn, is this one ok?

I reckon I need to post a v2 because this probably breaks when !SMP.

Will
Will Deacon - Nov. 11, 2011, 10:56 a.m.
On Fri, Nov 11, 2011 at 10:08:00AM +0000, Will Deacon wrote:
> On Fri, Nov 11, 2011 at 09:29:25AM +0000, Sascha Hauer wrote:
> > On Tue, Nov 08, 2011 at 02:34:53PM +0000, Will Deacon wrote:
> > > This patch uses the new cpu_logical_map() macro for converting logical
> > > CPU numbers into physical numbers when releasing CPUs during the SMP
> > > boot and CPU hotplug paths.
> > 
> > Shawn, is this one ok?
> 
> I reckon I need to post a v2 because this probably breaks when !SMP.

Actually, I take that back. Looks like the function is only used by
hotplug.c and platsmp.c, both of which depend on CONFIG_SMP.

So yes, comments from Shawn would be great.

Will
Shawn Guo - Nov. 11, 2011, 1:07 p.m.
On Fri, Nov 11, 2011 at 10:56:07AM +0000, Will Deacon wrote:
> On Fri, Nov 11, 2011 at 10:08:00AM +0000, Will Deacon wrote:
> > On Fri, Nov 11, 2011 at 09:29:25AM +0000, Sascha Hauer wrote:
> > > On Tue, Nov 08, 2011 at 02:34:53PM +0000, Will Deacon wrote:
> > > > This patch uses the new cpu_logical_map() macro for converting logical
> > > > CPU numbers into physical numbers when releasing CPUs during the SMP
> > > > boot and CPU hotplug paths.
> > > 
> > > Shawn, is this one ok?
> > 
> > I reckon I need to post a v2 because this probably breaks when !SMP.
> 
> Actually, I take that back. Looks like the function is only used by
> hotplug.c and platsmp.c, both of which depend on CONFIG_SMP.
> 
But the build of src.c does not depend on CONFIG_SMP.  So when building
with no CONFIG_SMP, we get:

  CC      arch/arm/mach-imx/src.o
arch/arm/mach-imx/src.c: In function ‘imx_enable_cpu’:
arch/arm/mach-imx/src.c:31:2: error: implicit declaration of function ‘cpu_logical_map’
make[2]: *** [arch/arm/mach-imx/src.o] Error 1
make[1]: *** [arch/arm/mach-imx] Error 2
Will Deacon - Nov. 11, 2011, 1:41 p.m.
On Fri, Nov 11, 2011 at 01:07:02PM +0000, Shawn Guo wrote:
> On Fri, Nov 11, 2011 at 10:56:07AM +0000, Will Deacon wrote:
> > On Fri, Nov 11, 2011 at 10:08:00AM +0000, Will Deacon wrote:
> > > On Fri, Nov 11, 2011 at 09:29:25AM +0000, Sascha Hauer wrote:
> > > > On Tue, Nov 08, 2011 at 02:34:53PM +0000, Will Deacon wrote:
> > > > > This patch uses the new cpu_logical_map() macro for converting logical
> > > > > CPU numbers into physical numbers when releasing CPUs during the SMP
> > > > > boot and CPU hotplug paths.
> > > > 
> > > > Shawn, is this one ok?
> > > 
> > > I reckon I need to post a v2 because this probably breaks when !SMP.
> > 
> > Actually, I take that back. Looks like the function is only used by
> > hotplug.c and platsmp.c, both of which depend on CONFIG_SMP.
> > 
> But the build of src.c does not depend on CONFIG_SMP.  So when building
> with no CONFIG_SMP, we get:
> 
>   CC      arch/arm/mach-imx/src.o
> arch/arm/mach-imx/src.c: In function ‘imx_enable_cpu’:
> arch/arm/mach-imx/src.c:31:2: error: implicit declaration of function ‘cpu_logical_map’
> make[2]: *** [arch/arm/mach-imx/src.o] Error 1
> make[1]: *** [arch/arm/mach-imx] Error 2

Ok, then maybe we should #ifdef CONFIG_SMP that function entirely. If that
sounds ok, I can post a v2.

Will
Shawn Guo - Nov. 11, 2011, 11:07 p.m.
On Fri, Nov 11, 2011 at 01:41:35PM +0000, Will Deacon wrote:
> On Fri, Nov 11, 2011 at 01:07:02PM +0000, Shawn Guo wrote:
> > On Fri, Nov 11, 2011 at 10:56:07AM +0000, Will Deacon wrote:
> > > On Fri, Nov 11, 2011 at 10:08:00AM +0000, Will Deacon wrote:
> > > > On Fri, Nov 11, 2011 at 09:29:25AM +0000, Sascha Hauer wrote:
> > > > > On Tue, Nov 08, 2011 at 02:34:53PM +0000, Will Deacon wrote:
> > > > > > This patch uses the new cpu_logical_map() macro for converting logical
> > > > > > CPU numbers into physical numbers when releasing CPUs during the SMP
> > > > > > boot and CPU hotplug paths.
> > > > > 
> > > > > Shawn, is this one ok?
> > > > 
> > > > I reckon I need to post a v2 because this probably breaks when !SMP.
> > > 
> > > Actually, I take that back. Looks like the function is only used by
> > > hotplug.c and platsmp.c, both of which depend on CONFIG_SMP.
> > > 
> > But the build of src.c does not depend on CONFIG_SMP.  So when building
> > with no CONFIG_SMP, we get:
> > 
> >   CC      arch/arm/mach-imx/src.o
> > arch/arm/mach-imx/src.c: In function ‘imx_enable_cpu’:
> > arch/arm/mach-imx/src.c:31:2: error: implicit declaration of function ‘cpu_logical_map’
> > make[2]: *** [arch/arm/mach-imx/src.o] Error 1
> > make[1]: *** [arch/arm/mach-imx] Error 2
> 
> Ok, then maybe we should #ifdef CONFIG_SMP that function entirely. If that
> sounds ok, I can post a v2.
> 
Yes for imx_enable_cpu(), and no for imx_set_cpu_jump() as it's being
called by pm-imx6q.c as well.  And I would suggest just wrap #ifdef
cpu_logical_map, as these two functions are exported in
arch/arm/plat-mxc/include/mach/common.h for !SMP users too.

Patch

diff --git a/arch/arm/mach-imx/src.c b/arch/arm/mach-imx/src.c
index 36cacbd..63ba593 100644
--- a/arch/arm/mach-imx/src.c
+++ b/arch/arm/mach-imx/src.c
@@ -14,6 +14,7 @@ 
 #include <linux/io.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/smp.h>
 #include <asm/unified.h>
 
 #define SRC_SCR				0x000
@@ -27,6 +28,7 @@  void imx_enable_cpu(int cpu, bool enable)
 {
 	u32 mask, val;
 
+	cpu = cpu_logical_map(cpu);
 	mask = 1 << (BP_SRC_SCR_CORE1_ENABLE + cpu - 1);
 	val = readl_relaxed(src_base + SRC_SCR);
 	val = enable ? val | mask : val & ~mask;
@@ -35,6 +37,7 @@  void imx_enable_cpu(int cpu, bool enable)
 
 void imx_set_cpu_jump(int cpu, void *jump_addr)
 {
+	cpu = cpu_logical_map(cpu);
 	writel_relaxed(BSYM(virt_to_phys(jump_addr)),
 		       src_base + SRC_GPR1 + cpu * 8);
 }