Skip to contentSkip to conversation

SMP support for CNS3xxx + some SMP SCU cleanups

PATCH In review Anton Vorontsov 5 participants 25 messages Nov 30, 2010 – Dec 6, 2010

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

v4 cover SMP support for CNS3xxx + some SMP SCU cleanups

Hello everyone,

This is a reincarnation of my old series that was posted some time ago, i.e. http://www.spinics.net/lists/arm-kernel/msg94291.html

The main change is that boot protocol routines were split into its own file, i.e. smp_scu_boot.c. And now there are all platforms converted to the common SCU routines (where possible).

Russell suggested to get rid of the holding pen thing, I believe this is doable, but for now I don't want to change code behaviour. Just consolidate it as much as possible.

For convenience, the patches are available in GIT repository (based on Russell's devel tree):

git://git.infradead.org/users/cbou/linux-cns3xxx.git smp

Diffstat looks quite good, I think. Especially, considering that the series contains SMP addition for a platform, :-)

 arch/arm/Kconfig                                   |    2 +-
 arch/arm/include/asm/smp_scu.h                     |    9 +
 arch/arm/kernel/Makefile                           |    2 +-
 arch/arm/kernel/smp_scu_boot.c                     |  149 ++++++++++++++++++
 .../headsmp.S => kernel/smp_scu_head.S}            |   11 +-
 arch/arm/mach-cns3xxx/Kconfig                      |    1 +
 arch/arm/mach-cns3xxx/Makefile                     |    1 +
 arch/arm/mach-cns3xxx/include/mach/smp.h           |   28 ++++
 arch/arm/mach-cns3xxx/platsmp.c                    |   69 +++++++++
 arch/arm/mach-omap2/omap-smp.c                     |   64 +--------
 arch/arm/mach-realview/Makefile                    |    2 +-
 arch/arm/mach-realview/hotplug.c                   |    5 +-
 arch/arm/mach-realview/platsmp.c                   |  161 ++------------------
 arch/arm/mach-s5pv310/Makefile                     |    2 +-
 arch/arm/mach-s5pv310/headsmp.S                    |   41 -----
 arch/arm/mach-s5pv310/hotplug.c                    |    5 +-
 arch/arm/mach-s5pv310/platsmp.c                    |  125 +---------------
 arch/arm/mach-tegra/platsmp.c                      |   36 +----
 arch/arm/mach-ux500/Makefile                       |    2 +-
 arch/arm/mach-ux500/headsmp.S                      |   38 -----
 arch/arm/mach-ux500/hotplug.c                      |    5 +-
 arch/arm/mach-ux500/include/mach/smp.h             |    3 -
 arch/arm/mach-ux500/platsmp.c                      |  115 +-------------
 arch/arm/mach-vexpress/Makefile                    |    2 +-
 arch/arm/mach-vexpress/headsmp.S                   |   39 -----
 arch/arm/mach-vexpress/platsmp.c                   |  150 ++-----------------
 26 files changed, 318 insertions(+), 749 deletions(-)
 create mode 100644 arch/arm/kernel/smp_scu_boot.c
 rename arch/arm/{mach-realview/headsmp.S => kernel/smp_scu_head.S} (81%)
 create mode 100644 arch/arm/mach-cns3xxx/include/mach/smp.h
 create mode 100644 arch/arm/mach-cns3xxx/platsmp.c
 delete mode 100644 arch/arm/mach-s5pv310/headsmp.S
 delete mode 100644 arch/arm/mach-ux500/headsmp.S
 delete mode 100644 arch/arm/mach-vexpress/headsmp.S
#1 lore raw

PATCH v4 1/8 ARM: SCU: Add common routines for secondary CPU bootup

For CNS3xxx we want to reuse the original ARM approach of booting secondary CPUs. This patch factors out VExpress' code into a common file, so that now platform code can call these routines.

Note that this patch doesn't convert VExpress platform to the generic routines. Plus, there are also a lot of other platforms that might benefit from this change, but we'll convert them via separate patches.

---
 arch/arm/include/asm/smp_scu.h |    9 +++
 arch/arm/kernel/Makefile       |    2 +-
 arch/arm/kernel/smp_scu_boot.c |  149 ++++++++++++++++++++++++++++++++++++++++
 arch/arm/kernel/smp_scu_head.S |   40 +++++++++++
 4 files changed, 199 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/kernel/smp_scu_boot.c
 create mode 100644 arch/arm/kernel/smp_scu_head.S
arch/arm/include/asm/smp_scu.h +9 -0
index 2376835..271b252 100644
@@ -1,7 +1,16 @@
 #ifndef __ASMARM_ARCH_SCU_H
 #define __ASMARM_ARCH_SCU_H
 
+#include <linux/init.h>
+
 unsigned int scu_get_core_count(void __iomem *);
 void scu_enable(void __iomem *);
 
+extern volatile int __cpuinitdata scu_pen_release;
+void scu_secondary_startup(void);
+void __cpuinit scu_secondary_init(unsigned int cpu);
+int __cpuinit scu_boot_secondary(unsigned int cpu, struct task_struct *idle);
+void __init scu_init_cpus(void __iomem *scu_base);
+void __init scu_prepare_cpus(void __iomem *scu_base, unsigned int max_cpus);
+
 #endif
arch/arm/kernel/Makefile +1 -1
index 806d5e1..11d946a 100644
@@ -30,7 +30,7 @@ obj-$(CONFIG_ARTHUR)		+= arthur.o
 obj-$(CONFIG_ISA_DMA)		+= dma-isa.o
 obj-$(CONFIG_PCI)		+= bios32.o isa.o
 obj-$(CONFIG_SMP)		+= smp.o
-obj-$(CONFIG_HAVE_ARM_SCU)	+= smp_scu.o
+obj-$(CONFIG_HAVE_ARM_SCU)	+= smp_scu.o smp_scu_head.o smp_scu_boot.o
 obj-$(CONFIG_HAVE_ARM_TWD)	+= smp_twd.o
 obj-$(CONFIG_DYNAMIC_FTRACE)	+= ftrace.o
 obj-$(CONFIG_FUNCTION_GRAPH_TRACER)	+= ftrace.o
arch/arm/kernel/smp_scu_boot.c new file +149 -0

149 lines not on this page · raw message

arch/arm/kernel/smp_scu_head.S new file +40 -0
new file mode 100644
index 0000000..e1ceb25
@@ -0,0 +1,40 @@
+/*
+ *  Copyright (c) 2003 ARM Limited
+ *  All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/linkage.h>
+#include <linux/init.h>
+
+	__INIT
+
+/*
+ * SCU specific entry point for secondary CPUs.  This provides
+ * a "holding pen" into which all secondary cores are held until we're
+ * ready for them to initialise.
+ */
+ENTRY(scu_secondary_startup)
+	mrc	p15, 0, r0, c0, c0, 5
+	and	r0, r0, #15
+	adr	r4, 1f
+	ldmia	r4, {r5, r6}
+	sub	r4, r4, r5
+	add	r6, r6, r4
+#if __LINUX_ARM_ARCH__ >= 7
+	dsb
+#endif
+pen:	ldr	r7, [r6]
+	cmp	r7, r0
+	bne	pen
+
+	/*
+	 * we've been released from the holding pen: secondary_stack
+	 * should now contain the SVC stack for this core
+	 */
+	b	secondary_startup
+
+1:	.long	.
+	.long	scu_pen_release
Signature · 1 line
1.7.0.5
#2 lore raw

Re: [PATCH 1/8] ARM: SCU: Add common routines for secondary CPU bootup

Quoted 8 lines · Anton Vorontsov

For CNS3xxx we want to reuse the original ARM approach of booting secondary CPUs. This patch factors out VExpress' code into a common file, so that now platform code can call these routines.

Note that this patch doesn't convert VExpress platform to the generic routines. Plus, there are also a lot of other platforms that might benefit from this change, but we'll convert them via separate patches.

I still think that we can do better with this - especially once the crappy situation with the hotplug CPU code gets resolved.

The SCU does not require the pen_release code. What currently requires that is the hotplug CPU code to allow offlined CPUs to be re-woken. If these CPUs can be properly shutdown, and brought back online via their reset vector, they can be brought back online via the same method used for their initial boot.

What that means is, as we send each individual CPU an IPI, we don't need the pen_release mess nor the holding pen, and all this code can go.

If all that code is tied into a generic "SCU" support option, then we have to ensure that _all_ SCU using platforms can use this method before we switch to it, rather than doing it on a per-platform basis as we can now.

#3 lore raw

Re: [PATCH 1/8] ARM: SCU: Add common routines for secondary CPU bootup

In reply to Anton Vorontsov
Quoted 50 lines · Anton Vorontsov
arch/arm/kernel/smp_scu_boot.c new file +50 -0
+/*
+ * Initialise the CPU possible map early - this describes the CPUs
+ * which may be present or become present in the system.
+ */
+void __init scu_init_cpus(void __iomem *scu_base)
+{
+	unsigned int ncores = scu_base ? scu_get_core_count(scu_base) : 1;
+	unsigned int i;
+
+	/* sanity check */
+	if (ncores == 0) {
+		pr_err("%s: strange CM count of 0? Default to 1\n", __func__);
+		ncores = 1;
+	}
+
+	if (ncores > NR_CPUS) {
+		pr_warn("%s: no. of cores (%d) greater than configured "
+		       "maximum of %d - clipping\n", __func__, ncores, NR_CPUS);
+		ncores = NR_CPUS;
+	}
+
+	for (i = 0; i < ncores; i++)
+		set_cpu_possible(i, true);
+}
+
+void __init scu_prepare_cpus(void __iomem *scu_base, unsigned int max_cpus)
+{
+	unsigned int ncores = num_possible_cpus();
+	unsigned int cpu = smp_processor_id();
+	int i;
+
+	smp_store_cpu_info(cpu);
+
+	/*
+	 * are we trying to boot more cores than exist?
+	 */
+	if (max_cpus > ncores)
+		max_cpus = ncores;
+
+	/*
+	 * Initialise the present map, which describes the set of CPUs
+	 * actually populated at the present time.
+	 */
+	for (i = 0; i < max_cpus; i++)
+		set_cpu_present(i, true);
+
+	/*
+	 * Initialise the SCU if there are more than one CPU and let
+	 * them know where to start.
+	 */

arch/arm/kernel/smp_scu_boot.c line 149

Quoted 10 lines
arch/arm/kernel/smp_scu_boot.c new file +10 -0
+	if (max_cpus > 1) {
+		/*
+		 * Enable the local timer or broadcast device for the
+		 * boot CPU, but only if we have more than one CPU.
+		 */
+		percpu_timer_setup();
+
+		scu_enable(scu_base);
+	}
+}

Note that I'll go with factoring this out into arch/arm/kernel/smp_scu.c for the time being, but I'm not convinced about the other parts yet.

arch/arm/kernel/smp_scu_head.S line 28

Quoted 5 lines
arch/arm/kernel/smp_scu_head.S new file +5 -0
+	sub	r4, r4, r5
+	add	r6, r6, r4
+#if __LINUX_ARM_ARCH__ >= 7
+	dsb
+#endif

Another question though - probably for Linus though - why is the u8500 code needing this dsb whereas other ARMv7 implementations don't appear to require it?

#4 lore raw

Re: [PATCH 1/8] ARM: SCU: Add common routines for secondary CPU bootup

Quoted 2 lines · Russell King - ARM Linux

Note that I'll go with factoring this out into arch/arm/kernel/smp_scu.c for the time being, but I'm not convinced about the other parts yet.

IOW, something like the attached. I've gone a little further and removed the now unnecessary scu_enable() and scu_get_core_count() global functions, making scu_enable() static, and eliminating scu_get_core_count() entirely.

 arch/arm/include/asm/smp_scu.h   |    4 +-
 arch/arm/kernel/smp_scu.c        |   65 +++++++++++++++++++++++++++++++------
 arch/arm/mach-omap2/omap-smp.c   |   61 ++--------------------------------
 arch/arm/mach-realview/platsmp.c |   66 ++------------------------------------
 arch/arm/mach-s5pv310/platsmp.c  |   58 ++-------------------------------
 arch/arm/mach-tegra/platsmp.c    |   37 +--------------------
 arch/arm/mach-ux500/platsmp.c    |   48 ++--------------------------
 arch/arm/mach-vexpress/platsmp.c |   58 ++-------------------------------
 8 files changed, 76 insertions(+), 321 deletions(-)
arch/arm/include/asm/smp_scu.h +2 -2
index 2376835..9807fb4 100644
@@ -1,7 +1,7 @@
 #ifndef __ASMARM_ARCH_SCU_H
 #define __ASMARM_ARCH_SCU_H
 
-unsigned int scu_get_core_count(void __iomem *);
-void scu_enable(void __iomem *);
+void scu_init_cpus(void __iomem *);
+void scu_prepare_cpus(void __iomem *, unsigned int);
 
 #endif
arch/arm/kernel/asm-offsets.c +0 -0
arch/arm/kernel/smp_scu.c +55 -10

82 lines not on this page · raw message

arch/arm/mach-omap2/omap-smp.c +4 -57

86 lines not on this page · raw message

arch/arm/mach-realview/platsmp.c +3 -63

88 lines not on this page · raw message

arch/arm/mach-s5pv310/platsmp.c +4 -54

80 lines not on this page · raw message

arch/arm/mach-tegra/platsmp.c +2 -35
index 1c0fd92..3b6bcca 100644
@@ -22,7 +22,6 @@
 #include <asm/cacheflush.h>
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
-#include <asm/localtimer.h>
 #include <asm/smp_scu.h>
 
 #include <mach/iomap.h>
@@ -115,42 +114,10 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
  */
 void __init smp_init_cpus(void)
 {
-	unsigned int i, ncores = scu_get_core_count(scu_base);
-
-	for (i = 0; i < ncores; i++)
-		cpu_set(i, cpu_possible_map);
+	scu_init_cpus(scu_base);
 }
 
 void __init smp_prepare_cpus(unsigned int max_cpus)
 {
-	unsigned int ncores = scu_get_core_count(scu_base);
-	unsigned int cpu = smp_processor_id();
-	int i;
-
-	smp_store_cpu_info(cpu);
-
-	/*
-	 * are we trying to boot more cores than exist?
-	 */
-	if (max_cpus > ncores)
-		max_cpus = ncores;
-
-	/*
-	 * Initialise the present map, which describes the set of CPUs
-	 * actually populated at the present time.
-	 */
-	for (i = 0; i < max_cpus; i++)
-		set_cpu_present(i, true);
-
-	/*
-	 * Initialise the SCU if there are more than one CPU and let
-	 * them know where to start. Note that, on modern versions of
-	 * MILO, the "poke" doesn't actually do anything until each
-	 * individual core is sent a soft interrupt to get it out of
-	 * WFI
-	 */
-	if (max_cpus > 1) {
-		percpu_timer_setup();
-		scu_enable(scu_base);
-	}
+	scu_prepare_cpus(scu_base, max_cpus);
 }
arch/arm/mach-ux500/platsmp.c +3 -45

69 lines not on this page · raw message

arch/arm/mach-vexpress/platsmp.c +3 -55

75 lines not on this page · raw message

#5 lore raw

Re: [PATCH 1/8] ARM: SCU: Add common routines for secondary CPU bootup

Quoted 7 lines · Russell King - ARM Linux
Quoted 2 lines · Russell King - ARM Linux

Note that I'll go with factoring this out into arch/arm/kernel/smp_scu.c for the time being, but I'm not convinced about the other parts yet.

IOW, something like the attached. ?I've gone a little further and removed the now unnecessary scu_enable() and scu_get_core_count() global functions, making scu_enable() static, and eliminating scu_get_core_count() entirely.

There is some benefit in leaving get_core_count() in the platform code. For example, the SCU on Cortex-A15 doesn't expose the core count register and we have to get it from somewhere else (for now from some L2 cache controller register but in the future it may be hardcoded, passed via FDT or simply trying to boot maxcpus).

Signature · 1 line
Catalin
#6 lore raw

Re: [PATCH 1/8] ARM: SCU: Add common routines for secondary CPU bootup

Quoted 10 lines · Catalin Marinas
Quoted 7 lines · Russell King - ARM Linux
Quoted 2 lines · Russell King - ARM Linux

Note that I'll go with factoring this out into arch/arm/kernel/smp_scu.c for the time being, but I'm not convinced about the other parts yet.

IOW, something like the attached. ?I've gone a little further and removed the now unnecessary scu_enable() and scu_get_core_count() global functions, making scu_enable() static, and eliminating scu_get_core_count() entirely.

Quoted 5 lines

There is some benefit in leaving get_core_count() in the platform code. For example, the SCU on Cortex-A15 doesn't expose the core count register and we have to get it from somewhere else (for now from some L2 cache controller register but in the future it may be hardcoded, passed via FDT or simply trying to boot maxcpus).

I notice that there's no way to tell what revision of SCU is implemented on _any_ mpcore platform.

In light of that, I think there's no point what so ever trying to consolidate this code - even the control register bits vary in unpredictable ways between different MPcore implementations.

So we can't say "this is a SCU X and this is its register layout."

And really, having it undetectable except via DT (which from what I can see, isn't happening any time soon) or via a command line argument isn't acceptable.

So I think the idea of consolidating the SCU code is a lost cause.

#7 lore raw

Re: [PATCH 1/8] ARM: SCU: Add common routines for secondary CPU bootup

Quoted 11 lines · Russell King - ARM Linux
Quoted 10 lines · Catalin Marinas
Quoted 7 lines · Russell King - ARM Linux
Quoted 2 lines · Russell King - ARM Linux

Note that I'll go with factoring this out into arch/arm/kernel/smp_scu.c for the time being, but I'm not convinced about the other parts yet.

IOW, something like the attached. I've gone a little further and removed the now unnecessary scu_enable() and scu_get_core_count() global functions, making scu_enable() static, and eliminating scu_get_core_count() entirely.

Quoted 8 lines
Quoted 5 lines

There is some benefit in leaving get_core_count() in the platform code. For example, the SCU on Cortex-A15 doesn't expose the core count register and we have to get it from somewhere else (for now from some L2 cache controller register but in the future it may be hardcoded, passed via FDT or simply trying to boot maxcpus).

I notice that there's no way to tell what revision of SCU is implemented on _any_ mpcore platform.

C-A15 doesn't have any SCU registers exposed (and it's enabled by default).

Quoted 3 lines

In light of that, I think there's no point what so ever trying to consolidate this code - even the control register bits vary in unpredictable ways between different MPcore implementations.

The SCU is part of the core TRM, so I don't expect it to be the same across various MP cores (and A15 is an example).

You may want to consolidate functions like scu_prepare_cpus (maybe call it smp_prepare_cpus) and something that calls set_cpu_possible() but with platform callbacks for getting the number of calls and initialising the SMP (SCU for most platforms).

Whether this is worth, I don't know.

Signature · 1 line
Catalin
#8 lore raw

Re: [PATCH 1/8] ARM: SCU: Add common routines for secondary CPU bootup

Quoted 5 lines · Catalin Marinas

The SCU is part of the core TRM, so I don't expect it to be the same across various MP cores (and A15 is an example).

You may want to consolidate functions like scu_prepare_cpus (maybe call it smp_prepare_cpus)

You do realise the function called from architecture independent code is called 'smp_prepare_cpus' ?

Quoted 3 lines

and something that calls set_cpu_possible() but
with platform callbacks for getting the number of calls and initialising the SMP (SCU for most platforms).

What if a platform, for what ever reason, wants to have 3 CPUs, numbered 0, 2, 3 ? That's the reason why the code which sets the possible and present maps isn't in the ARM core code - Eg, we don't know if a platform wants to keep CPU 1 in AMP mode to run some special software on it.

Quoted 1 line

Whether this is worth, I don't know.

I don't think it's worth it because I think trying to considate this is going to cripple the code structure in the future.

What we currently have is a nice sane separation of the core SMP support from the platform specific parts of the SMP support.

BTW, is it worth making sure that the IC and SCU standby mode bits are set for A9 MPCore ?

#9 lore raw

Re: [PATCH 1/8] ARM: SCU: Add common routines for secondary CPU bootup

Quoted 9 lines · Russell King - ARM Linux
Quoted 5 lines · Catalin Marinas

The SCU is part of the core TRM, so I don't expect it to be the same across various MP cores (and A15 is an example).

You may want to consolidate functions like scu_prepare_cpus (maybe call it smp_prepare_cpus)

You do realise the function called from architecture independent code is called 'smp_prepare_cpus' ?

It indeed looked familiar when I wrote it down :)

Quoted 2 lines

BTW, is it worth making sure that the IC and SCU standby mode bits are set for A9 MPCore ?

IMHO I would leave such default settings to the boot monitor as it knows better whether such feature works or has any benefits. If you want to always set the bits, it may need trying on a few A9 platforms to make sure they still work.

Signature · 1 line
Catalin
#10 lore raw

Re: [PATCH 1/8] ARM: SCU: Add common routines for secondary CPU bootup

In reply to Russell King - ARM Linux
Quoted 8 lines · Russell King - ARM Linux

What if a platform, for what ever reason, wants to have 3 CPUs, numbered 0, 2, 3 ? That's the reason why the code which sets the possible and present maps isn't in the ARM core code - Eg, we don't know if a platform wants to keep CPU 1 in AMP mode to run some special software on it.

I don't think it's worth it because I think trying to considate this is going to cripple the code structure in the future.

I don't think this is particularly worth it either:

8e511800fe64114d00b6a22c6e37a510b208785e

 arch/arm/include/asm/smp.h       |   14 ++++++-
 arch/arm/kernel/smp.c            |   71 ++++++++++++++++++++++++++++++++------
 arch/arm/kernel/smp_scu.c        |    2 +-
 arch/arm/mach-omap2/omap-smp.c   |   67 +++---------------------------------
 arch/arm/mach-realview/platsmp.c |   71 ++++---------------------------------
 arch/arm/mach-s5pv310/platsmp.c  |   63 ++++-----------------------------
 arch/arm/mach-tegra/platsmp.c    |   39 ++-------------------
 arch/arm/mach-ux500/platsmp.c    |   55 +++--------------------------
 arch/arm/mach-vexpress/platsmp.c |   69 +++++-------------------------------
 9 files changed, 113 insertions(+), 338 deletions(-)
arch/arm/include/asm/smp.h +12 -2
index f93d0a6..99dd48b 100644
@@ -46,9 +46,14 @@ asmlinkage void do_IPI(int ipinr, struct pt_regs *regs);
 extern void smp_init_cpus(void);
 
 /*
- * Move global data into per-processor storage.
+ * Initialize cpu_possible map for 0 .. CPUs.
  */
-extern void smp_store_cpu_info(unsigned int cpuid);
+void smp_init_cpu_possible(unsigned int);
+
+/*
+ * Initialize cpu_present map for 0 .. CPUs.
+ */
+void smp_init_cpu_present(unsigned int);
 
 /*
  * Raise an IPI cross call on CPUs in callmap.
@@ -73,6 +78,11 @@ asmlinkage void secondary_start_kernel(void);
 extern void platform_secondary_init(unsigned int cpu);
 
 /*
+ * Initialize cpu_possible map, and enable coherency
+ */
+extern void platform_smp_prepare_cpus(unsigned int);
+
+/*
  * Initial data for bringing up a secondary CPU.
  */
 struct secondary_data {
arch/arm/kernel/smp.c +60 -11

89 lines not on this page · raw message

arch/arm/kernel/smp_scu.c +1 -1
index 9ab4149..904b77b 100644
@@ -11,8 +11,8 @@
 #include <linux/init.h>
 #include <linux/io.h>
 
-#include <asm/smp_scu.h>
 #include <asm/cacheflush.h>
+#include <asm/smp_scu.h>
 
 #define SCU_CTRL		0x00
 #define SCU_CONFIG		0x04
arch/arm/mach-omap2/omap-smp.c +5 -62

93 lines not on this page · raw message

arch/arm/mach-realview/platsmp.c +8 -63

93 lines not on this page · raw message

arch/arm/mach-s5pv310/platsmp.c +8 -55

83 lines not on this page · raw message

arch/arm/mach-tegra/platsmp.c +3 -36
index 1c0fd92..abbb97b 100644
@@ -22,7 +22,6 @@
 #include <asm/cacheflush.h>
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
-#include <asm/localtimer.h>
 #include <asm/smp_scu.h>
 
 #include <mach/iomap.h>
@@ -115,42 +114,10 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
  */
 void __init smp_init_cpus(void)
 {
-	unsigned int i, ncores = scu_get_core_count(scu_base);
-
-	for (i = 0; i < ncores; i++)
-		cpu_set(i, cpu_possible_map);
+	smp_init_cpu_possible(scu_get_core_count(scu_base));
 }
 
-void __init smp_prepare_cpus(unsigned int max_cpus)
+void __init platform_smp_prepare_cpus(unsigned int max_cpus)
 {
-	unsigned int ncores = scu_get_core_count(scu_base);
-	unsigned int cpu = smp_processor_id();
-	int i;
-
-	smp_store_cpu_info(cpu);
-
-	/*
-	 * are we trying to boot more cores than exist?
-	 */
-	if (max_cpus > ncores)
-		max_cpus = ncores;
-
-	/*
-	 * Initialise the present map, which describes the set of CPUs
-	 * actually populated at the present time.
-	 */
-	for (i = 0; i < max_cpus; i++)
-		set_cpu_present(i, true);
-
-	/*
-	 * Initialise the SCU if there are more than one CPU and let
-	 * them know where to start. Note that, on modern versions of
-	 * MILO, the "poke" doesn't actually do anything until each
-	 * individual core is sent a soft interrupt to get it out of
-	 * WFI
-	 */
-	if (max_cpus > 1) {
-		percpu_timer_setup();
-		scu_enable(scu_base);
-	}
+	smp_init_cpu_present(max_cpus);
 }
arch/arm/mach-ux500/platsmp.c +6 -49

79 lines not on this page · raw message

arch/arm/mach-vexpress/platsmp.c +10 -59

89 lines not on this page · raw message

#11 lore raw

Re: [PATCH 1/8] ARM: SCU: Add common routines for secondary CPU bootup

Quoted 11 lines · Russell King - ARM Linux
Quoted 8 lines · Russell King - ARM Linux

What if a platform, for what ever reason, wants to have 3 CPUs, numbered 0, 2, 3 ? That's the reason why the code which sets the possible and present maps isn't in the ARM core code - Eg, we don't know if a platform wants to keep CPU 1 in AMP mode to run some special software on it.

I don't think it's worth it because I think trying to considate this is going to cripple the code structure in the future.

I don't think this is particularly worth it either:

As Catalin has pointed out:

http://lists.arm.linux.org.uk/lurker/message/20101202.162840.5465758c.en.html

The SCU is part of the core, and if you consult the TRMs for the MPCore devices, it is actually different in ARM11 MPCore vs Cortex-A9 MPCore. Cortex-A15 doesn't have a MMIO addressable SCU at all.

So, this is about as far as I want to go with stripping out the common code from the various platforms (this includes my previous SMP series):

http://lists.arm.linux.org.uk/lurker/message/20101203.200746.31424430.en.html

This results in a net reduction of 242 LOC, as shown in the following diffstat:

 arch/arm/include/asm/hardirq.h            |   18 ++
 arch/arm/include/asm/mach/irq.h           |    2 +-
 arch/arm/include/asm/smp.h                |   17 +-
 arch/arm/include/asm/smp_mpidr.h          |   17 --
 arch/arm/kernel/entry-armv.S              |    2 +-
 arch/arm/kernel/fiq.c                     |    5 +-
 arch/arm/kernel/head.S                    |   39 +++--
 arch/arm/kernel/irq.c                     |   23 ++-
 arch/arm/kernel/smp.c                     |  243 ++++++++++++++++-------------
 arch/arm/mach-msm/include/mach/smp.h      |    4 +-
 arch/arm/mach-omap2/omap-hotplug.c        |   14 +--
 arch/arm/mach-omap2/omap-smp.c            |   66 ++------
 arch/arm/mach-realview/hotplug.c          |   18 +--
 arch/arm/mach-realview/include/mach/smp.h |    5 +-
 arch/arm/mach-realview/platsmp.c          |   95 +++---------
 arch/arm/mach-s5pv310/hotplug.c           |   18 +--
 arch/arm/mach-s5pv310/include/mach/smp.h  |    5 +-
 arch/arm/mach-s5pv310/platsmp.c           |   46 +-----
 arch/arm/mach-tegra/hotplug.c             |   18 +--
 arch/arm/mach-tegra/include/mach/smp.h    |   12 +--
 arch/arm/mach-tegra/platsmp.c             |   33 +---
 arch/arm/mach-ux500/hotplug.c             |   18 +--
 arch/arm/mach-ux500/include/mach/smp.h    |    5 +-
 arch/arm/mach-ux500/platsmp.c             |   57 ++-----
 arch/arm/mach-vexpress/include/mach/smp.h |    5 +-
 arch/arm/mach-vexpress/platsmp.c          |   54 ++-----
 arch/arm/plat-omap/include/plat/smp.h     |    5 +-
 27 files changed, 301 insertions(+), 543 deletions(-)

Can someone also explain why OMAP uses different file naming from everyone else? It's annoying as (eg) arch/arm/*/platsmp.c for editing the platform SMP support files gets everyone except OMAP.

#12 lore raw

RE: [PATCH 1/8] ARM: SCU: Add common routines for secondary CPUbootup

Quoted 7 lines

-----Original Message-----
From: linux-omap-owner at vger.kernel.org [mailto:linux-omap- owner at vger.kernel.org] On Behalf Of Russell King - ARM Linux
Sent: Saturday, December 04, 2010 2:18 PM
To: Tony Lindgren; Kukjin Kim; Srinidhi Kasagar; Jamie Iles; Anton Vorontsov; linux-kernel at vger.kernel.org; linux-samsung- soc at vger.kernel.org; Colin Cross; linux-tegra at vger.kernel.org; Uwe

Kleine-

Quoted 5 lines

K?nig; linux-omap at vger.kernel.org; linux-arm-kernel at lists.infradead.org
Subject: Re: [PATCH 1/8] ARM: SCU: Add common routines for secondary CPUbootup

On Thu, Dec 02, 2010 at 06:01:50PM +0000, Russell King - ARM Linux

Quoted 8 lines · wrote:
Quoted 1 line

On Thu, Dec 02, 2010 at 05:38:24PM +0000, Russell King - ARM Linux

Quoted 6 lines · wrote:
Quoted 6 lines

What if a platform, for what ever reason, wants to have 3 CPUs, numbered 0, 2, 3 ? That's the reason why the code which sets the possible and present maps isn't in the ARM core code - Eg, we don't know if a platform wants to keep CPU 1 in AMP mode to run some special software on it.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

I don't think it's worth it because I think trying to considate this is going to cripple the code structure in the future.

I don't think this is particularly worth it either:

As Catalin has pointed out:

http://lists.arm.linux.org.uk/lurker/message/20101202.162840.5465758c.en.h

Quoted 10 lines

tml

The SCU is part of the core, and if you consult the TRMs for the MPCore devices, it is actually different in ARM11 MPCore vs Cortex-A9 MPCore. Cortex-A15 doesn't have a MMIO addressable SCU at all.

So, this is about as far as I want to go with stripping out the common code from the various platforms (this includes my previous SMP series):

http://lists.arm.linux.org.uk/lurker/message/20101203.200746.31424430.en.h

Quoted 5 lines

tml

This results in a net reduction of 242 LOC, as shown in the following diffstat:

Quoted 9 lines
 arch/arm/include/asm/hardirq.h            |   18 ++
 arch/arm/include/asm/mach/irq.h           |    2 +-
 arch/arm/include/asm/smp.h                |   17 +-
 arch/arm/include/asm/smp_mpidr.h          |   17 --
 arch/arm/kernel/entry-armv.S              |    2 +-
 arch/arm/kernel/fiq.c                     |    5 +-
 arch/arm/kernel/head.S                    |   39 +++--
 arch/arm/kernel/irq.c                     |   23 ++-
 arch/arm/kernel/smp.c                     |  243

++++++++++++++++--------

Quoted 21 lines

-----

 arch/arm/mach-msm/include/mach/smp.h      |    4 +-
 arch/arm/mach-omap2/omap-hotplug.c        |   14 +--
 arch/arm/mach-omap2/omap-smp.c            |   66 ++------
 arch/arm/mach-realview/hotplug.c          |   18 +--
 arch/arm/mach-realview/include/mach/smp.h |    5 +-
 arch/arm/mach-realview/platsmp.c          |   95 +++---------
 arch/arm/mach-s5pv310/hotplug.c           |   18 +--
 arch/arm/mach-s5pv310/include/mach/smp.h  |    5 +-
 arch/arm/mach-s5pv310/platsmp.c           |   46 +-----
 arch/arm/mach-tegra/hotplug.c             |   18 +--
 arch/arm/mach-tegra/include/mach/smp.h    |   12 +--
 arch/arm/mach-tegra/platsmp.c             |   33 +---
 arch/arm/mach-ux500/hotplug.c             |   18 +--
 arch/arm/mach-ux500/include/mach/smp.h    |    5 +-
 arch/arm/mach-ux500/platsmp.c             |   57 ++-----
 arch/arm/mach-vexpress/include/mach/smp.h |    5 +-
 arch/arm/mach-vexpress/platsmp.c          |   54 ++-----
 arch/arm/plat-omap/include/plat/smp.h     |    5 +-
 27 files changed, 301 insertions(+), 543 deletions(-)
Quoted 1 line

Can someone also explain why OMAP uses different file naming from

everyone

Quoted 1 line

else? It's annoying as (eg) arch/arm/*/platsmp.c for editing the

platform

Quoted 1 line

SMP support files gets everyone except OMAP.

Nothing specific Russell?.
Its just to keep in sync with the way other files are named under omap directories. We could rename this if it helps.

Regards,
Ssantosh

#13 lore raw

RE: [PATCH 1/8] ARM: SCU: Add common routines for secondary CPUbootup

In reply to Russell King - ARM Linux
Quoted 7 lines

-----Original Message-----
From: [email protected] [mailto:linux-omap- [email protected]] On Behalf Of Russell King - ARM Linux
Sent: Saturday, December 04, 2010 2:18 PM
To: Tony Lindgren; Kukjin Kim; Srinidhi Kasagar; Jamie Iles; Anton Vorontsov; [email protected]; linux-samsung- [email protected]; Colin Cross; [email protected]; Uwe

Kleine-

Quoted 5 lines

König; [email protected]; [email protected]
Subject: Re: [PATCH 1/8] ARM: SCU: Add common routines for secondary CPUbootup

On Thu, Dec 02, 2010 at 06:01:50PM +0000, Russell King - ARM Linux

Quoted 8 lines · wrote:
Quoted 1 line

On Thu, Dec 02, 2010 at 05:38:24PM +0000, Russell King - ARM Linux

Quoted 6 lines · wrote:
Quoted 6 lines

What if a platform, for what ever reason, wants to have 3 CPUs, numbered 0, 2, 3 ? That's the reason why the code which sets the possible and present maps isn't in the ARM core code - Eg, we don't know if a platform wants to keep CPU 1 in AMP mode to run some special software on it.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

I don't think it's worth it because I think trying to considate this is going to cripple the code structure in the future.

I don't think this is particularly worth it either:

As Catalin has pointed out:

http://lists.arm.linux.org.uk/lurker/message/20101202.162840.5465758c.en.h

Quoted 10 lines

tml

The SCU is part of the core, and if you consult the TRMs for the MPCore devices, it is actually different in ARM11 MPCore vs Cortex-A9 MPCore. Cortex-A15 doesn't have a MMIO addressable SCU at all.

So, this is about as far as I want to go with stripping out the common code from the various platforms (this includes my previous SMP series):

http://lists.arm.linux.org.uk/lurker/message/20101203.200746.31424430.en.h

Quoted 5 lines

tml

This results in a net reduction of 242 LOC, as shown in the following diffstat:

Quoted 9 lines
 arch/arm/include/asm/hardirq.h            |   18 ++
 arch/arm/include/asm/mach/irq.h           |    2 +-
 arch/arm/include/asm/smp.h                |   17 +-
 arch/arm/include/asm/smp_mpidr.h          |   17 --
 arch/arm/kernel/entry-armv.S              |    2 +-
 arch/arm/kernel/fiq.c                     |    5 +-
 arch/arm/kernel/head.S                    |   39 +++--
 arch/arm/kernel/irq.c                     |   23 ++-
 arch/arm/kernel/smp.c                     |  243

++++++++++++++++--------

Quoted 21 lines

-----

 arch/arm/mach-msm/include/mach/smp.h      |    4 +-
 arch/arm/mach-omap2/omap-hotplug.c        |   14 +--
 arch/arm/mach-omap2/omap-smp.c            |   66 ++------
 arch/arm/mach-realview/hotplug.c          |   18 +--
 arch/arm/mach-realview/include/mach/smp.h |    5 +-
 arch/arm/mach-realview/platsmp.c          |   95 +++---------
 arch/arm/mach-s5pv310/hotplug.c           |   18 +--
 arch/arm/mach-s5pv310/include/mach/smp.h  |    5 +-
 arch/arm/mach-s5pv310/platsmp.c           |   46 +-----
 arch/arm/mach-tegra/hotplug.c             |   18 +--
 arch/arm/mach-tegra/include/mach/smp.h    |   12 +--
 arch/arm/mach-tegra/platsmp.c             |   33 +---
 arch/arm/mach-ux500/hotplug.c             |   18 +--
 arch/arm/mach-ux500/include/mach/smp.h    |    5 +-
 arch/arm/mach-ux500/platsmp.c             |   57 ++-----
 arch/arm/mach-vexpress/include/mach/smp.h |    5 +-
 arch/arm/mach-vexpress/platsmp.c          |   54 ++-----
 arch/arm/plat-omap/include/plat/smp.h     |    5 +-
 27 files changed, 301 insertions(+), 543 deletions(-)
Quoted 1 line

Can someone also explain why OMAP uses different file naming from

everyone

Quoted 1 line

else? It's annoying as (eg) arch/arm/*/platsmp.c for editing the

platform

Quoted 1 line

SMP support files gets everyone except OMAP.

Nothing specific Russell?.
Its just to keep in sync with the way other files are named under omap directories. We could rename this if it helps.

Regards,
Ssantosh

#14 lore raw

Re: [PATCH 1/8] ARM: SCU: Add common routines for secondary CPU bootup

In reply to Russell King - ARM Linux
Quoted 11 lines · Russell King - ARM Linux
Quoted 8 lines · Russell King - ARM Linux

What if a platform, for what ever reason, wants to have 3 CPUs, numbered 0, 2, 3 ? That's the reason why the code which sets the possible and present maps isn't in the ARM core code - Eg, we don't know if a platform wants to keep CPU 1 in AMP mode to run some special software on it.

I don't think it's worth it because I think trying to considate this is going to cripple the code structure in the future.

I don't think this is particularly worth it either:

As Catalin has pointed out:

http://lists.arm.linux.org.uk/lurker/message/20101202.162840.5465758c.en.html

The SCU is part of the core, and if you consult the TRMs for the MPCore devices, it is actually different in ARM11 MPCore vs Cortex-A9 MPCore. Cortex-A15 doesn't have a MMIO addressable SCU at all.

So, this is about as far as I want to go with stripping out the common code from the various platforms (this includes my previous SMP series):

http://lists.arm.linux.org.uk/lurker/message/20101203.200746.31424430.en.html

This results in a net reduction of 242 LOC, as shown in the following diffstat:

 arch/arm/include/asm/hardirq.h            |   18 ++
 arch/arm/include/asm/mach/irq.h           |    2 +-
 arch/arm/include/asm/smp.h                |   17 +-
 arch/arm/include/asm/smp_mpidr.h          |   17 --
 arch/arm/kernel/entry-armv.S              |    2 +-
 arch/arm/kernel/fiq.c                     |    5 +-
 arch/arm/kernel/head.S                    |   39 +++--
 arch/arm/kernel/irq.c                     |   23 ++-
 arch/arm/kernel/smp.c                     |  243 ++++++++++++++++-------------
 arch/arm/mach-msm/include/mach/smp.h      |    4 +-
 arch/arm/mach-omap2/omap-hotplug.c        |   14 +--
 arch/arm/mach-omap2/omap-smp.c            |   66 ++------
 arch/arm/mach-realview/hotplug.c          |   18 +--
 arch/arm/mach-realview/include/mach/smp.h |    5 +-
 arch/arm/mach-realview/platsmp.c          |   95 +++---------
 arch/arm/mach-s5pv310/hotplug.c           |   18 +--
 arch/arm/mach-s5pv310/include/mach/smp.h  |    5 +-
 arch/arm/mach-s5pv310/platsmp.c           |   46 +-----
 arch/arm/mach-tegra/hotplug.c             |   18 +--
 arch/arm/mach-tegra/include/mach/smp.h    |   12 +--
 arch/arm/mach-tegra/platsmp.c             |   33 +---
 arch/arm/mach-ux500/hotplug.c             |   18 +--
 arch/arm/mach-ux500/include/mach/smp.h    |    5 +-
 arch/arm/mach-ux500/platsmp.c             |   57 ++-----
 arch/arm/mach-vexpress/include/mach/smp.h |    5 +-
 arch/arm/mach-vexpress/platsmp.c          |   54 ++-----
 arch/arm/plat-omap/include/plat/smp.h     |    5 +-
 27 files changed, 301 insertions(+), 543 deletions(-)

Can someone also explain why OMAP uses different file naming from everyone else? It's annoying as (eg) arch/arm/*/platsmp.c for editing the platform SMP support files gets everyone except OMAP.

#15 lore raw

Re: [PATCH 1/8] ARM: SCU: Add common routines for secondary CPU bootup

In reply to Russell King - ARM Linux
Quoted 1 line · Russell King - ARM Linux

On Tue, Nov 30, 2010 at 08:16:58PM +0300, Anton Vorontsov wrote:

[...]

Quoted 9 lines

arch/arm/kernel/smp_scu_head.S line 28

Quoted 5 lines

+ ? ? sub ? ? r4, r4, r5
+ ? ? add ? ? r6, r6, r4

arch/arm/kernel/smp_scu_head.S new file +3 -0
+#if __LINUX_ARM_ARCH__ >= 7
+ ? ? dsb
+#endif

Another question though - probably for Linus though - why is the u8500 code needing this dsb whereas other ARMv7 implementations don't appear to require it?

No strong reason, we can safely ignore this now.

srinidhi

#16 lore raw

PATCH v4 2/8 ARM: cns3xxx: Add support for SMP

In reply to Anton Vorontsov

Nothing fancy needs to be done, just use generic SCU routines.

---
 arch/arm/Kconfig                         |    2 +-
 arch/arm/mach-cns3xxx/Kconfig            |    1 +
 arch/arm/mach-cns3xxx/Makefile           |    1 +
 arch/arm/mach-cns3xxx/include/mach/smp.h |   28 ++++++++++++
 arch/arm/mach-cns3xxx/platsmp.c          |   69 ++++++++++++++++++++++++++++++
 5 files changed, 100 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-cns3xxx/include/mach/smp.h
 create mode 100644 arch/arm/mach-cns3xxx/platsmp.c
arch/arm/Kconfig +1 -1
index 9aff0e8..38c1697 100644
@@ -1208,7 +1208,7 @@ config SMP
 	depends on REALVIEW_EB_ARM11MP || REALVIEW_EB_A9MP || \
 		 MACH_REALVIEW_PB11MP || MACH_REALVIEW_PBX || ARCH_OMAP4 || \
 		 ARCH_S5PV310 || ARCH_TEGRA || ARCH_U8500 || ARCH_VEXPRESS_CA9X4 || \
-		 ARCH_MSM_SCORPIONMP
+		 ARCH_MSM_SCORPIONMP || ARCH_CNS3XXX
 	select USE_GENERIC_SMP_HELPERS
 	select HAVE_ARM_SCU if !ARCH_MSM_SCORPIONMP
 	help
arch/arm/mach-cns3xxx/Kconfig +1 -0
index 9ebfcc4..0ba82aa 100644
@@ -3,6 +3,7 @@ menu "CNS3XXX platform type"
 
 config MACH_CNS3420VB
 	bool "Support for CNS3420 Validation Board"
+	select HAVE_ARM_SCU if SMP
 	help
 	  Include support for the Cavium Networks CNS3420 MPCore Platform
 	  Baseboard.
arch/arm/mach-cns3xxx/Makefile +1 -0
index 11033f1..ba4ee7b 100644
@@ -1,3 +1,4 @@
 obj-$(CONFIG_ARCH_CNS3XXX)		+= core.o pm.o devices.o
+obj-$(CONFIG_SMP)			+= platsmp.o
 obj-$(CONFIG_PCI)			+= pcie.o
 obj-$(CONFIG_MACH_CNS3420VB)		+= cns3420vb.o
arch/arm/mach-cns3xxx/include/mach/smp.h new file +28 -0
new file mode 100644
index 0000000..44aa7ea
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2002 ARM Ltd.
+ * Copyright 2008 Cavium Networks
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, Version 2, as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __MACH_SMP_H
+#define __MACH_SMP_H
+
+#include <asm/hardware/gic.h>
+
+#define hard_smp_processor_id()				\
+	({						\
+		unsigned int cpunum;			\
+		__asm__("mrc p15, 0, %0, c0, c0, 5"	\
+			: "=r" (cpunum));		\
+		cpunum &= 0x0F;				\
+	})
+
+static inline void smp_cross_call(const struct cpumask *mask, int ipi)
+{
+	gic_raise_softirq(mask, ipi);
+}
+
+#endif /* __MACH_SMP_H */
arch/arm/mach-cns3xxx/platsmp.c new file +69 -0

69 lines not on this page · raw message

Signature · 1 line
1.7.0.5
#17 lore raw

Re: [PATCH 2/8] ARM: cns3xxx: Add support for SMP

Quoted 3 lines · Anton Vorontsov

Nothing fancy needs to be done, just use generic SCU routines.

This I assume is an age old patch.

Quoted 17 lines
arch/arm/mach-cns3xxx/include/mach/smp.h new file +11 -0
new file mode 100644
index 0000000..44aa7ea
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2002 ARM Ltd.
+ * Copyright 2008 Cavium Networks
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, Version 2, as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __MACH_SMP_H
+#define __MACH_SMP_H

arch/arm/mach-cns3xxx/include/mach/smp.h line 21

Quoted 10 lines
arch/arm/mach-cns3xxx/include/mach/smp.h new file +10 -0
+
+#include <asm/hardware/gic.h>
+
+#define hard_smp_processor_id()				\
+	({						\
+		unsigned int cpunum;			\
+		__asm__("mrc p15, 0, %0, c0, c0, 5"	\
+			: "=r" (cpunum));		\
+		cpunum &= 0x0F;				\
+	})

#include <asm/smp_mpidr.h>

replaces this, but it's not actually necessary - it's only used by some bug checking code in the CPU hotplug code. I'm shortly going to be deleting all hard_smp_processor_id() implementations.

#18 lore raw

PATCH v4 3/8 ARM: VExpress: Switch to generic SCU routines

In reply to Anton Vorontsov

This shrinks platform-specific code quite a bit.

---
 arch/arm/mach-vexpress/Makefile  |    2 +-
 arch/arm/mach-vexpress/headsmp.S |   39 ----------
 arch/arm/mach-vexpress/platsmp.c |  150 ++++----------------------------------
 3 files changed, 15 insertions(+), 176 deletions(-)
 delete mode 100644 arch/arm/mach-vexpress/headsmp.S
arch/arm/mach-vexpress/Makefile +1 -1
index 1b71b77..6533d11 100644
@@ -4,5 +4,5 @@
 
 obj-y					:= v2m.o
 obj-$(CONFIG_ARCH_VEXPRESS_CA9X4)	+= ct-ca9x4.o
-obj-$(CONFIG_SMP)			+= platsmp.o headsmp.o
+obj-$(CONFIG_SMP)			+= platsmp.o
 obj-$(CONFIG_LOCAL_TIMERS)		+= localtimer.o
arch/arm/mach-vexpress/headsmp.S deleted +0 -39
deleted file mode 100644
index 8a78ff6..0000000
@@ -1,39 +0,0 @@
-/*
- *  linux/arch/arm/mach-vexpress/headsmp.S
- *
- *  Copyright (c) 2003 ARM Limited
- *  All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/linkage.h>
-#include <linux/init.h>
-
-	__INIT
-
-/*
- * Versatile Express specific entry point for secondary CPUs.  This
- * provides a "holding pen" into which all secondary cores are held
- * until we're ready for them to initialise.
- */
-ENTRY(vexpress_secondary_startup)
-	mrc	p15, 0, r0, c0, c0, 5
-	and	r0, r0, #15
-	adr	r4, 1f
-	ldmia	r4, {r5, r6}
-	sub	r4, r4, r5
-	add	r6, r6, r4
-pen:	ldr	r7, [r6]
-	cmp	r7, r0
-	bne	pen
-
-	/*
-	 * we've been released from the holding pen: secondary_stack
-	 * should now contain the SVC stack for this core
-	 */
-	b	secondary_startup
-
-1:	.long	.
-	.long	pen_release
arch/arm/mach-vexpress/platsmp.c +14 -136

188 lines not on this page · raw message

Signature · 1 line
1.7.0.5
#19 lore raw

Re: [PATCH 3/8] ARM: VExpress: Switch to generic SCU routines

arch/arm/mach-vexpress/platsmp.c void __cpuinit platform_secondary_init(unsigned int cpu) · line 62

Quoted 12 lines · Anton Vorontsov
arch/arm/mach-vexpress/platsmp.c +8 -2
+/* If there are more than one CPU let them know where to start. */
+static void __init smp_point_cpus(void)
+{
+	if (num_present_cpus() <= 1)
+		return;
 
-	for (i = 0; i < ncores; i++)
-		set_cpu_possible(i, true);
+	writel(~0, MMIO_P2V(V2M_SYS_FLAGSCLR));
+	writel(BSYM(virt_to_phys(scu_secondary_startup)),
+	       MMIO_P2V(V2M_SYS_FLAGSSET));
 }

I don't see the point of separating this code from the code below. It doesn't seem to bring any benefit. Could you explain why it's necessary to separate this?

Quoted 2 lines

void __init smp_prepare_cpus(unsigned int max_cpus) {

...

#20 lore raw

PATCH v4 4/8 ARM: RealView: Switch to generic SCU routines

In reply to Anton Vorontsov

This shrinks platform-specific code quite a bit.

---
 arch/arm/mach-realview/Makefile  |    2 +-
 arch/arm/mach-realview/headsmp.S |   39 ---------
 arch/arm/mach-realview/hotplug.c |    5 +-
 arch/arm/mach-realview/platsmp.c |  161 +++-----------------------------------
 4 files changed, 14 insertions(+), 193 deletions(-)
 delete mode 100644 arch/arm/mach-realview/headsmp.S
arch/arm/mach-realview/Makefile +1 -1
index a01b76b..d456163 100644
@@ -8,6 +8,6 @@ obj-$(CONFIG_MACH_REALVIEW_PB11MP)	+= realview_pb11mp.o
 obj-$(CONFIG_MACH_REALVIEW_PB1176)	+= realview_pb1176.o
 obj-$(CONFIG_MACH_REALVIEW_PBA8)	+= realview_pba8.o
 obj-$(CONFIG_MACH_REALVIEW_PBX)		+= realview_pbx.o
-obj-$(CONFIG_SMP)			+= platsmp.o headsmp.o
+obj-$(CONFIG_SMP)			+= platsmp.o
 obj-$(CONFIG_HOTPLUG_CPU)		+= hotplug.o
 obj-$(CONFIG_LOCAL_TIMERS)		+= localtimer.o
arch/arm/mach-realview/headsmp.S deleted +0 -39
deleted file mode 100644
index 4075473..0000000
@@ -1,39 +0,0 @@
-/*
- *  linux/arch/arm/mach-realview/headsmp.S
- *
- *  Copyright (c) 2003 ARM Limited
- *  All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/linkage.h>
-#include <linux/init.h>
-
-	__INIT
-
-/*
- * Realview specific entry point for secondary CPUs.  This provides
- * a "holding pen" into which all secondary cores are held until we're
- * ready for them to initialise.
- */
-ENTRY(realview_secondary_startup)
-	mrc	p15, 0, r0, c0, c0, 5
-	and	r0, r0, #15
-	adr	r4, 1f
-	ldmia	r4, {r5, r6}
-	sub	r4, r4, r5
-	add	r6, r6, r4
-pen:	ldr	r7, [r6]
-	cmp	r7, r0
-	bne	pen
-
-	/*
-	 * we've been released from the holding pen: secondary_stack
-	 * should now contain the SVC stack for this core
-	 */
-	b	secondary_startup
-
-1:	.long	.
-	.long	pen_release
arch/arm/mach-realview/hotplug.c +2 -3
index e06572e..0261785 100644
@@ -12,10 +12,9 @@
 #include <linux/errno.h>
 #include <linux/smp.h>
 
+#include <asm/smp_scu.h>
 #include <asm/cacheflush.h>
 
-extern volatile int pen_release;
-
 static inline void cpu_enter_lowpower(void)
 {
 	unsigned int v;
@@ -69,7 +68,7 @@ static inline void platform_do_lowpower(unsigned int cpu)
 		    :
 		    : "memory", "cc");
 
-		if (pen_release == cpu) {
+		if (scu_pen_release == cpu) {
 			/*
 			 * OK, proper wakeup, we're done
 			 */
arch/arm/mach-realview/platsmp.c +11 -150

209 lines not on this page · raw message

Signature · 1 line
1.7.0.5
#21 lore raw

PATCH v4 5/8 ARM: S5PV310: Switch to generic SCU routines

In reply to Anton Vorontsov

This shrinks platform-specific code quite a bit.

---
 arch/arm/mach-s5pv310/Makefile  |    2 +-
 arch/arm/mach-s5pv310/headsmp.S |   41 -------------
 arch/arm/mach-s5pv310/hotplug.c |    5 +-
 arch/arm/mach-s5pv310/platsmp.c |  125 ++-------------------------------------
 4 files changed, 9 insertions(+), 164 deletions(-)
 delete mode 100644 arch/arm/mach-s5pv310/headsmp.S
arch/arm/mach-s5pv310/Makefile +1 -1
index 84afc64..b72abd2 100644
@@ -15,7 +15,7 @@ obj-				:=
 obj-$(CONFIG_CPU_S5PV310)	+= cpu.o init.o clock.o irq-combiner.o
 obj-$(CONFIG_CPU_S5PV310)	+= setup-i2c0.o time.o gpiolib.o irq-eint.o
 
-obj-$(CONFIG_SMP)		+= platsmp.o headsmp.o
+obj-$(CONFIG_SMP)		+= platsmp.o
 obj-$(CONFIG_LOCAL_TIMERS)	+= localtimer.o
 obj-$(CONFIG_HOTPLUG_CPU)	+= hotplug.o
 
arch/arm/mach-s5pv310/headsmp.S deleted +0 -41

41 lines not on this page · raw message

arch/arm/mach-s5pv310/hotplug.c +2 -3
index ea951ef..ff1bc05 100644
@@ -14,10 +14,9 @@
 #include <linux/errno.h>
 #include <linux/smp.h>
 
+#include <asm/smp_scu.h>
 #include <asm/cacheflush.h>
 
-extern volatile int pen_release;
-
 static inline void cpu_enter_lowpower(void)
 {
 	unsigned int v;
@@ -72,7 +71,7 @@ static inline void platform_do_lowpower(unsigned int cpu)
 		    :
 		    : "memory", "cc");
 
-		if (pen_release == cpu) {
+		if (scu_pen_release == cpu) {
 			/*
 			 * OK, proper wakeup, we're done
 			 */
arch/arm/mach-s5pv310/platsmp.c +6 -119

177 lines not on this page · raw message

Signature · 1 line
1.7.0.5
#22 lore raw

PATCH v4 6/8 ARM: ux500: Switch to generic SCU routines

In reply to Anton Vorontsov

This shrinks platform-specific code quite a bit.

---
 arch/arm/mach-ux500/Makefile           |    2 +-
 arch/arm/mach-ux500/headsmp.S          |   38 -----------
 arch/arm/mach-ux500/hotplug.c          |    5 +-
 arch/arm/mach-ux500/include/mach/smp.h |    3 -
 arch/arm/mach-ux500/platsmp.c          |  115 ++------------------------------
 5 files changed, 10 insertions(+), 153 deletions(-)
 delete mode 100644 arch/arm/mach-ux500/headsmp.S
arch/arm/mach-ux500/Makefile +1 -1
index 9e27a84..90fa03c 100644
@@ -7,7 +7,7 @@ obj-$(CONFIG_UX500_SOC_DB5500)	+= cpu-db5500.o devices-db5500.o
 obj-$(CONFIG_UX500_SOC_DB8500)	+= cpu-db8500.o devices-db8500.o prcmu.o
 obj-$(CONFIG_MACH_U8500_MOP)	+= board-mop500.o board-mop500-sdi.o
 obj-$(CONFIG_MACH_U5500)	+= board-u5500.o
-obj-$(CONFIG_SMP)		+= platsmp.o headsmp.o
+obj-$(CONFIG_SMP)		+= platsmp.o
 obj-$(CONFIG_HOTPLUG_CPU)	+= hotplug.o
 obj-$(CONFIG_LOCAL_TIMERS)	+= localtimer.o
 obj-$(CONFIG_REGULATOR_AB8500)	+= board-mop500-regulators.o
arch/arm/mach-ux500/headsmp.S deleted +0 -38
deleted file mode 100644
index a6be2cd..0000000
@@ -1,38 +0,0 @@
-/*
- *  Copyright (c) 2009 ST-Ericsson
- *	This file is based  ARM Realview platform
- *  Copyright (c) 2003 ARM Limited
- *  All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#include <linux/linkage.h>
-#include <linux/init.h>
-
-	__INIT
-
-/*
- * U8500 specific entry point for secondary CPUs.
- */
-ENTRY(u8500_secondary_startup)
-	mrc	p15, 0, r0, c0, c0, 5
-	and	r0, r0, #15
-	adr	r4, 1f
-	ldmia	r4, {r5, r6}
-	sub	r4, r4, r5
-	add	r6, r6, r4
-	dsb
-pen:	ldr	r7, [r6]
-	cmp	r7, r0
-	bne	pen
-
-	/*
-	 * we've been released from the holding pen: secondary_stack
-	 * should now contain the SVC stack for this core
-	 */
-	b	secondary_startup
-
-1:	.long	.
-	.long	pen_release
arch/arm/mach-ux500/hotplug.c +2 -3
index dd8037e..38f4e1b 100644
@@ -12,10 +12,9 @@
 #include <linux/errno.h>
 #include <linux/smp.h>
 
+#include <asm/smp_scu.h>
 #include <asm/cacheflush.h>
 
-extern volatile int pen_release;
-
 static inline void platform_do_lowpower(unsigned int cpu)
 {
 	flush_cache_all();
@@ -24,7 +23,7 @@ static inline void platform_do_lowpower(unsigned int cpu)
 	for (;;) {
 		__asm__ __volatile__("dsb\n\t" "wfi\n\t"
 				: : : "memory");
-		if (pen_release == cpu) {
+		if (scu_pen_release == cpu) {
 			/*
 			 * OK, proper wakeup, we're done
 			 */
arch/arm/mach-ux500/include/mach/smp.h +0 -3
index bd57c50..646cea7 100644
@@ -12,9 +12,6 @@
 #include <asm/hardware/gic.h>
 #include <asm/smp_mpidr.h>
 
-/* This is required to wakeup the secondary core */
-extern void u8500_secondary_startup(void);
-
 /*
  * We use IRQ1 as the IPI
  */
arch/arm/mach-ux500/platsmp.c +7 -108

158 lines not on this page · raw message

Signature · 1 line
1.7.0.5
#23 lore raw

PATCH v4 7/8 ARM: tegra: Switch to generic SCU routines

In reply to Anton Vorontsov

This shrinks platform-specific code a little bit.

---
 arch/arm/mach-tegra/platsmp.c |   36 ++----------------------------------
 1 files changed, 2 insertions(+), 34 deletions(-)
arch/arm/mach-tegra/platsmp.c +2 -34
index 1c0fd92..bf5433a 100644
@@ -115,42 +115,10 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
  */
 void __init smp_init_cpus(void)
 {
-	unsigned int i, ncores = scu_get_core_count(scu_base);
-
-	for (i = 0; i < ncores; i++)
-		cpu_set(i, cpu_possible_map);
+	scu_init_cpus(scu_base);
 }
 
 void __init smp_prepare_cpus(unsigned int max_cpus)
 {
-	unsigned int ncores = scu_get_core_count(scu_base);
-	unsigned int cpu = smp_processor_id();
-	int i;
-
-	smp_store_cpu_info(cpu);
-
-	/*
-	 * are we trying to boot more cores than exist?
-	 */
-	if (max_cpus > ncores)
-		max_cpus = ncores;
-
-	/*
-	 * Initialise the present map, which describes the set of CPUs
-	 * actually populated at the present time.
-	 */
-	for (i = 0; i < max_cpus; i++)
-		set_cpu_present(i, true);
-
-	/*
-	 * Initialise the SCU if there are more than one CPU and let
-	 * them know where to start. Note that, on modern versions of
-	 * MILO, the "poke" doesn't actually do anything until each
-	 * individual core is sent a soft interrupt to get it out of
-	 * WFI
-	 */
-	if (max_cpus > 1) {
-		percpu_timer_setup();
-		scu_enable(scu_base);
-	}
+	scu_prepare_cpus(scu_base, max_cpus);
 }
Signature · 1 line
1.7.0.5
#24 lore raw

PATCH v4 8/8 ARM: OMAP2: Switch to generic SCU routines

In reply to Anton Vorontsov

This shrinks platform-specific code a little bit.

---
 arch/arm/mach-omap2/omap-smp.c |   64 ++--------------------------------------
 1 files changed, 3 insertions(+), 61 deletions(-)
arch/arm/mach-omap2/omap-smp.c +3 -61
index 56a8bce..52379c7 100644
@@ -29,16 +29,6 @@
 /* SCU base address */
 static void __iomem *scu_base;
 
-/*
- * Use SCU config register to count number of cores
- */
-static inline unsigned int get_core_count(void)
-{
-	if (scu_base)
-		return scu_get_core_count(scu_base);
-	return 1;
-}
-
 static DEFINE_SPINLOCK(boot_lock);
 
 void __cpuinit platform_secondary_init(unsigned int cpu)
@@ -112,65 +102,17 @@ static void __init wakeup_secondary(void)
  */
 void __init smp_init_cpus(void)
 {
-	unsigned int i, ncores;
-
 	/* Never released */
 	scu_base = ioremap(OMAP44XX_SCU_BASE, SZ_256);
 	BUG_ON(!scu_base);
 
-	ncores = get_core_count();
-
-	for (i = 0; i < ncores; i++)
-		set_cpu_possible(i, true);
+	scu_init_cpus(scu_base);
 }
 
 void __init smp_prepare_cpus(unsigned int max_cpus)
 {
-	unsigned int ncores = get_core_count();
-	unsigned int cpu = smp_processor_id();
-	int i;
-
-	/* sanity check */
-	if (ncores == 0) {
-		printk(KERN_ERR
-		       "OMAP4: strange core count of 0? Default to 1\n");
-		ncores = 1;
-	}
-
-	if (ncores > NR_CPUS) {
-		printk(KERN_WARNING
-		       "OMAP4: no. of cores (%d) greater than configured "
-		       "maximum of %d - clipping\n",
-		       ncores, NR_CPUS);
-		ncores = NR_CPUS;
-	}
-	smp_store_cpu_info(cpu);
-
-	/*
-	 * are we trying to boot more cores than exist?
-	 */
-	if (max_cpus > ncores)
-		max_cpus = ncores;
+	scu_prepare_cpus(scu_base, max_cpus);
 
-	/*
-	 * Initialise the present map, which describes the set of CPUs
-	 * actually populated at the present time.
-	 */
-	for (i = 0; i < max_cpus; i++)
-		set_cpu_present(i, true);
-
-	if (max_cpus > 1) {
-		/*
-		 * Enable the local timer or broadcast device for the
-		 * boot CPU, but only if we have more than one CPU.
-		 */
-		percpu_timer_setup();
-
-		/*
-		 * Initialise the SCU and wake up the secondary core using
-		 * wakeup_secondary().
-		 */
-		scu_enable(scu_base);
+	if (max_cpus > 1)
 		wakeup_secondary();
-	}
 }
Signature · 1 line
1.7.0.5