[PATCH v2 0/8] Introduce logical CPU mapping

STALE5497d

Revision v2 of 3 in this series.

12 messages, 2 authors, 2011-08-19 · open the first message on its own page

[PATCH v2 0/8] Introduce logical CPU mapping

From: Will Deacon <hidden>
Date: 2011-08-15 17:30:44

Hello,

This is version 2 of the RFC originally posted here:

http://lists.infradead.org/pipermail/linux-arm-kernel/2011-August/060594.html

Changes since v1 include:

  * Fixed the GIC code to compile when !CONFIG_SMP
  * Based on -rc2
  * Added acks / tested-bys from various platform maintainers (thanks!)

Any feedback on the approach taken and comments from the shmobile folks
would be much appreciated.

Thanks,

Will


Will Deacon (8):
  ARM: cpuid: add support for reading MPIDR
  ARM: smp: populate logical CPU mapping during boot
  ARM: gic: convert logical CPU numbers into physical numbers
  ARM: exynos4: convert logical CPU numbers to physical numbers
  ARM: msm: convert logical CPU numbers to physical numbers
  ARM: shmobile: convert logical CPU numbers to physical numbers
  ARM: ux500: convert logical CPU numbers to physical numbers
  ARM: versatile: convert logical CPU numbers to physical numbers

 arch/arm/common/gic.c               |   17 ++++++++++++++---
 arch/arm/include/asm/cputype.h      |    6 ++++++
 arch/arm/include/asm/smp.h          |    6 ++++++
 arch/arm/kernel/smp.c               |   15 +++++++++++++++
 arch/arm/mach-exynos4/hotplug.c     |    2 +-
 arch/arm/mach-exynos4/platsmp.c     |    2 +-
 arch/arm/mach-msm/hotplug.c         |    2 +-
 arch/arm/mach-msm/platsmp.c         |    2 +-
 arch/arm/mach-realview/hotplug.c    |    2 +-
 arch/arm/mach-shmobile/smp-sh73a0.c |    6 +++++-
 arch/arm/mach-ux500/hotplug.c       |    2 +-
 arch/arm/mach-ux500/platsmp.c       |    2 +-
 arch/arm/mach-vexpress/hotplug.c    |    2 +-
 arch/arm/plat-versatile/platsmp.c   |    2 +-
 14 files changed, 55 insertions(+), 13 deletions(-)

[PATCH v2 1/8] ARM: cpuid: add support for reading MPIDR

From: Will Deacon <hidden>
Date: 2011-08-15 17:30:45

The MPIDR register forms part of the CPUID interface and allows software
to determine the physical ID of the CPU on which it is currently
executing.

This patch adds support for reading the MPIDR to cputype.h

Signed-off-by: Will Deacon <redacted>
---
 arch/arm/include/asm/cputype.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/arch/arm/include/asm/cputype.h b/arch/arm/include/asm/cputype.h
index cd4458f..cb47d28 100644
--- a/arch/arm/include/asm/cputype.h
+++ b/arch/arm/include/asm/cputype.h
@@ -8,6 +8,7 @@
 #define CPUID_CACHETYPE	1
 #define CPUID_TCM	2
 #define CPUID_TLBTYPE	3
+#define CPUID_MPIDR	5
 
 #define CPUID_EXT_PFR0	"c1, 0"
 #define CPUID_EXT_PFR1	"c1, 1"
@@ -70,6 +71,11 @@ static inline unsigned int __attribute_const__ read_cpuid_tcmstatus(void)
 	return read_cpuid(CPUID_TCM);
 }
 
+static inline unsigned int __attribute_const__ read_cpuid_mpidr(void)
+{
+	return read_cpuid(CPUID_MPIDR);
+}
+
 /*
  * Intel's XScale3 core supports some v6 features (supersections, L2)
  * but advertises itself as v5 as it does not support the v6 ISA.  For
-- 
1.7.0.4

[PATCH v2 2/8] ARM: smp: populate logical CPU mapping during boot

From: Will Deacon <hidden>
Date: 2011-08-15 17:30:46

To allow booting Linux on a CPU with physical ID != 0, we need to
provide a mapping from the logical CPU number to the physical CPU
number.

This patch adds such a mapping and populates it during boot.

Signed-off-by: Will Deacon <redacted>
---
 arch/arm/include/asm/smp.h |    6 ++++++
 arch/arm/kernel/smp.c      |   15 +++++++++++++++
 2 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
index e42d96a..674ebcd 100644
--- a/arch/arm/include/asm/smp.h
+++ b/arch/arm/include/asm/smp.h
@@ -66,6 +66,12 @@ extern void platform_secondary_init(unsigned int cpu);
 extern void platform_smp_prepare_cpus(unsigned int);
 
 /*
+ * Logical CPU mapping.
+ */
+extern int __cpu_logical_map[NR_CPUS];
+#define cpu_logical_map(cpu)	__cpu_logical_map[cpu]
+
+/*
  * Initial data for bringing up a secondary CPU.
  */
 struct secondary_data {
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index d88ff02..0016665 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -39,6 +39,7 @@
 #include <asm/tlbflush.h>
 #include <asm/ptrace.h>
 #include <asm/localtimer.h>
+#include <asm/smp_plat.h>
 
 /*
  * as from 2.5, kernels no longer have an init_tasks structure
@@ -259,6 +260,20 @@ void __ref cpu_die(void)
 }
 #endif /* CONFIG_HOTPLUG_CPU */
 
+int __cpu_logical_map[NR_CPUS];
+
+void __init smp_setup_processor_id(void)
+{
+	int i;
+	u32 cpu = is_smp() ? read_cpuid_mpidr() & 0xff : 0;
+
+	cpu_logical_map(0) = cpu;
+	for (i = 1; i < NR_CPUS; ++i)
+		cpu_logical_map(i) = i == cpu ? 0 : i;
+
+	printk(KERN_INFO "Booting Linux on physical CPU %d\n", cpu);
+}
+
 /*
  * Called by both boot and secondaries to move global data into
  * per-processor storage.
-- 
1.7.0.4

[PATCH v2 3/8] ARM: gic: convert logical CPU numbers into physical numbers

From: Will Deacon <hidden>
Date: 2011-08-15 17:30:47

The GIC driver must convert logical CPU numbers passed in from Linux
into physical CPU numbers that are understood by the hardware.

This patch uses the new cpu_logical_map macro for performing the
conversion inside the GIC driver.

Signed-off-by: Will Deacon <redacted>
---
 arch/arm/common/gic.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c
index 3227ca9..666b278 100644
--- a/arch/arm/common/gic.c
+++ b/arch/arm/common/gic.c
@@ -180,7 +180,7 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val,
 		return -EINVAL;
 
 	mask = 0xff << shift;
-	bit = 1 << (cpu + shift);
+	bit = 1 << (cpu_logical_map(cpu) + shift);
 
 	spin_lock(&irq_controller_lock);
 	val = readl_relaxed(reg) & ~mask;
@@ -259,9 +259,15 @@ static void __init gic_dist_init(struct gic_chip_data *gic,
 	unsigned int irq_start)
 {
 	unsigned int gic_irqs, irq_limit, i;
+	u32 cpumask;
 	void __iomem *base = gic->dist_base;
-	u32 cpumask = 1 << smp_processor_id();
+	u32 cpu = 0;
 
+#ifdef CONFIG_SMP
+	cpu = cpu_logical_map(smp_processor_id());
+#endif
+
+	cpumask = 1 << cpu;
 	cpumask |= cpumask << 8;
 	cpumask |= cpumask << 16;
 
@@ -382,7 +388,12 @@ void __cpuinit gic_enable_ppi(unsigned int irq)
 #ifdef CONFIG_SMP
 void gic_raise_softirq(const struct cpumask *mask, unsigned int irq)
 {
-	unsigned long map = *cpus_addr(*mask);
+	int cpu;
+	unsigned long map = 0;
+
+	/* Convert our logical CPU mask into a physical one. */
+	for_each_cpu(cpu, mask)
+		map |= 1 << cpu_logical_map(cpu);
 
 	/*
 	 * Ensure that stores to Normal memory are visible to the
-- 
1.7.0.4

[PATCH v2 4/8] ARM: exynos4: convert logical CPU numbers to physical numbers

From: Will Deacon <hidden>
Date: 2011-08-15 17:30:48

This patch uses the new cpu_logical_map() macro for converting logical
CPU numbers into physical numbers when dealing with the pen_release
variable in the SMP boot and CPU hotplug paths.

Cc: Kukjin Kim <redacted>
Tested-and-acked-by: Kyungmin Park [off-list ref]
Signed-off-by: Will Deacon <redacted>
---
 arch/arm/mach-exynos4/hotplug.c |    2 +-
 arch/arm/mach-exynos4/platsmp.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-exynos4/hotplug.c b/arch/arm/mach-exynos4/hotplug.c
index 7490789..da70e7e 100644
--- a/arch/arm/mach-exynos4/hotplug.c
+++ b/arch/arm/mach-exynos4/hotplug.c
@@ -75,7 +75,7 @@ static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
 		    :
 		    : "memory", "cc");
 
-		if (pen_release == cpu) {
+		if (pen_release == cpu_logical_map(cpu)) {
 			/*
 			 * OK, proper wakeup, we're done
 			 */
diff --git a/arch/arm/mach-exynos4/platsmp.c b/arch/arm/mach-exynos4/platsmp.c
index 7c2282c..0733814 100644
--- a/arch/arm/mach-exynos4/platsmp.c
+++ b/arch/arm/mach-exynos4/platsmp.c
@@ -126,7 +126,7 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
 	 * Note that "pen_release" is the hardware CPU ID, whereas
 	 * "cpu" is Linux's internal ID.
 	 */
-	write_pen_release(cpu);
+	write_pen_release(cpu_logical_map(cpu));
 
 	if (!(__raw_readl(S5P_ARM_CORE1_STATUS) & S5P_CORE_LOCAL_PWR_EN)) {
 		__raw_writel(S5P_CORE_LOCAL_PWR_EN,
-- 
1.7.0.4

[PATCH v2 5/8] ARM: msm: convert logical CPU numbers to physical numbers

From: Will Deacon <hidden>
Date: 2011-08-15 17:30:49

This patch uses the new cpu_logical_map() macro for converting logical
CPU numbers into physical numbers when dealing with the pen_release
variable in the SMP boot and CPU hotplug paths.

Tested-and-acked-by: David Brown [off-list ref]
Signed-off-by: Will Deacon <redacted>
---
 arch/arm/mach-msm/hotplug.c |    2 +-
 arch/arm/mach-msm/platsmp.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-msm/hotplug.c b/arch/arm/mach-msm/hotplug.c
index 5a31f70..41c252d 100644
--- a/arch/arm/mach-msm/hotplug.c
+++ b/arch/arm/mach-msm/hotplug.c
@@ -37,7 +37,7 @@ static inline void platform_do_lowpower(unsigned int cpu)
 		    :
 		    : "memory", "cc");
 
-		if (pen_release == cpu) {
+		if (pen_release == cpu_logical_map(cpu)) {
 			/*
 			 * OK, proper wakeup, we're done
 			 */
diff --git a/arch/arm/mach-msm/platsmp.c b/arch/arm/mach-msm/platsmp.c
index 1a1af9e..e3375ee 100644
--- a/arch/arm/mach-msm/platsmp.c
+++ b/arch/arm/mach-msm/platsmp.c
@@ -117,7 +117,7 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
 	 * Note that "pen_release" is the hardware CPU ID, whereas
 	 * "cpu" is Linux's internal ID.
 	 */
-	pen_release = cpu;
+	pen_release = cpu_logical_map(cpu);
 	__cpuc_flush_dcache_area((void *)&pen_release, sizeof(pen_release));
 	outer_clean_range(__pa(&pen_release), __pa(&pen_release + 1));
 
-- 
1.7.0.4

[PATCH v2 6/8] ARM: shmobile: convert logical CPU numbers to physical numbers

From: Will Deacon <hidden>
Date: 2011-08-15 17:30:50

This patch uses the new cpu_logical_map() macro for converting logical
CPU numbers into physical numbers when dealing with the SCU in the SMP
boot path for sh73a0.

Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Paul Mundt <redacted>
Signed-off-by: Will Deacon <redacted>
---
 arch/arm/mach-shmobile/smp-sh73a0.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/arch/arm/mach-shmobile/smp-sh73a0.c b/arch/arm/mach-shmobile/smp-sh73a0.c
index 3ffdbc9..be1ade7 100644
--- a/arch/arm/mach-shmobile/smp-sh73a0.c
+++ b/arch/arm/mach-shmobile/smp-sh73a0.c
@@ -74,6 +74,8 @@ void __cpuinit sh73a0_secondary_init(unsigned int cpu)
 
 int __cpuinit sh73a0_boot_secondary(unsigned int cpu)
 {
+	cpu = cpu_logical_map(cpu);
+
 	/* enable cache coherency */
 	modify_scu_cpu_psr(0, 3 << (cpu * 8));
 
@@ -87,6 +89,8 @@ int __cpuinit sh73a0_boot_secondary(unsigned int cpu)
 
 void __init sh73a0_smp_prepare_cpus(void)
 {
+	int cpu = cpu_logical_map(0);
+
 	scu_enable(scu_base_addr());
 
 	/* Map the reset vector (in headsmp.S) */
@@ -94,5 +98,5 @@ void __init sh73a0_smp_prepare_cpus(void)
 	__raw_writel(__pa(shmobile_secondary_vector), __io(SBAR));
 
 	/* enable cache coherency on CPU0 */
-	modify_scu_cpu_psr(0, 3 << (0 * 8));
+	modify_scu_cpu_psr(0, 3 << (cpu * 8));
 }
-- 
1.7.0.4

[PATCH v2 7/8] ARM: ux500: convert logical CPU numbers to physical numbers

From: Will Deacon <hidden>
Date: 2011-08-15 17:30:51

This patch uses the new cpu_logical_map() macro for converting logical
CPU numbers into physical numbers when dealing with the pen_release
variable in the SMP boot and CPU hotplug paths.

Acked-by: Linus Walleij <redacted>
Signed-off-by: Will Deacon <redacted>
---
 arch/arm/mach-ux500/hotplug.c |    2 +-
 arch/arm/mach-ux500/platsmp.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-ux500/hotplug.c b/arch/arm/mach-ux500/hotplug.c
index dd8037e..572015e 100644
--- a/arch/arm/mach-ux500/hotplug.c
+++ b/arch/arm/mach-ux500/hotplug.c
@@ -24,7 +24,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 (pen_release == cpu_logical_map(cpu)) {
 			/*
 			 * OK, proper wakeup, we're done
 			 */
diff --git a/arch/arm/mach-ux500/platsmp.c b/arch/arm/mach-ux500/platsmp.c
index a33df5f..27e5281 100644
--- a/arch/arm/mach-ux500/platsmp.c
+++ b/arch/arm/mach-ux500/platsmp.c
@@ -96,7 +96,7 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
 	 * the holding pen - release it, then wait for it to flag
 	 * that it has been released by resetting pen_release.
 	 */
-	write_pen_release(cpu);
+	write_pen_release(cpu_logical_map(cpu));
 
 	gic_raise_softirq(cpumask_of(cpu), 1);
 
-- 
1.7.0.4

[PATCH v2 8/8] ARM: versatile: convert logical CPU numbers to physical numbers

From: Will Deacon <hidden>
Date: 2011-08-15 17:30:52

This patch uses the new cpu_logical_map() macro for converting logical
CPU numbers into physical numbers when dealing with the pen_release
variable in the SMP boot and CPU hotplug paths.

Signed-off-by: Will Deacon <redacted>
---
 arch/arm/mach-realview/hotplug.c  |    2 +-
 arch/arm/mach-vexpress/hotplug.c  |    2 +-
 arch/arm/plat-versatile/platsmp.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-realview/hotplug.c b/arch/arm/mach-realview/hotplug.c
index a87523d..ac1aed2 100644
--- a/arch/arm/mach-realview/hotplug.c
+++ b/arch/arm/mach-realview/hotplug.c
@@ -69,7 +69,7 @@ static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
 		    :
 		    : "memory", "cc");
 
-		if (pen_release == cpu) {
+		if (pen_release == cpu_logical_map(cpu)) {
 			/*
 			 * OK, proper wakeup, we're done
 			 */
diff --git a/arch/arm/mach-vexpress/hotplug.c b/arch/arm/mach-vexpress/hotplug.c
index ea4cbfb..2866ed8 100644
--- a/arch/arm/mach-vexpress/hotplug.c
+++ b/arch/arm/mach-vexpress/hotplug.c
@@ -70,7 +70,7 @@ static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
 		    :
 		    : "memory", "cc");
 
-		if (pen_release == cpu) {
+		if (pen_release == cpu_logical_map(cpu)) {
 			/*
 			 * OK, proper wakeup, we're done
 			 */
diff --git a/arch/arm/plat-versatile/platsmp.c b/arch/arm/plat-versatile/platsmp.c
index 51ecfea..92f18d3 100644
--- a/arch/arm/plat-versatile/platsmp.c
+++ b/arch/arm/plat-versatile/platsmp.c
@@ -77,7 +77,7 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
 	 * since we haven't sent them a soft interrupt, they shouldn't
 	 * be there.
 	 */
-	write_pen_release(cpu);
+	write_pen_release(cpu_logical_map(cpu));
 
 	/*
 	 * Send the secondary CPU a soft interrupt, thereby causing
-- 
1.7.0.4

[PATCH v2 1/8] ARM: cpuid: add support for reading MPIDR

From: vincent.guittot@linaro.org (Vincent Guittot)
Date: 2011-08-16 09:06:01

Hi Will,

The read_cpuid_mpidr function has been added in a previous patch :

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

It's now in Russell's patch system: ref 7011/1

Vincent

On 15 August 2011 19:30, Will Deacon [off-list ref] wrote:
quoted hunk
The MPIDR register forms part of the CPUID interface and allows software
to determine the physical ID of the CPU on which it is currently
executing.

This patch adds support for reading the MPIDR to cputype.h

Signed-off-by: Will Deacon <redacted>
---
?arch/arm/include/asm/cputype.h | ? ?6 ++++++
?1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/arch/arm/include/asm/cputype.h b/arch/arm/include/asm/cputype.h
index cd4458f..cb47d28 100644
--- a/arch/arm/include/asm/cputype.h
+++ b/arch/arm/include/asm/cputype.h
@@ -8,6 +8,7 @@
?#define CPUID_CACHETYPE ? ? ? ?1
?#define CPUID_TCM ? ? ?2
?#define CPUID_TLBTYPE ?3
+#define CPUID_MPIDR ? ?5

?#define CPUID_EXT_PFR0 "c1, 0"
?#define CPUID_EXT_PFR1 "c1, 1"
@@ -70,6 +71,11 @@ static inline unsigned int __attribute_const__ read_cpuid_tcmstatus(void)
? ? ? ?return read_cpuid(CPUID_TCM);
?}

+static inline unsigned int __attribute_const__ read_cpuid_mpidr(void)
+{
+ ? ? ? return read_cpuid(CPUID_MPIDR);
+}
+
?/*
?* Intel's XScale3 core supports some v6 features (supersections, L2)
?* but advertises itself as v5 as it does not support the v6 ISA. ?For
--
1.7.0.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

[PATCH v2 1/8] ARM: cpuid: add support for reading MPIDR

From: Will Deacon <hidden>
Date: 2011-08-16 09:12:25

On Tue, Aug 16, 2011 at 10:06:01AM +0100, Vincent Guittot wrote:
Hi Will,
Hi Vincent,
The read_cpuid_mpidr function has been added in a previous patch :

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

It's now in Russell's patch system: ref 7011/1
Brill, saves me a job!

Thanks,

Will

[PATCH v2 6/8] ARM: shmobile: convert logical CPU numbers to physical numbers

From: Will Deacon <hidden>
Date: 2011-08-19 12:52:24

Magnus, Paul,

On Mon, Aug 15, 2011 at 06:30:50PM +0100, Will Deacon wrote:
This patch uses the new cpu_logical_map() macro for converting logical
CPU numbers into physical numbers when dealing with the SCU in the SMP
boot path for sh73a0.

Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: Paul Mundt <redacted>
Signed-off-by: Will Deacon <redacted>
---
 arch/arm/mach-shmobile/smp-sh73a0.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
Any feedback on this? My change to modify_scu_cpu_psr is based largely on
pattern matching, so please shout if it's wrong.

Will

quoted hunk
diff --git a/arch/arm/mach-shmobile/smp-sh73a0.c b/arch/arm/mach-shmobile/smp-sh73a0.c
index 3ffdbc9..be1ade7 100644
--- a/arch/arm/mach-shmobile/smp-sh73a0.c
+++ b/arch/arm/mach-shmobile/smp-sh73a0.c
@@ -74,6 +74,8 @@ void __cpuinit sh73a0_secondary_init(unsigned int cpu)
 
 int __cpuinit sh73a0_boot_secondary(unsigned int cpu)
 {
+	cpu = cpu_logical_map(cpu);
+
 	/* enable cache coherency */
 	modify_scu_cpu_psr(0, 3 << (cpu * 8));
 
@@ -87,6 +89,8 @@ int __cpuinit sh73a0_boot_secondary(unsigned int cpu)
 
 void __init sh73a0_smp_prepare_cpus(void)
 {
+	int cpu = cpu_logical_map(0);
+
 	scu_enable(scu_base_addr());
 
 	/* Map the reset vector (in headsmp.S) */
@@ -94,5 +98,5 @@ void __init sh73a0_smp_prepare_cpus(void)
 	__raw_writel(__pa(shmobile_secondary_vector), __io(SBAR));
 
 	/* enable cache coherency on CPU0 */
-	modify_scu_cpu_psr(0, 3 << (0 * 8));
+	modify_scu_cpu_psr(0, 3 << (cpu * 8));
 }
-- 
1.7.0.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help