All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/22] More SMP cleanup
@ 2010-12-03 20:07 Russell King - ARM Linux
  2010-12-03 20:19 ` [PATCH 01/22] ARM: remove obsolete smp_cross_call_done() Russell King - ARM Linux
                   ` (23 more replies)
  0 siblings, 24 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:07 UTC (permalink / raw)
  To: linux-arm-kernel

This patch series incorporates patches from the previously posted
"Clean up SMP IPI support" series of 9 patches.  Patch 5, and
11 onwards are new.

This aims to reduce the amount of code in platform specific files
to the barest minimum, while maintaining the flexibility of the
API to allow platforms to decide which CPU numbers are populated.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 01/22] ARM: remove obsolete smp_cross_call_done()
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
@ 2010-12-03 20:19 ` Russell King - ARM Linux
  2010-12-03 20:19 ` [PATCH 02/22] ARM: SMP: pass an ipi number to smp_cross_call() Russell King - ARM Linux
                   ` (22 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:19 UTC (permalink / raw)
  To: linux-arm-kernel

smp_cross_call_done() was removed long ago (see 78d236c - remove useless
smp_cross_call_done()).  Remove those which have been subsequently
merged.

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/mach-tegra/include/mach/smp.h |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-tegra/include/mach/smp.h b/arch/arm/mach-tegra/include/mach/smp.h
index e4a34a3..d3cd265 100644
--- a/arch/arm/mach-tegra/include/mach/smp.h
+++ b/arch/arm/mach-tegra/include/mach/smp.h
@@ -12,11 +12,4 @@ static inline void smp_cross_call(const struct cpumask *mask)
 	gic_raise_softirq(mask, 1);
 }
 
-/*
- * Do nothing on MPcore.
- */
-static inline void smp_cross_call_done(cpumask_t callmap)
-{
-}
-
 #endif
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 02/22] ARM: SMP: pass an ipi number to smp_cross_call()
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
  2010-12-03 20:19 ` [PATCH 01/22] ARM: remove obsolete smp_cross_call_done() Russell King - ARM Linux
@ 2010-12-03 20:19 ` Russell King - ARM Linux
  2010-12-03 20:19 ` [PATCH 03/22] ARM: SMP: avoid using bitmasks and locks for IPIs, use hardware instead Russell King - ARM Linux
                   ` (21 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:19 UTC (permalink / raw)
  To: linux-arm-kernel

This allows us to use smp_cross_call() to trigger a number of different
software generated interrupts, rather than combining them all on one
SGI.  Recover the SGI number via do_IPI.

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/include/asm/smp.h                |    4 ++--
 arch/arm/kernel/entry-armv.S              |    2 +-
 arch/arm/kernel/smp.c                     |   10 ++--------
 arch/arm/mach-msm/include/mach/smp.h      |    4 ++--
 arch/arm/mach-omap2/omap-smp.c            |    2 +-
 arch/arm/mach-realview/include/mach/smp.h |    4 ++--
 arch/arm/mach-realview/platsmp.c          |    2 +-
 arch/arm/mach-s5pv310/include/mach/smp.h  |    4 ++--
 arch/arm/mach-s5pv310/platsmp.c           |    2 +-
 arch/arm/mach-tegra/include/mach/smp.h    |    4 ++--
 arch/arm/mach-ux500/include/mach/smp.h    |    4 ++--
 arch/arm/mach-ux500/platsmp.c             |    2 +-
 arch/arm/mach-vexpress/include/mach/smp.h |    4 ++--
 arch/arm/mach-vexpress/platsmp.c          |    2 +-
 arch/arm/plat-omap/include/plat/smp.h     |    4 ++--
 15 files changed, 24 insertions(+), 30 deletions(-)

diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
index 3d05190..da7e7ca 100644
--- a/arch/arm/include/asm/smp.h
+++ b/arch/arm/include/asm/smp.h
@@ -38,7 +38,7 @@ extern void show_ipi_list(struct seq_file *p);
 /*
  * Called from assembly code, this handles an IPI.
  */
-asmlinkage void do_IPI(struct pt_regs *regs);
+asmlinkage void do_IPI(int ipinr, struct pt_regs *regs);
 
 /*
  * Setup the set of possible CPUs (via set_cpu_possible)
@@ -53,7 +53,7 @@ extern void smp_store_cpu_info(unsigned int cpuid);
 /*
  * Raise an IPI cross call on CPUs in callmap.
  */
-extern void smp_cross_call(const struct cpumask *mask);
+extern void smp_cross_call(const struct cpumask *mask, int ipi);
 
 /*
  * Boot a secondary CPU, and assign it the specified idle task.
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index c09e357..955cf5f 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -48,7 +48,7 @@
 	 */
 	ALT_SMP(test_for_ipi r0, r6, r5, lr)
 	ALT_UP_B(9997f)
-	movne	r0, sp
+	movne	r1, sp
 	adrne	lr, BSYM(1b)
 	bne	do_IPI
 
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 8c19595..7a236db 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -404,7 +404,7 @@ static void send_ipi_message(const struct cpumask *mask, enum ipi_msg_type msg)
 	/*
 	 * Call the platform specific cross-CPU call function.
 	 */
-	smp_cross_call(mask);
+	smp_cross_call(mask, 1);
 
 	local_irq_restore(flags);
 }
@@ -537,14 +537,8 @@ static void ipi_cpu_stop(unsigned int cpu)
 
 /*
  * Main handler for inter-processor interrupts
- *
- * For ARM, the ipimask now only identifies a single
- * category of IPI (Bit 1 IPIs have been replaced by a
- * different mechanism):
- *
- *  Bit 0 - Inter-processor function call
  */
-asmlinkage void __exception do_IPI(struct pt_regs *regs)
+asmlinkage void __exception do_IPI(int ipinr, struct pt_regs *regs)
 {
 	unsigned int cpu = smp_processor_id();
 	struct ipi_data *ipi = &per_cpu(ipi_data, cpu);
diff --git a/arch/arm/mach-msm/include/mach/smp.h b/arch/arm/mach-msm/include/mach/smp.h
index 3ff7bf5..a95f7b9 100644
--- a/arch/arm/mach-msm/include/mach/smp.h
+++ b/arch/arm/mach-msm/include/mach/smp.h
@@ -31,9 +31,9 @@
 
 #include <asm/hardware/gic.h>
 
-static inline void smp_cross_call(const struct cpumask *mask)
+static inline void smp_cross_call(const struct cpumask *mask, int ipi)
 {
-	gic_raise_softirq(mask, 1);
+	gic_raise_softirq(mask, ipi);
 }
 
 #endif
diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
index 9e9f70e..56a8bce 100644
--- a/arch/arm/mach-omap2/omap-smp.c
+++ b/arch/arm/mach-omap2/omap-smp.c
@@ -76,7 +76,7 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
 	omap_modify_auxcoreboot0(0x200, 0xfffffdff);
 	flush_cache_all();
 	smp_wmb();
-	smp_cross_call(cpumask_of(cpu));
+	smp_cross_call(cpumask_of(cpu), 1);
 
 	/*
 	 * Now the secondary core is starting up let it run its
diff --git a/arch/arm/mach-realview/include/mach/smp.h b/arch/arm/mach-realview/include/mach/smp.h
index d3cd265..d1aa704 100644
--- a/arch/arm/mach-realview/include/mach/smp.h
+++ b/arch/arm/mach-realview/include/mach/smp.h
@@ -7,9 +7,9 @@
 /*
  * We use IRQ1 as the IPI
  */
-static inline void smp_cross_call(const struct cpumask *mask)
+static inline void smp_cross_call(const struct cpumask *mask, int ipi)
 {
-	gic_raise_softirq(mask, 1);
+	gic_raise_softirq(mask, ipi);
 }
 
 #endif
diff --git a/arch/arm/mach-realview/platsmp.c b/arch/arm/mach-realview/platsmp.c
index 0092658..af3d909 100644
--- a/arch/arm/mach-realview/platsmp.c
+++ b/arch/arm/mach-realview/platsmp.c
@@ -116,7 +116,7 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
 	 * Use smp_cross_call() for this, since there's little
 	 * point duplicating the code here
 	 */
-	smp_cross_call(cpumask_of(cpu));
+	smp_cross_call(cpumask_of(cpu), 1);
 
 	timeout = jiffies + (1 * HZ);
 	while (time_before(jiffies, timeout)) {
diff --git a/arch/arm/mach-s5pv310/include/mach/smp.h b/arch/arm/mach-s5pv310/include/mach/smp.h
index b7ec252..2897747 100644
--- a/arch/arm/mach-s5pv310/include/mach/smp.h
+++ b/arch/arm/mach-s5pv310/include/mach/smp.h
@@ -14,9 +14,9 @@ extern void __iomem *gic_cpu_base_addr;
 /*
  * We use IRQ1 as the IPI
  */
-static inline void smp_cross_call(const struct cpumask *mask)
+static inline void smp_cross_call(const struct cpumask *mask, int ipi)
 {
-	gic_raise_softirq(mask, 1);
+	gic_raise_softirq(mask, ipi);
 }
 
 #endif
diff --git a/arch/arm/mach-s5pv310/platsmp.c b/arch/arm/mach-s5pv310/platsmp.c
index d357c19..d474426 100644
--- a/arch/arm/mach-s5pv310/platsmp.c
+++ b/arch/arm/mach-s5pv310/platsmp.c
@@ -97,7 +97,7 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
 	 * the boot monitor to read the system wide flags register,
 	 * and branch to the address found there.
 	 */
-	smp_cross_call(cpumask_of(cpu));
+	smp_cross_call(cpumask_of(cpu), 1);
 
 	timeout = jiffies + (1 * HZ);
 	while (time_before(jiffies, timeout)) {
diff --git a/arch/arm/mach-tegra/include/mach/smp.h b/arch/arm/mach-tegra/include/mach/smp.h
index d3cd265..d1aa704 100644
--- a/arch/arm/mach-tegra/include/mach/smp.h
+++ b/arch/arm/mach-tegra/include/mach/smp.h
@@ -7,9 +7,9 @@
 /*
  * We use IRQ1 as the IPI
  */
-static inline void smp_cross_call(const struct cpumask *mask)
+static inline void smp_cross_call(const struct cpumask *mask, int ipi)
 {
-	gic_raise_softirq(mask, 1);
+	gic_raise_softirq(mask, ipi);
 }
 
 #endif
diff --git a/arch/arm/mach-ux500/include/mach/smp.h b/arch/arm/mach-ux500/include/mach/smp.h
index 197e841..bd57c50 100644
--- a/arch/arm/mach-ux500/include/mach/smp.h
+++ b/arch/arm/mach-ux500/include/mach/smp.h
@@ -18,8 +18,8 @@ extern void u8500_secondary_startup(void);
 /*
  * We use IRQ1 as the IPI
  */
-static inline void smp_cross_call(const struct cpumask *mask)
+static inline void smp_cross_call(const struct cpumask *mask, int ipi)
 {
-	gic_raise_softirq(mask, 1);
+	gic_raise_softirq(mask, ipi);
 }
 #endif
diff --git a/arch/arm/mach-ux500/platsmp.c b/arch/arm/mach-ux500/platsmp.c
index 9e4c678..b8987bd 100644
--- a/arch/arm/mach-ux500/platsmp.c
+++ b/arch/arm/mach-ux500/platsmp.c
@@ -78,7 +78,7 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
 	__cpuc_flush_dcache_area((void *)&pen_release, sizeof(pen_release));
 	outer_clean_range(__pa(&pen_release), __pa(&pen_release) + 1);
 
-	smp_cross_call(cpumask_of(cpu));
+	smp_cross_call(cpumask_of(cpu), 1);
 
 	timeout = jiffies + (1 * HZ);
 	while (time_before(jiffies, timeout)) {
diff --git a/arch/arm/mach-vexpress/include/mach/smp.h b/arch/arm/mach-vexpress/include/mach/smp.h
index 5a6da4f..721be0f 100644
--- a/arch/arm/mach-vexpress/include/mach/smp.h
+++ b/arch/arm/mach-vexpress/include/mach/smp.h
@@ -7,8 +7,8 @@
 /*
  * We use IRQ1 as the IPI
  */
-static inline void smp_cross_call(const struct cpumask *mask)
+static inline void smp_cross_call(const struct cpumask *mask, int ipi)
 {
-	gic_raise_softirq(mask, 1);
+	gic_raise_softirq(mask, ipi);
 }
 #endif
diff --git a/arch/arm/mach-vexpress/platsmp.c b/arch/arm/mach-vexpress/platsmp.c
index 6709706..276f916 100644
--- a/arch/arm/mach-vexpress/platsmp.c
+++ b/arch/arm/mach-vexpress/platsmp.c
@@ -92,7 +92,7 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
 	 * the boot monitor to read the system wide flags register,
 	 * and branch to the address found there.
 	 */
-	smp_cross_call(cpumask_of(cpu));
+	smp_cross_call(cpumask_of(cpu), 1);
 
 	timeout = jiffies + (1 * HZ);
 	while (time_before(jiffies, timeout)) {
diff --git a/arch/arm/plat-omap/include/plat/smp.h b/arch/arm/plat-omap/include/plat/smp.h
index ecd6a48..e5541e5 100644
--- a/arch/arm/plat-omap/include/plat/smp.h
+++ b/arch/arm/plat-omap/include/plat/smp.h
@@ -29,9 +29,9 @@ extern u32 omap_read_auxcoreboot0(void);
 /*
  * We use Soft IRQ1 as the IPI
  */
-static inline void smp_cross_call(const struct cpumask *mask)
+static inline void smp_cross_call(const struct cpumask *mask, int ipi)
 {
-	gic_raise_softirq(mask, 1);
+	gic_raise_softirq(mask, ipi);
 }
 
 #endif
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 03/22] ARM: SMP: avoid using bitmasks and locks for IPIs, use hardware instead
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
  2010-12-03 20:19 ` [PATCH 01/22] ARM: remove obsolete smp_cross_call_done() Russell King - ARM Linux
  2010-12-03 20:19 ` [PATCH 02/22] ARM: SMP: pass an ipi number to smp_cross_call() Russell King - ARM Linux
@ 2010-12-03 20:19 ` Russell King - ARM Linux
  2010-12-03 20:20 ` [PATCH 04/22] ARM: SMP: remove IRQ-disabling for smp_cross_call() Russell King - ARM Linux
                   ` (20 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:19 UTC (permalink / raw)
  To: linux-arm-kernel

Avoid using bitmasks and locks in the percpu area for IPIs, and instead
use individual software generated interrupts to identify the reason for
the IPI.  This avoids the problems of having spinlocks in the percpu
area.

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/kernel/smp.c |   87 ++++++++++++++----------------------------------
 1 files changed, 26 insertions(+), 61 deletions(-)

diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 7a236db..78d55c6 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -48,20 +48,15 @@ struct secondary_data secondary_data;
 
 /*
  * structures for inter-processor calls
- * - A collection of single bit ipi messages.
  */
 struct ipi_data {
-	spinlock_t lock;
 	unsigned long ipi_count;
-	unsigned long bits;
 };
 
-static DEFINE_PER_CPU(struct ipi_data, ipi_data) = {
-	.lock	= SPIN_LOCK_UNLOCKED,
-};
+static DEFINE_PER_CPU(struct ipi_data, ipi_data);
 
 enum ipi_msg_type {
-	IPI_TIMER,
+	IPI_TIMER = 2,
 	IPI_RESCHEDULE,
 	IPI_CALL_FUNC,
 	IPI_CALL_FUNC_SINGLE,
@@ -389,22 +384,13 @@ void __init smp_prepare_boot_cpu(void)
 static void send_ipi_message(const struct cpumask *mask, enum ipi_msg_type msg)
 {
 	unsigned long flags;
-	unsigned int cpu;
 
 	local_irq_save(flags);
 
-	for_each_cpu(cpu, mask) {
-		struct ipi_data *ipi = &per_cpu(ipi_data, cpu);
-
-		spin_lock(&ipi->lock);
-		ipi->bits |= 1 << msg;
-		spin_unlock(&ipi->lock);
-	}
-
 	/*
 	 * Call the platform specific cross-CPU call function.
 	 */
-	smp_cross_call(mask, 1);
+	smp_cross_call(mask, msg);
 
 	local_irq_restore(flags);
 }
@@ -546,56 +532,35 @@ asmlinkage void __exception do_IPI(int ipinr, struct pt_regs *regs)
 
 	ipi->ipi_count++;
 
-	for (;;) {
-		unsigned long msgs;
-
-		spin_lock(&ipi->lock);
-		msgs = ipi->bits;
-		ipi->bits = 0;
-		spin_unlock(&ipi->lock);
-
-		if (!msgs)
-			break;
-
-		do {
-			unsigned nextmsg;
-
-			nextmsg = msgs & -msgs;
-			msgs &= ~nextmsg;
-			nextmsg = ffz(~nextmsg);
-
-			switch (nextmsg) {
-			case IPI_TIMER:
-				ipi_timer();
-				break;
+	switch (ipinr) {
+	case IPI_TIMER:
+		ipi_timer();
+		break;
 
-			case IPI_RESCHEDULE:
-				/*
-				 * nothing more to do - eveything is
-				 * done on the interrupt return path
-				 */
-				break;
+	case IPI_RESCHEDULE:
+		/*
+		 * nothing more to do - eveything is
+		 * done on the interrupt return path
+		 */
+		break;
 
-			case IPI_CALL_FUNC:
-				generic_smp_call_function_interrupt();
-				break;
+	case IPI_CALL_FUNC:
+		generic_smp_call_function_interrupt();
+		break;
 
-			case IPI_CALL_FUNC_SINGLE:
-				generic_smp_call_function_single_interrupt();
-				break;
+	case IPI_CALL_FUNC_SINGLE:
+		generic_smp_call_function_single_interrupt();
+		break;
 
-			case IPI_CPU_STOP:
-				ipi_cpu_stop(cpu);
-				break;
+	case IPI_CPU_STOP:
+		ipi_cpu_stop(cpu);
+		break;
 
-			default:
-				printk(KERN_CRIT "CPU%u: Unknown IPI message 0x%x\n",
-				       cpu, nextmsg);
-				break;
-			}
-		} while (msgs);
+	default:
+		printk(KERN_CRIT "CPU%u: Unknown IPI message 0x%x\n",
+		       cpu, ipinr);
+		break;
 	}
-
 	set_irq_regs(old_regs);
 }
 
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 04/22] ARM: SMP: remove IRQ-disabling for smp_cross_call()
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (2 preceding siblings ...)
  2010-12-03 20:19 ` [PATCH 03/22] ARM: SMP: avoid using bitmasks and locks for IPIs, use hardware instead Russell King - ARM Linux
@ 2010-12-03 20:20 ` Russell King - ARM Linux
  2010-12-03 20:20 ` [PATCH 05/22] ARM: include local timer irq stats only when local timers configured Russell King - ARM Linux
                   ` (19 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:20 UTC (permalink / raw)
  To: linux-arm-kernel

As we've now removed the spinlock and bitmask, we have nothing left
which requires interrupts to be disabled when sending an IPI.  All
current IPI-sending implementations use the GIC, which also does not
require interrupts disabled when calling gic_raise_softirq().

Remove the now unnecessary IRQ disable.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/kernel/smp.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 78d55c6..4878e51 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -383,16 +383,10 @@ void __init smp_prepare_boot_cpu(void)
 
 static void send_ipi_message(const struct cpumask *mask, enum ipi_msg_type msg)
 {
-	unsigned long flags;
-
-	local_irq_save(flags);
-
 	/*
 	 * Call the platform specific cross-CPU call function.
 	 */
 	smp_cross_call(mask, msg);
-
-	local_irq_restore(flags);
 }
 
 void arch_send_call_function_ipi_mask(const struct cpumask *mask)
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 05/22] ARM: include local timer irq stats only when local timers configured
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (3 preceding siblings ...)
  2010-12-03 20:20 ` [PATCH 04/22] ARM: SMP: remove IRQ-disabling for smp_cross_call() Russell King - ARM Linux
@ 2010-12-03 20:20 ` Russell King - ARM Linux
  2010-12-03 20:20 ` [PATCH 06/22] ARM: SMP: provide accessors for irq_stat data Russell King - ARM Linux
                   ` (18 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:20 UTC (permalink / raw)
  To: linux-arm-kernel

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/include/asm/hardirq.h |    2 ++
 arch/arm/kernel/irq.c          |    2 ++
 arch/arm/kernel/smp.c          |   24 ++++++++++++------------
 3 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/arch/arm/include/asm/hardirq.h b/arch/arm/include/asm/hardirq.h
index 6d7485a..522fb23 100644
--- a/arch/arm/include/asm/hardirq.h
+++ b/arch/arm/include/asm/hardirq.h
@@ -7,7 +7,9 @@
 
 typedef struct {
 	unsigned int __softirq_pending;
+#ifdef CONFIG_LOCAL_TIMERS
 	unsigned int local_timer_irqs;
+#endif
 } ____cacheline_aligned irq_cpustat_t;
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
index 36ad3be..ea29721 100644
--- a/arch/arm/kernel/irq.c
+++ b/arch/arm/kernel/irq.c
@@ -93,6 +93,8 @@ unlock:
 #endif
 #ifdef CONFIG_SMP
 		show_ipi_list(p);
+#endif
+#ifdef CONFIG_LOCAL_TIMERS
 		show_local_irqs(p);
 #endif
 		seq_printf(p, "Err: %10lu\n", irq_err_count);
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 4878e51..6604d74 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -411,18 +411,6 @@ void show_ipi_list(struct seq_file *p)
 	seq_putc(p, '\n');
 }
 
-void show_local_irqs(struct seq_file *p)
-{
-	unsigned int cpu;
-
-	seq_printf(p, "LOC: ");
-
-	for_each_present_cpu(cpu)
-		seq_printf(p, "%10u ", irq_stat[cpu].local_timer_irqs);
-
-	seq_putc(p, '\n');
-}
-
 /*
  * Timer (local or broadcast) support
  */
@@ -449,6 +437,18 @@ asmlinkage void __exception do_local_timer(struct pt_regs *regs)
 
 	set_irq_regs(old_regs);
 }
+
+void show_local_irqs(struct seq_file *p)
+{
+	unsigned int cpu;
+
+	seq_printf(p, "LOC: ");
+
+	for_each_present_cpu(cpu)
+		seq_printf(p, "%10u ", irq_stat[cpu].local_timer_irqs);
+
+	seq_putc(p, '\n');
+}
 #endif
 
 #ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 06/22] ARM: SMP: provide accessors for irq_stat data
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (4 preceding siblings ...)
  2010-12-03 20:20 ` [PATCH 05/22] ARM: include local timer irq stats only when local timers configured Russell King - ARM Linux
@ 2010-12-03 20:20 ` Russell King - ARM Linux
  2010-12-03 20:21 ` [PATCH 07/22] ARM: SMP: move ipi_count into irq_stat structure Russell King - ARM Linux
                   ` (17 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:20 UTC (permalink / raw)
  To: linux-arm-kernel

Provide __inc_irq_stat() and __get_irq_stat() to increment and
read the irq stat counters.

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/include/asm/hardirq.h |    3 +++
 arch/arm/kernel/smp.c          |    4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/hardirq.h b/arch/arm/include/asm/hardirq.h
index 522fb23..923eaa1 100644
--- a/arch/arm/include/asm/hardirq.h
+++ b/arch/arm/include/asm/hardirq.h
@@ -14,6 +14,9 @@ typedef struct {
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
 
+#define __inc_irq_stat(cpu, member)	__IRQ_STAT(cpu, member)++
+#define __get_irq_stat(cpu, member)	__IRQ_STAT(cpu, member)
+
 #if NR_IRQS > 512
 #define HARDIRQ_BITS	10
 #elif NR_IRQS > 256
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 6604d74..101bce0 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -431,7 +431,7 @@ asmlinkage void __exception do_local_timer(struct pt_regs *regs)
 	int cpu = smp_processor_id();
 
 	if (local_timer_ack()) {
-		irq_stat[cpu].local_timer_irqs++;
+		__inc_irq_stat(cpu, local_timer_irqs);
 		ipi_timer();
 	}
 
@@ -445,7 +445,7 @@ void show_local_irqs(struct seq_file *p)
 	seq_printf(p, "LOC: ");
 
 	for_each_present_cpu(cpu)
-		seq_printf(p, "%10u ", irq_stat[cpu].local_timer_irqs);
+		seq_printf(p, "%10u ", __get_irq_stat(cpu, local_timer_irqs));
 
 	seq_putc(p, '\n');
 }
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 07/22] ARM: SMP: move ipi_count into irq_stat structure
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (5 preceding siblings ...)
  2010-12-03 20:20 ` [PATCH 06/22] ARM: SMP: provide accessors for irq_stat data Russell King - ARM Linux
@ 2010-12-03 20:21 ` Russell King - ARM Linux
  2010-12-03 20:21 ` [PATCH 08/22] ARM: fix /proc/interrupts formatting Russell King - ARM Linux
                   ` (16 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:21 UTC (permalink / raw)
  To: linux-arm-kernel

Move the ipi_count into irq_stat, which allows the ipi_data structure
to be entirely removed.

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/include/asm/hardirq.h |    3 +++
 arch/arm/kernel/smp.c          |   14 ++------------
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/arch/arm/include/asm/hardirq.h b/arch/arm/include/asm/hardirq.h
index 923eaa1..824b08a 100644
--- a/arch/arm/include/asm/hardirq.h
+++ b/arch/arm/include/asm/hardirq.h
@@ -10,6 +10,9 @@ typedef struct {
 #ifdef CONFIG_LOCAL_TIMERS
 	unsigned int local_timer_irqs;
 #endif
+#ifdef CONFIG_SMP
+	unsigned int ipi_irqs;
+#endif
 } ____cacheline_aligned irq_cpustat_t;
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 101bce0..42e0ae9 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -46,15 +46,6 @@
  */
 struct secondary_data secondary_data;
 
-/*
- * structures for inter-processor calls
- */
-struct ipi_data {
-	unsigned long ipi_count;
-};
-
-static DEFINE_PER_CPU(struct ipi_data, ipi_data);
-
 enum ipi_msg_type {
 	IPI_TIMER = 2,
 	IPI_RESCHEDULE,
@@ -406,7 +397,7 @@ void show_ipi_list(struct seq_file *p)
 	seq_puts(p, "IPI:");
 
 	for_each_present_cpu(cpu)
-		seq_printf(p, " %10lu", per_cpu(ipi_data, cpu).ipi_count);
+		seq_printf(p, " %10u", __get_irq_stat(cpu, ipi_irqs));
 
 	seq_putc(p, '\n');
 }
@@ -521,10 +512,9 @@ static void ipi_cpu_stop(unsigned int cpu)
 asmlinkage void __exception do_IPI(int ipinr, struct pt_regs *regs)
 {
 	unsigned int cpu = smp_processor_id();
-	struct ipi_data *ipi = &per_cpu(ipi_data, cpu);
 	struct pt_regs *old_regs = set_irq_regs(regs);
 
-	ipi->ipi_count++;
+	__inc_irq_stat(cpu, ipi_irqs);
 
 	switch (ipinr) {
 	case IPI_TIMER:
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 08/22] ARM: fix /proc/interrupts formatting
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (6 preceding siblings ...)
  2010-12-03 20:21 ` [PATCH 07/22] ARM: SMP: move ipi_count into irq_stat structure Russell King - ARM Linux
@ 2010-12-03 20:21 ` Russell King - ARM Linux
  2010-12-03 20:21 ` [PATCH 09/22] ARM: SMP: provide individual IPI interrupt statistics Russell King - ARM Linux
                   ` (15 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:21 UTC (permalink / raw)
  To: linux-arm-kernel

As per x86, align the initial column according to how many IRQs we
have.  Also, provide an english explaination for the 'LOC:' and
'IPI:' lines.

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/include/asm/mach/irq.h |    2 +-
 arch/arm/include/asm/smp.h      |    4 ++--
 arch/arm/kernel/fiq.c           |    5 +++--
 arch/arm/kernel/irq.c           |   16 ++++++++++------
 arch/arm/kernel/smp.c           |   14 +++++++-------
 5 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/arch/arm/include/asm/mach/irq.h b/arch/arm/include/asm/mach/irq.h
index ce3eee9..2bc47fb 100644
--- a/arch/arm/include/asm/mach/irq.h
+++ b/arch/arm/include/asm/mach/irq.h
@@ -20,7 +20,7 @@ struct seq_file;
 extern unsigned int arch_nr_irqs;
 extern void (*init_arch_irq)(void);
 extern void init_FIQ(void);
-extern int show_fiq_list(struct seq_file *, void *);
+extern int show_fiq_list(struct seq_file *, int);
 
 /*
  * This is for easy migration, but should be changed in the source
diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
index da7e7ca..f93d0a6 100644
--- a/arch/arm/include/asm/smp.h
+++ b/arch/arm/include/asm/smp.h
@@ -33,7 +33,7 @@ struct seq_file;
 /*
  * generate IPI list text
  */
-extern void show_ipi_list(struct seq_file *p);
+extern void show_ipi_list(struct seq_file *, int);
 
 /*
  * Called from assembly code, this handles an IPI.
@@ -97,6 +97,6 @@ extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
 /*
  * show local interrupt info
  */
-extern void show_local_irqs(struct seq_file *);
+extern void show_local_irqs(struct seq_file *, int);
 
 #endif /* ifndef __ASM_ARM_SMP_H */
diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
index 6ff7919..47837b8 100644
--- a/arch/arm/kernel/fiq.c
+++ b/arch/arm/kernel/fiq.c
@@ -67,10 +67,11 @@ static struct fiq_handler default_owner = {
 
 static struct fiq_handler *current_fiq = &default_owner;
 
-int show_fiq_list(struct seq_file *p, void *v)
+int show_fiq_list(struct seq_file *p, int prec)
 {
 	if (current_fiq != &default_owner)
-		seq_printf(p, "FIQ:              %s\n", current_fiq->name);
+		seq_printf(p, "%*s:              %s\n", prec, "FIQ",
+			current_fiq->name);
 
 	return 0;
 }
diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
index ea29721..4e7a7d2 100644
--- a/arch/arm/kernel/irq.c
+++ b/arch/arm/kernel/irq.c
@@ -57,11 +57,15 @@ int show_interrupts(struct seq_file *p, void *v)
 	struct irq_desc *desc;
 	struct irqaction * action;
 	unsigned long flags;
+	int prec, n;
+
+	for (prec = 3, n = 1000; prec < 10 && n <= nr_irqs; prec++)
+		n *= 10;
 
 	if (i == 0) {
 		char cpuname[12];
 
-		seq_printf(p, "    ");
+		seq_printf(p, "%*s ", prec, "");
 		for_each_present_cpu(cpu) {
 			sprintf(cpuname, "CPU%d", cpu);
 			seq_printf(p, " %10s", cpuname);
@@ -76,7 +80,7 @@ int show_interrupts(struct seq_file *p, void *v)
 		if (!action)
 			goto unlock;
 
-		seq_printf(p, "%3d: ", i);
+		seq_printf(p, "%*d: ", prec, i);
 		for_each_present_cpu(cpu)
 			seq_printf(p, "%10u ", kstat_irqs_cpu(i, cpu));
 		seq_printf(p, " %10s", desc->chip->name ? : "-");
@@ -89,15 +93,15 @@ unlock:
 		raw_spin_unlock_irqrestore(&desc->lock, flags);
 	} else if (i == nr_irqs) {
 #ifdef CONFIG_FIQ
-		show_fiq_list(p, v);
+		show_fiq_list(p, prec);
 #endif
 #ifdef CONFIG_SMP
-		show_ipi_list(p);
+		show_ipi_list(p, prec);
 #endif
 #ifdef CONFIG_LOCAL_TIMERS
-		show_local_irqs(p);
+		show_local_irqs(p, prec);
 #endif
-		seq_printf(p, "Err: %10lu\n", irq_err_count);
+		seq_printf(p, "%*s: %10lu\n", prec, "Err", irq_err_count);
 	}
 	return 0;
 }
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 42e0ae9..e45efae 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -390,16 +390,16 @@ void arch_send_call_function_single_ipi(int cpu)
 	send_ipi_message(cpumask_of(cpu), IPI_CALL_FUNC_SINGLE);
 }
 
-void show_ipi_list(struct seq_file *p)
+void show_ipi_list(struct seq_file *p, int prec)
 {
 	unsigned int cpu;
 
-	seq_puts(p, "IPI:");
+	seq_printf(p, "%*s: ", prec, "IPI");
 
 	for_each_present_cpu(cpu)
-		seq_printf(p, " %10u", __get_irq_stat(cpu, ipi_irqs));
+		seq_printf(p, "%10u ", __get_irq_stat(cpu, ipi_irqs));
 
-	seq_putc(p, '\n');
+	seq_printf(p, " Inter-processor interrupts\n");
 }
 
 /*
@@ -429,16 +429,16 @@ asmlinkage void __exception do_local_timer(struct pt_regs *regs)
 	set_irq_regs(old_regs);
 }
 
-void show_local_irqs(struct seq_file *p)
+void show_local_irqs(struct seq_file *p, int prec)
 {
 	unsigned int cpu;
 
-	seq_printf(p, "LOC: ");
+	seq_printf(p, "%*s: ", prec, "LOC");
 
 	for_each_present_cpu(cpu)
 		seq_printf(p, "%10u ", __get_irq_stat(cpu, local_timer_irqs));
 
-	seq_putc(p, '\n');
+	seq_printf(p, " Local timer interrupts\n");
 }
 #endif
 
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 09/22] ARM: SMP: provide individual IPI interrupt statistics
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (7 preceding siblings ...)
  2010-12-03 20:21 ` [PATCH 08/22] ARM: fix /proc/interrupts formatting Russell King - ARM Linux
@ 2010-12-03 20:21 ` Russell King - ARM Linux
  2010-12-03 20:22 ` [PATCH 10/22] ARM: SMP: collect IPI and local timer IRQs for /proc/stat Russell King - ARM Linux
                   ` (14 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:21 UTC (permalink / raw)
  To: linux-arm-kernel

This separates out the individual IPI interrupt counts from the
total IPI count, which allows better visibility of what IPIs are
being used for.

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/include/asm/hardirq.h |    4 +++-
 arch/arm/kernel/irq.c          |    5 +++++
 arch/arm/kernel/smp.c          |   25 +++++++++++++++++++------
 3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/arch/arm/include/asm/hardirq.h b/arch/arm/include/asm/hardirq.h
index 824b08a..c52e250 100644
--- a/arch/arm/include/asm/hardirq.h
+++ b/arch/arm/include/asm/hardirq.h
@@ -5,13 +5,15 @@
 #include <linux/threads.h>
 #include <asm/irq.h>
 
+#define NR_IPI	5
+
 typedef struct {
 	unsigned int __softirq_pending;
 #ifdef CONFIG_LOCAL_TIMERS
 	unsigned int local_timer_irqs;
 #endif
 #ifdef CONFIG_SMP
-	unsigned int ipi_irqs;
+	unsigned int ipi_irqs[NR_IPI];
 #endif
 } ____cacheline_aligned irq_cpustat_t;
 
diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
index 4e7a7d2..6276f01 100644
--- a/arch/arm/kernel/irq.c
+++ b/arch/arm/kernel/irq.c
@@ -62,6 +62,11 @@ int show_interrupts(struct seq_file *p, void *v)
 	for (prec = 3, n = 1000; prec < 10 && n <= nr_irqs; prec++)
 		n *= 10;
 
+#ifdef CONFIG_SMP
+	if (prec < 4)
+		prec = 4;
+#endif
+
 	if (i == 0) {
 		char cpuname[12];
 
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index e45efae..1d9d6d8 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -390,16 +390,28 @@ void arch_send_call_function_single_ipi(int cpu)
 	send_ipi_message(cpumask_of(cpu), IPI_CALL_FUNC_SINGLE);
 }
 
+static const char *ipi_types[NR_IPI] = {
+#define S(x,s)	[x - IPI_TIMER] = s
+	S(IPI_TIMER, "Timer broadcast interrupts"),
+	S(IPI_RESCHEDULE, "Rescheduling interrupts"),
+	S(IPI_CALL_FUNC, "Function call interrupts"),
+	S(IPI_CALL_FUNC_SINGLE, "Single function call interrupts"),
+	S(IPI_CPU_STOP, "CPU stop interrupts"),
+};
+
 void show_ipi_list(struct seq_file *p, int prec)
 {
-	unsigned int cpu;
+	unsigned int cpu, i;
 
-	seq_printf(p, "%*s: ", prec, "IPI");
+	for (i = 0; i < NR_IPI; i++) {
+		seq_printf(p, "%*s%u: ", prec - 1, "IPI", i);
 
-	for_each_present_cpu(cpu)
-		seq_printf(p, "%10u ", __get_irq_stat(cpu, ipi_irqs));
+		for_each_present_cpu(cpu)
+			seq_printf(p, "%10u ",
+				   __get_irq_stat(cpu, ipi_irqs[i]));
 
-	seq_printf(p, " Inter-processor interrupts\n");
+		seq_printf(p, " %s\n", ipi_types[i]);
+	}
 }
 
 /*
@@ -514,7 +526,8 @@ asmlinkage void __exception do_IPI(int ipinr, struct pt_regs *regs)
 	unsigned int cpu = smp_processor_id();
 	struct pt_regs *old_regs = set_irq_regs(regs);
 
-	__inc_irq_stat(cpu, ipi_irqs);
+	if (ipinr >= IPI_TIMER && ipinr < IPI_TIMER + NR_IPI)
+		__inc_irq_stat(cpu, ipi_irqs[ipinr - IPI_TIMER]);
 
 	switch (ipinr) {
 	case IPI_TIMER:
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 10/22] ARM: SMP: collect IPI and local timer IRQs for /proc/stat
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (8 preceding siblings ...)
  2010-12-03 20:21 ` [PATCH 09/22] ARM: SMP: provide individual IPI interrupt statistics Russell King - ARM Linux
@ 2010-12-03 20:22 ` Russell King - ARM Linux
  2010-12-03 20:22 ` [PATCH 11/22] ARM: SMP: use more sane register allocation for __fixup_smp_on_up Russell King - ARM Linux
                   ` (13 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:22 UTC (permalink / raw)
  To: linux-arm-kernel

The IPI and local timer interrupts weren't being properly accounted
for in /proc/stat.  Collect them from the irq_stat structure, and
return their sum.

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/include/asm/hardirq.h |    8 ++++++++
 arch/arm/kernel/smp.c          |   15 +++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/arch/arm/include/asm/hardirq.h b/arch/arm/include/asm/hardirq.h
index c52e250..89ad180 100644
--- a/arch/arm/include/asm/hardirq.h
+++ b/arch/arm/include/asm/hardirq.h
@@ -22,6 +22,14 @@ typedef struct {
 #define __inc_irq_stat(cpu, member)	__IRQ_STAT(cpu, member)++
 #define __get_irq_stat(cpu, member)	__IRQ_STAT(cpu, member)
 
+#ifdef CONFIG_SMP
+u64 smp_irq_stat_cpu(unsigned int cpu);
+#else
+#define smp_irq_stat_cpu(cpu)	0
+#endif
+
+#define arch_irq_stat_cpu	smp_irq_stat_cpu
+
 #if NR_IRQS > 512
 #define HARDIRQ_BITS	10
 #elif NR_IRQS > 256
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 1d9d6d8..aa1c6f5 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -414,6 +414,21 @@ void show_ipi_list(struct seq_file *p, int prec)
 	}
 }
 
+u64 smp_irq_stat_cpu(unsigned int cpu)
+{
+	u64 sum = 0;
+	int i;
+
+	for (i = 0; i < NR_IPI; i++)
+		sum += __get_irq_stat(cpu, ipi_irqs[i]);
+
+#ifdef CONFIG_LOCAL_TIMERS
+	sum += __get_irq_stat(cpu, local_timer_irqs);
+#endif
+
+	return sum;
+}
+
 /*
  * Timer (local or broadcast) support
  */
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 11/22] ARM: SMP: use more sane register allocation for __fixup_smp_on_up
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (9 preceding siblings ...)
  2010-12-03 20:22 ` [PATCH 10/22] ARM: SMP: collect IPI and local timer IRQs for /proc/stat Russell King - ARM Linux
@ 2010-12-03 20:22 ` Russell King - ARM Linux
  2010-12-03 20:23 ` [PATCH 12/22] ARM: SMP: ensure smp_send_stop() waits for CPUs to stop Russell King - ARM Linux
                   ` (12 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:22 UTC (permalink / raw)
  To: linux-arm-kernel

Use r0,r3-r6 rather than r0,r3,r4,r6,r7, which makes it easier to
understand which registers can be modified.  Also document which
registers hold values which must be preserved.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/kernel/head.S |   39 ++++++++++++++++++++++-----------------
 1 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index dd6b369..fd94e4e 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -89,6 +89,11 @@ ENTRY(stext)
 	bl	__lookup_machine_type		@ r5=machinfo
 	movs	r8, r5				@ invalid machine (r5=0)?
 	beq	__error_a			@ yes, error 'a'
+
+	/*
+	 * r1 = machine no, r2 = atags,
+	 * r8 = machinfo, r9 = cpuid, r10 = procinfo
+	 */
 	bl	__vet_atags
 #ifdef CONFIG_SMP_ON_UP
 	bl	__fixup_smp
@@ -381,19 +386,19 @@ ENDPROC(__turn_mmu_on)
 
 #ifdef CONFIG_SMP_ON_UP
 __fixup_smp:
-	mov	r7, #0x00070000
-	orr	r6, r7, #0xff000000	@ mask 0xff070000
-	orr	r7, r7, #0x41000000	@ val 0x41070000
-	and	r0, r9, r6
-	teq	r0, r7			@ ARM CPU and ARMv6/v7?
+	mov	r4, #0x00070000
+	orr	r3, r4, #0xff000000	@ mask 0xff070000
+	orr	r4, r4, #0x41000000	@ val 0x41070000
+	and	r0, r9, r3
+	teq	r0, r4			@ ARM CPU and ARMv6/v7?
 	bne	__fixup_smp_on_up	@ no, assume UP
 
-	orr	r6, r6, #0x0000ff00
-	orr	r6, r6, #0x000000f0	@ mask 0xff07fff0
-	orr	r7, r7, #0x0000b000
-	orr	r7, r7, #0x00000020	@ val 0x4107b020
-	and	r0, r9, r6
-	teq	r0, r7			@ ARM 11MPCore?
+	orr	r3, r3, #0x0000ff00
+	orr	r3, r3, #0x000000f0	@ mask 0xff07fff0
+	orr	r4, r4, #0x0000b000
+	orr	r4, r4, #0x00000020	@ val 0x4107b020
+	and	r0, r9, r3
+	teq	r0, r4			@ ARM 11MPCore?
 	moveq	pc, lr			@ yes, assume SMP
 
 	mrc	p15, 0, r0, c0, c0, 5	@ read MPIDR
@@ -402,13 +407,13 @@ __fixup_smp:
 
 __fixup_smp_on_up:
 	adr	r0, 1f
-	ldmia	r0, {r3, r6, r7}
+	ldmia	r0, {r3 - r5}
 	sub	r3, r0, r3
-	add	r6, r6, r3
-	add	r7, r7, r3
-2:	cmp	r6, r7
-	ldmia	r6!, {r0, r4}
-	strlo	r4, [r0, r3]
+	add	r4, r4, r3
+	add	r5, r5, r3
+2:	cmp	r4, r5
+	ldmia	r4!, {r0, r6}
+	strlo	r6, [r0, r3]
 	blo	2b
 	mov	pc, lr
 ENDPROC(__fixup_smp)
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 12/22] ARM: SMP: ensure smp_send_stop() waits for CPUs to stop
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (10 preceding siblings ...)
  2010-12-03 20:22 ` [PATCH 11/22] ARM: SMP: use more sane register allocation for __fixup_smp_on_up Russell King - ARM Linux
@ 2010-12-03 20:23 ` Russell King - ARM Linux
  2010-12-03 20:23 ` [PATCH 13/22] ARM: SMP: move CPU number sanity checks to smp_init_cpus() Russell King - ARM Linux
                   ` (11 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:23 UTC (permalink / raw)
  To: linux-arm-kernel

Wait for CPUs to indicate that they've stopped, after sending the
stop IPI, rather than blindly continuing on and hoping that they've
stopped in time.  Print a warning if we fail to stop the other CPUs.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/kernel/smp.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index aa1c6f5..48bccf3 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -583,10 +583,22 @@ void smp_send_reschedule(int cpu)
 
 void smp_send_stop(void)
 {
-	cpumask_t mask = cpu_online_map;
-	cpu_clear(smp_processor_id(), mask);
-	if (!cpus_empty(mask))
+	unsigned long timeout;
+
+	if (num_online_cpus() > 1) {
+		cpumask_t mask = cpu_online_map;
+		cpu_clear(smp_processor_id(), mask);
+
 		send_ipi_message(&mask, IPI_CPU_STOP);
+	}
+
+	/* Wait up to one second for other CPUs to stop */
+	timeout = USEC_PER_SEC;
+	while (num_online_cpus() > 1 && timeout--)
+		udelay(1);
+
+	if (num_online_cpus() > 1)
+		pr_warning("SMP: failed to stop secondary CPUs\n");
 }
 
 /*
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 13/22] ARM: SMP: move CPU number sanity checks to smp_init_cpus()
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (11 preceding siblings ...)
  2010-12-03 20:23 ` [PATCH 12/22] ARM: SMP: ensure smp_send_stop() waits for CPUs to stop Russell King - ARM Linux
@ 2010-12-03 20:23 ` Russell King - ARM Linux
  2010-12-03 20:23 ` [PATCH 14/22] ARM: SMP: Clean up ncores sanity checks Russell King - ARM Linux
                   ` (10 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:23 UTC (permalink / raw)
  To: linux-arm-kernel

Ensure that the number of CPUs is sanity checked before setting
the number of possible CPUs.  This avoids any chance of overflowing
the cpu_possible bitmap.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/mach-omap2/omap-smp.c   |   21 +++++++++++----------
 arch/arm/mach-realview/platsmp.c |   20 ++++++++++----------
 arch/arm/mach-ux500/platsmp.c    |   26 +++++++++++++-------------
 3 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
index 56a8bce..3c87468 100644
--- a/arch/arm/mach-omap2/omap-smp.c
+++ b/arch/arm/mach-omap2/omap-smp.c
@@ -120,16 +120,6 @@ void __init smp_init_cpus(void)
 
 	ncores = get_core_count();
 
-	for (i = 0; i < ncores; i++)
-		set_cpu_possible(i, true);
-}
-
-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
@@ -144,6 +134,17 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 		       ncores, NR_CPUS);
 		ncores = NR_CPUS;
 	}
+
+	for (i = 0; i < ncores; i++)
+		set_cpu_possible(i, true);
+}
+
+void __init smp_prepare_cpus(unsigned int max_cpus)
+{
+	unsigned int ncores = num_possible_cpus();
+	unsigned int cpu = smp_processor_id();
+	int i;
+
 	smp_store_cpu_info(cpu);
 
 	/*
diff --git a/arch/arm/mach-realview/platsmp.c b/arch/arm/mach-realview/platsmp.c
index af3d909..108e92f 100644
--- a/arch/arm/mach-realview/platsmp.c
+++ b/arch/arm/mach-realview/platsmp.c
@@ -160,16 +160,6 @@ void __init smp_init_cpus(void)
 {
 	unsigned int i, ncores = get_core_count();
 
-	for (i = 0; i < ncores; i++)
-		set_cpu_possible(i, true);
-}
-
-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
@@ -186,6 +176,16 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 		ncores = NR_CPUS;
 	}
 
+	for (i = 0; i < ncores; i++)
+		set_cpu_possible(i, true);
+}
+
+void __init smp_prepare_cpus(unsigned int max_cpus)
+{
+	unsigned int ncores = num_possible_cpus();
+	unsigned int cpu = smp_processor_id();
+	int i;
+
 	smp_store_cpu_info(cpu);
 
 	/*
diff --git a/arch/arm/mach-ux500/platsmp.c b/arch/arm/mach-ux500/platsmp.c
index b8987bd..a51962b 100644
--- a/arch/arm/mach-ux500/platsmp.c
+++ b/arch/arm/mach-ux500/platsmp.c
@@ -128,16 +128,6 @@ void __init smp_init_cpus(void)
 {
 	unsigned int i, ncores = get_core_count();
 
-	for (i = 0; i < ncores; i++)
-		set_cpu_possible(i, true);
-}
-
-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
@@ -145,14 +135,24 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 		ncores = 1;
 	}
 
-	if (ncores > num_possible_cpus())	{
+	if (ncores > NR_CPUS) {
 		printk(KERN_WARNING
 		       "U8500: no. of cores (%d) greater than configured "
 		       "maximum of %d - clipping\n",
-		       ncores, num_possible_cpus());
-		ncores = num_possible_cpus();
+		       ncores, NR_CPUS);
+		ncores = NR_CPUS;
 	}
 
+	for (i = 0; i < ncores; i++)
+		set_cpu_possible(i, true);
+}
+
+void __init smp_prepare_cpus(unsigned int max_cpus)
+{
+	unsigned int ncores = num_possible_cpus();
+	unsigned int cpu = smp_processor_id();
+	int i;
+
 	smp_store_cpu_info(cpu);
 
 	/*
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 14/22] ARM: SMP: Clean up ncores sanity checks
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (12 preceding siblings ...)
  2010-12-03 20:23 ` [PATCH 13/22] ARM: SMP: move CPU number sanity checks to smp_init_cpus() Russell King - ARM Linux
@ 2010-12-03 20:23 ` Russell King - ARM Linux
  2010-12-03 20:24 ` [PATCH 15/22] ARM: SMP: get rid of get_core_count() Russell King - ARM Linux
                   ` (9 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:23 UTC (permalink / raw)
  To: linux-arm-kernel

scu_get_core_count() never returns zero cores, so we don't need to
check and correct if ncores is zero.

Tegra was missing the check against NR_CPUS, leading to a potential
bitfield overflow if this becomes the case.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/mach-omap2/omap-smp.c   |    6 ------
 arch/arm/mach-realview/platsmp.c |    7 -------
 arch/arm/mach-s5pv310/platsmp.c  |    7 -------
 arch/arm/mach-tegra/platsmp.c    |    6 ++++++
 arch/arm/mach-ux500/platsmp.c    |    6 ------
 arch/arm/mach-vexpress/platsmp.c |    7 -------
 6 files changed, 6 insertions(+), 33 deletions(-)

diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
index 3c87468..5f10f38 100644
--- a/arch/arm/mach-omap2/omap-smp.c
+++ b/arch/arm/mach-omap2/omap-smp.c
@@ -121,12 +121,6 @@ void __init smp_init_cpus(void)
 	ncores = get_core_count();
 
 	/* 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 "
diff --git a/arch/arm/mach-realview/platsmp.c b/arch/arm/mach-realview/platsmp.c
index 108e92f..13116cd 100644
--- a/arch/arm/mach-realview/platsmp.c
+++ b/arch/arm/mach-realview/platsmp.c
@@ -161,13 +161,6 @@ void __init smp_init_cpus(void)
 	unsigned int i, ncores = get_core_count();
 
 	/* sanity check */
-	if (ncores == 0) {
-		printk(KERN_ERR
-		       "Realview: strange CM count of 0? Default to 1\n");
-
-		ncores = 1;
-	}
-
 	if (ncores > NR_CPUS) {
 		printk(KERN_WARNING
 		       "Realview: no. of cores (%d) greater than configured "
diff --git a/arch/arm/mach-s5pv310/platsmp.c b/arch/arm/mach-s5pv310/platsmp.c
index d474426..560ada8 100644
--- a/arch/arm/mach-s5pv310/platsmp.c
+++ b/arch/arm/mach-s5pv310/platsmp.c
@@ -130,13 +130,6 @@ void __init smp_init_cpus(void)
 	ncores = scu_base ? scu_get_core_count(scu_base) : 1;
 
 	/* sanity check */
-	if (ncores == 0) {
-		printk(KERN_ERR
-		       "S5PV310: strange CM count of 0? Default to 1\n");
-
-		ncores = 1;
-	}
-
 	if (ncores > NR_CPUS) {
 		printk(KERN_WARNING
 		       "S5PV310: no. of cores (%d) greater than configured "
diff --git a/arch/arm/mach-tegra/platsmp.c b/arch/arm/mach-tegra/platsmp.c
index 1c0fd92..5b194dd 100644
--- a/arch/arm/mach-tegra/platsmp.c
+++ b/arch/arm/mach-tegra/platsmp.c
@@ -117,6 +117,12 @@ void __init smp_init_cpus(void)
 {
 	unsigned int i, ncores = scu_get_core_count(scu_base);
 
+	if (ncores > NR_CPUS) {
+		printk(KERN_ERR "Tegra: no. of cores (%u) greater than configured (%u), clipping\n",
+			ncores, NR_CPUS);
+		ncores = NR_CPUS;
+	}
+
 	for (i = 0; i < ncores; i++)
 		cpu_set(i, cpu_possible_map);
 }
diff --git a/arch/arm/mach-ux500/platsmp.c b/arch/arm/mach-ux500/platsmp.c
index a51962b..e31024e 100644
--- a/arch/arm/mach-ux500/platsmp.c
+++ b/arch/arm/mach-ux500/platsmp.c
@@ -129,12 +129,6 @@ void __init smp_init_cpus(void)
 	unsigned int i, ncores = get_core_count();
 
 	/* sanity check */
-	if (ncores == 0) {
-		printk(KERN_ERR
-		       "U8500: strange CM count of 0? Default to 1\n");
-		ncores = 1;
-	}
-
 	if (ncores > NR_CPUS) {
 		printk(KERN_WARNING
 		       "U8500: no. of cores (%d) greater than configured "
diff --git a/arch/arm/mach-vexpress/platsmp.c b/arch/arm/mach-vexpress/platsmp.c
index 276f916..b5a7586 100644
--- a/arch/arm/mach-vexpress/platsmp.c
+++ b/arch/arm/mach-vexpress/platsmp.c
@@ -124,13 +124,6 @@ void __init smp_init_cpus(void)
 	ncores = scu_base ? scu_get_core_count(scu_base) : 1;
 
 	/* sanity check */
-	if (ncores == 0) {
-		printk(KERN_ERR
-		       "vexpress: strange CM count of 0? Default to 1\n");
-
-		ncores = 1;
-	}
-
 	if (ncores > NR_CPUS) {
 		printk(KERN_WARNING
 		       "vexpress: no. of cores (%d) greater than configured "
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 15/22] ARM: SMP: get rid of get_core_count()
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (13 preceding siblings ...)
  2010-12-03 20:23 ` [PATCH 14/22] ARM: SMP: Clean up ncores sanity checks Russell King - ARM Linux
@ 2010-12-03 20:24 ` Russell King - ARM Linux
  2010-12-03 20:24 ` [PATCH 16/22] ARM: SMP: get rid of references to poke_milo and Milo Russell King - ARM Linux
                   ` (8 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:24 UTC (permalink / raw)
  To: linux-arm-kernel

We don't need this small function as well as scu_get_core_count()

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/mach-omap2/omap-smp.c   |   12 +-----------
 arch/arm/mach-realview/platsmp.c |   13 ++++---------
 arch/arm/mach-ux500/platsmp.c    |    9 +++------
 3 files changed, 8 insertions(+), 26 deletions(-)

diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
index 5f10f38..405a8fc 100644
--- a/arch/arm/mach-omap2/omap-smp.c
+++ b/arch/arm/mach-omap2/omap-smp.c
@@ -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)
@@ -118,7 +108,7 @@ void __init smp_init_cpus(void)
 	scu_base = ioremap(OMAP44XX_SCU_BASE, SZ_256);
 	BUG_ON(!scu_base);
 
-	ncores = get_core_count();
+	ncores = scu_get_core_count(scu_base);
 
 	/* sanity check */
 	if (ncores > NR_CPUS) {
diff --git a/arch/arm/mach-realview/platsmp.c b/arch/arm/mach-realview/platsmp.c
index 13116cd..6595e87 100644
--- a/arch/arm/mach-realview/platsmp.c
+++ b/arch/arm/mach-realview/platsmp.c
@@ -50,14 +50,6 @@ static void __iomem *scu_base_addr(void)
 		return (void __iomem *)0;
 }
 
-static inline unsigned int get_core_count(void)
-{
-	void __iomem *scu_base = scu_base_addr();
-	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)
@@ -158,7 +150,10 @@ static void __init poke_milo(void)
  */
 void __init smp_init_cpus(void)
 {
-	unsigned int i, ncores = get_core_count();
+	void __iomem *scu_base = scu_base_addr();
+	unsigned int i, ncores;
+
+	ncores = scu_base ? scu_get_core_count(scu_base) : 1;
 
 	/* sanity check */
 	if (ncores > NR_CPUS) {
diff --git a/arch/arm/mach-ux500/platsmp.c b/arch/arm/mach-ux500/platsmp.c
index e31024e..fd40fa1 100644
--- a/arch/arm/mach-ux500/platsmp.c
+++ b/arch/arm/mach-ux500/platsmp.c
@@ -28,11 +28,6 @@
  */
 volatile int __cpuinitdata pen_release = -1;
 
-static unsigned int __init get_core_count(void)
-{
-	return scu_get_core_count(__io_address(UX500_SCU_BASE));
-}
-
 static DEFINE_SPINLOCK(boot_lock);
 
 void __cpuinit platform_secondary_init(unsigned int cpu)
@@ -126,7 +121,9 @@ static void __init wakeup_secondary(void)
  */
 void __init smp_init_cpus(void)
 {
-	unsigned int i, ncores = get_core_count();
+	unsigned int i, ncores;
+
+	ncores = scu_get_core_count(__io_address(UX500_SCU_BASE));
 
 	/* sanity check */
 	if (ncores > NR_CPUS) {
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 16/22] ARM: SMP: get rid of references to poke_milo and Milo
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (14 preceding siblings ...)
  2010-12-03 20:24 ` [PATCH 15/22] ARM: SMP: get rid of get_core_count() Russell King - ARM Linux
@ 2010-12-03 20:24 ` Russell King - ARM Linux
  2010-12-03 20:24 ` [PATCH 17/22] ARM: SMP: consolidate the common parts of smp_prepare_cpus() Russell King - ARM Linux
                   ` (7 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:24 UTC (permalink / raw)
  To: linux-arm-kernel

Milo is an old boot loader, which is no longer relevant for these
platforms.  References to it are misleading.  Move the code out
of poke_milo(), and remove references to milo in comments.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/mach-realview/platsmp.c |   44 ++++++++++---------------------------
 arch/arm/mach-tegra/platsmp.c    |    7 ------
 2 files changed, 12 insertions(+), 39 deletions(-)

diff --git a/arch/arm/mach-realview/platsmp.c b/arch/arm/mach-realview/platsmp.c
index 6595e87..ef3cc86 100644
--- a/arch/arm/mach-realview/platsmp.c
+++ b/arch/arm/mach-realview/platsmp.c
@@ -99,14 +99,9 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
 	flush_cache_all();
 
 	/*
-	 * XXX
-	 *
-	 * This is a later addition to the booting protocol: the
-	 * bootMonitor now puts secondary cores into WFI, so
-	 * poke_milo() no longer gets the cores moving; we need
-	 * to send a soft interrupt to wake the secondary core.
-	 * Use smp_cross_call() for this, since there's little
-	 * point duplicating the code here
+	 * Send the secondary CPU a soft interrupt, thereby causing
+	 * the boot monitor to read the system wide flags register,
+	 * and branch to the address found there.
 	 */
 	smp_cross_call(cpumask_of(cpu), 1);
 
@@ -128,22 +123,6 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
 	return pen_release != -1 ? -ENOSYS : 0;
 }
 
-static void __init poke_milo(void)
-{
-	/* nobody is to be released from the pen yet */
-	pen_release = -1;
-
-	/*
-	 * Write the address of secondary startup into the system-wide flags
-	 * register. The BootMonitor waits for this register to become
-	 * non-zero.
-	 */
-	__raw_writel(BSYM(virt_to_phys(realview_secondary_startup)),
-		     __io_address(REALVIEW_SYS_FLAGSSET));
-
-	mb();
-}
-
 /*
  * Initialise the CPU possible map early - this describes the CPUs
  * which may be present or become present in the system.
@@ -189,13 +168,6 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 	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) {
 		/*
 		 * Enable the local timer or broadcast device for the
@@ -204,6 +176,14 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 		percpu_timer_setup();
 
 		scu_enable(scu_base_addr());
-		poke_milo();
+
+		/*
+		 * Write the address of secondary startup into the
+		 * system-wide flags register. The BootMonitor waits
+		 * until it receives a soft interrupt, and then the
+		 * secondary CPU branches to this address.
+		 */
+		__raw_writel(BSYM(virt_to_phys(realview_secondary_startup)),
+			     __io_address(REALVIEW_SYS_FLAGSSET));
 	}
 }
diff --git a/arch/arm/mach-tegra/platsmp.c b/arch/arm/mach-tegra/platsmp.c
index 5b194dd..66d0634 100644
--- a/arch/arm/mach-tegra/platsmp.c
+++ b/arch/arm/mach-tegra/platsmp.c
@@ -148,13 +148,6 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 	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);
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 17/22] ARM: SMP: consolidate the common parts of smp_prepare_cpus()
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (15 preceding siblings ...)
  2010-12-03 20:24 ` [PATCH 16/22] ARM: SMP: get rid of references to poke_milo and Milo Russell King - ARM Linux
@ 2010-12-03 20:24 ` Russell King - ARM Linux
  2010-12-03 20:25 ` [PATCH 18/22] ARM: SMP: consolidate trace_hardirqs_off() into common SMP code Russell King - ARM Linux
                   ` (6 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:24 UTC (permalink / raw)
  To: linux-arm-kernel

There is a certain amount of smp_prepare_cpus() which doesn't belong
in the platform support code - that is, code which is invariant to the
SMP implementation.  Move this code into arch/arm/kernel/smp.c, and
add a platform_ prefix to the original function.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/include/asm/smp.h       |    9 ++++---
 arch/arm/kernel/smp.c            |   49 +++++++++++++++++++++++++++++--------
 arch/arm/mach-omap2/omap-smp.c   |   33 +++++--------------------
 arch/arm/mach-realview/platsmp.c |   41 ++++++++-----------------------
 arch/arm/mach-s5pv310/platsmp.c  |   35 +++++---------------------
 arch/arm/mach-tegra/platsmp.c    |   18 +------------
 arch/arm/mach-ux500/platsmp.c    |   24 ++----------------
 arch/arm/mach-vexpress/platsmp.c |   43 +++++++-------------------------
 8 files changed, 83 insertions(+), 169 deletions(-)

diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
index f93d0a6..96ed521 100644
--- a/arch/arm/include/asm/smp.h
+++ b/arch/arm/include/asm/smp.h
@@ -45,10 +45,6 @@ asmlinkage void do_IPI(int ipinr, struct pt_regs *regs);
  */
 extern void smp_init_cpus(void);
 
-/*
- * Move global data into per-processor storage.
- */
-extern void smp_store_cpu_info(unsigned int cpuid);
 
 /*
  * Raise an IPI cross call on CPUs in callmap.
@@ -73,6 +69,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 {
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 48bccf3..d50e612 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -282,6 +282,17 @@ void __ref cpu_die(void)
 #endif /* CONFIG_HOTPLUG_CPU */
 
 /*
+ * Called by both boot and secondaries to move global data into
+ * per-processor storage.
+ */
+static void __cpuinit smp_store_cpu_info(unsigned int cpuid)
+{
+	struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpuid);
+
+	cpu_info->loops_per_jiffy = loops_per_jiffy;
+}
+
+/*
  * This is the secondary CPU boot entry.  We're using this CPUs
  * idle thread stack, but a set of temporary page tables.
  */
@@ -339,17 +350,6 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
 	cpu_idle();
 }
 
-/*
- * Called by both boot and secondaries to move global data into
- * per-processor storage.
- */
-void __cpuinit smp_store_cpu_info(unsigned int cpuid)
-{
-	struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpuid);
-
-	cpu_info->loops_per_jiffy = loops_per_jiffy;
-}
-
 void __init smp_cpus_done(unsigned int max_cpus)
 {
 	int cpu;
@@ -372,6 +372,33 @@ void __init smp_prepare_boot_cpu(void)
 	per_cpu(cpu_data, cpu).idle = current;
 }
 
+void __init smp_prepare_cpus(unsigned int max_cpus)
+{
+	unsigned int ncores = num_possible_cpus();
+
+	smp_store_cpu_info(smp_processor_id());
+
+	/*
+	 * are we trying to boot more cores than exist?
+	 */
+	if (max_cpus > ncores)
+		max_cpus = ncores;
+
+	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 if there are more than one CPU
+		 * and let them know where to start.
+		 */
+		platform_smp_prepare_cpus(max_cpus);
+	}
+}
+
 static void send_ipi_message(const struct cpumask *mask, enum ipi_msg_type msg)
 {
 	/*
diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
index 405a8fc..3c3d679 100644
--- a/arch/arm/mach-omap2/omap-smp.c
+++ b/arch/arm/mach-omap2/omap-smp.c
@@ -21,7 +21,6 @@
 #include <linux/io.h>
 
 #include <asm/cacheflush.h>
-#include <asm/localtimer.h>
 #include <asm/smp_scu.h>
 #include <mach/hardware.h>
 #include <mach/omap4-common.h>
@@ -123,20 +122,10 @@ void __init smp_init_cpus(void)
 		set_cpu_possible(i, true);
 }
 
-void __init smp_prepare_cpus(unsigned int max_cpus)
+void __init platform_smp_prepare_cpus(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.
@@ -144,18 +133,10 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 	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);
-		wakeup_secondary();
-	}
+	/*
+	 * Initialise the SCU and wake up the secondary core using
+	 * wakeup_secondary().
+	 */
+	scu_enable(scu_base);
+	wakeup_secondary();
 }
diff --git a/arch/arm/mach-realview/platsmp.c b/arch/arm/mach-realview/platsmp.c
index ef3cc86..380562c 100644
--- a/arch/arm/mach-realview/platsmp.c
+++ b/arch/arm/mach-realview/platsmp.c
@@ -19,7 +19,6 @@
 #include <asm/cacheflush.h>
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
-#include <asm/localtimer.h>
 #include <asm/unified.h>
 
 #include <mach/board-eb.h>
@@ -147,20 +146,10 @@ void __init smp_init_cpus(void)
 		set_cpu_possible(i, true);
 }
 
-void __init smp_prepare_cpus(unsigned int max_cpus)
+void __init platform_smp_prepare_cpus(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.
@@ -168,22 +157,14 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 	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();
-
-		scu_enable(scu_base_addr());
-
-		/*
-		 * Write the address of secondary startup into the
-		 * system-wide flags register. The BootMonitor waits
-		 * until it receives a soft interrupt, and then the
-		 * secondary CPU branches to this address.
-		 */
-		__raw_writel(BSYM(virt_to_phys(realview_secondary_startup)),
-			     __io_address(REALVIEW_SYS_FLAGSSET));
-	}
+	scu_enable(scu_base_addr());
+
+	/*
+	 * Write the address of secondary startup into the
+	 * system-wide flags register. The BootMonitor waits
+	 * until it receives a soft interrupt, and then the
+	 * secondary CPU branches to this address.
+	 */
+	__raw_writel(BSYM(virt_to_phys(realview_secondary_startup)),
+		     __io_address(REALVIEW_SYS_FLAGSSET));
 }
diff --git a/arch/arm/mach-s5pv310/platsmp.c b/arch/arm/mach-s5pv310/platsmp.c
index 560ada8..51c44d4 100644
--- a/arch/arm/mach-s5pv310/platsmp.c
+++ b/arch/arm/mach-s5pv310/platsmp.c
@@ -22,7 +22,6 @@
 #include <linux/io.h>
 
 #include <asm/cacheflush.h>
-#include <asm/localtimer.h>
 #include <asm/smp_scu.h>
 #include <asm/unified.h>
 
@@ -142,18 +141,10 @@ void __init smp_init_cpus(void)
 		set_cpu_possible(i, true);
 }
 
-void __init smp_prepare_cpus(unsigned int max_cpus)
+void __init platform_smp_prepare_cpus(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.
@@ -161,25 +152,13 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 	for (i = 0; i < max_cpus; i++)
 		set_cpu_present(i, true);
 
+	scu_enable(scu_base_addr());
+
 	/*
-	 * Initialise the SCU if there are more than one CPU and let
-	 * them know where to start.
+	 * Write the address of secondary startup into the
+	 * system-wide flags register. The boot monitor waits
+	 * until it receives a soft interrupt, and then the
+	 * secondary CPU branches to this address.
 	 */
-	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_addr());
-
-		/*
-		 * Write the address of secondary startup into the
-		 * system-wide flags register. The boot monitor waits
-		 * until it receives a soft interrupt, and then the
-		 * secondary CPU branches to this address.
-		 */
 	__raw_writel(BSYM(virt_to_phys(s5pv310_secondary_startup)), S5P_VA_SYSRAM);
-	}
 }
diff --git a/arch/arm/mach-tegra/platsmp.c b/arch/arm/mach-tegra/platsmp.c
index 66d0634..b66a0c2 100644
--- a/arch/arm/mach-tegra/platsmp.c
+++ b/arch/arm/mach-tegra/platsmp.c
@@ -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>
@@ -127,20 +126,10 @@ void __init smp_init_cpus(void)
 		cpu_set(i, cpu_possible_map);
 }
 
-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.
@@ -148,8 +137,5 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 	for (i = 0; i < max_cpus; i++)
 		set_cpu_present(i, true);
 
-	if (max_cpus > 1) {
-		percpu_timer_setup();
-		scu_enable(scu_base);
-	}
+	scu_enable(scu_base);
 }
diff --git a/arch/arm/mach-ux500/platsmp.c b/arch/arm/mach-ux500/platsmp.c
index fd40fa1..458a288 100644
--- a/arch/arm/mach-ux500/platsmp.c
+++ b/arch/arm/mach-ux500/platsmp.c
@@ -18,7 +18,6 @@
 #include <linux/io.h>
 
 #include <asm/cacheflush.h>
-#include <asm/localtimer.h>
 #include <asm/smp_scu.h>
 #include <mach/hardware.h>
 
@@ -138,20 +137,10 @@ void __init smp_init_cpus(void)
 		set_cpu_possible(i, true);
 }
 
-void __init smp_prepare_cpus(unsigned int max_cpus)
+void __init platform_smp_prepare_cpus(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.
@@ -159,13 +148,6 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 	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();
-		scu_enable(__io_address(UX500_SCU_BASE));
-		wakeup_secondary();
-	}
+	scu_enable(__io_address(UX500_SCU_BASE));
+	wakeup_secondary();
 }
diff --git a/arch/arm/mach-vexpress/platsmp.c b/arch/arm/mach-vexpress/platsmp.c
index b5a7586..a0341d1 100644
--- a/arch/arm/mach-vexpress/platsmp.c
+++ b/arch/arm/mach-vexpress/platsmp.c
@@ -17,7 +17,6 @@
 #include <linux/io.h>
 
 #include <asm/cacheflush.h>
-#include <asm/localtimer.h>
 #include <asm/smp_scu.h>
 #include <asm/unified.h>
 
@@ -136,20 +135,10 @@ void __init smp_init_cpus(void)
 		set_cpu_possible(i, true);
 }
 
-void __init smp_prepare_cpus(unsigned int max_cpus)
+void __init platform_smp_prepare_cpus(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.
@@ -157,27 +146,15 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 	for (i = 0; i < max_cpus; i++)
 		set_cpu_present(i, true);
 
+	scu_enable(scu_base_addr());
+
 	/*
-	 * Initialise the SCU if there are more than one CPU and let
-	 * them know where to start.
+	 * Write the address of secondary startup into the
+	 * system-wide flags register. The boot monitor waits
+	 * until it receives a soft interrupt, and then the
+	 * secondary CPU branches to this address.
 	 */
-	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_addr());
-
-		/*
-		 * Write the address of secondary startup into the
-		 * system-wide flags register. The boot monitor waits
-		 * until it receives a soft interrupt, and then the
-		 * secondary CPU branches to this address.
-		 */
-		writel(~0, MMIO_P2V(V2M_SYS_FLAGSCLR));
-		writel(BSYM(virt_to_phys(vexpress_secondary_startup)),
-			MMIO_P2V(V2M_SYS_FLAGSSET));
-	}
+	writel(~0, MMIO_P2V(V2M_SYS_FLAGSCLR));
+	writel(BSYM(virt_to_phys(vexpress_secondary_startup)),
+		MMIO_P2V(V2M_SYS_FLAGSSET));
 }
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 18/22] ARM: SMP: consolidate trace_hardirqs_off() into common SMP code
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (16 preceding siblings ...)
  2010-12-03 20:24 ` [PATCH 17/22] ARM: SMP: consolidate the common parts of smp_prepare_cpus() Russell King - ARM Linux
@ 2010-12-03 20:25 ` Russell King - ARM Linux
  2010-12-03 20:25 ` [PATCH 19/22] ARM: CPU hotplug: move cpu_killed completion to core code Russell King - ARM Linux
                   ` (5 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:25 UTC (permalink / raw)
  To: linux-arm-kernel

All platforms call trace_hardirqs_off() in their secondary startup code,
so move this into the core SMP code - it doesn't need to be in the
per-platform code.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/kernel/smp.c            |    1 +
 arch/arm/mach-omap2/omap-smp.c   |    2 --
 arch/arm/mach-realview/platsmp.c |    2 --
 arch/arm/mach-s5pv310/platsmp.c  |    2 --
 arch/arm/mach-tegra/platsmp.c    |    2 --
 arch/arm/mach-ux500/platsmp.c    |    2 --
 arch/arm/mach-vexpress/platsmp.c |    2 --
 7 files changed, 1 insertions(+), 12 deletions(-)

diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index d50e612..1f1de2b 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -317,6 +317,7 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
 
 	cpu_init();
 	preempt_disable();
+	trace_hardirqs_off();
 
 	/*
 	 * Give the platform a chance to do its own initialisation.
diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
index 3c3d679..9fed631 100644
--- a/arch/arm/mach-omap2/omap-smp.c
+++ b/arch/arm/mach-omap2/omap-smp.c
@@ -32,8 +32,6 @@ static DEFINE_SPINLOCK(boot_lock);
 
 void __cpuinit platform_secondary_init(unsigned int cpu)
 {
-	trace_hardirqs_off();
-
 	/*
 	 * If any interrupts are already enabled for the primary
 	 * core (e.g. timer irq), then they will not have been enabled
diff --git a/arch/arm/mach-realview/platsmp.c b/arch/arm/mach-realview/platsmp.c
index 380562c..226c631 100644
--- a/arch/arm/mach-realview/platsmp.c
+++ b/arch/arm/mach-realview/platsmp.c
@@ -53,8 +53,6 @@ static DEFINE_SPINLOCK(boot_lock);
 
 void __cpuinit platform_secondary_init(unsigned int cpu)
 {
-	trace_hardirqs_off();
-
 	/*
 	 * if any interrupts are already enabled for the primary
 	 * core (e.g. timer irq), then they will not have been enabled
diff --git a/arch/arm/mach-s5pv310/platsmp.c b/arch/arm/mach-s5pv310/platsmp.c
index 51c44d4..18aaf5f 100644
--- a/arch/arm/mach-s5pv310/platsmp.c
+++ b/arch/arm/mach-s5pv310/platsmp.c
@@ -46,8 +46,6 @@ static DEFINE_SPINLOCK(boot_lock);
 
 void __cpuinit platform_secondary_init(unsigned int cpu)
 {
-	trace_hardirqs_off();
-
 	/*
 	 * if any interrupts are already enabled for the primary
 	 * core (e.g. timer irq), then they will not have been enabled
diff --git a/arch/arm/mach-tegra/platsmp.c b/arch/arm/mach-tegra/platsmp.c
index b66a0c2..c729cd7 100644
--- a/arch/arm/mach-tegra/platsmp.c
+++ b/arch/arm/mach-tegra/platsmp.c
@@ -40,8 +40,6 @@ static void __iomem *scu_base = IO_ADDRESS(TEGRA_ARM_PERIF_BASE);
 
 void __cpuinit platform_secondary_init(unsigned int cpu)
 {
-	trace_hardirqs_off();
-
 	/*
 	 * if any interrupts are already enabled for the primary
 	 * core (e.g. timer irq), then they will not have been enabled
diff --git a/arch/arm/mach-ux500/platsmp.c b/arch/arm/mach-ux500/platsmp.c
index 458a288..ddedbc8 100644
--- a/arch/arm/mach-ux500/platsmp.c
+++ b/arch/arm/mach-ux500/platsmp.c
@@ -31,8 +31,6 @@ static DEFINE_SPINLOCK(boot_lock);
 
 void __cpuinit platform_secondary_init(unsigned int cpu)
 {
-	trace_hardirqs_off();
-
 	/*
 	 * if any interrupts are already enabled for the primary
 	 * core (e.g. timer irq), then they will not have been enabled
diff --git a/arch/arm/mach-vexpress/platsmp.c b/arch/arm/mach-vexpress/platsmp.c
index a0341d1..d7e0cb9 100644
--- a/arch/arm/mach-vexpress/platsmp.c
+++ b/arch/arm/mach-vexpress/platsmp.c
@@ -43,8 +43,6 @@ static DEFINE_SPINLOCK(boot_lock);
 
 void __cpuinit platform_secondary_init(unsigned int cpu)
 {
-	trace_hardirqs_off();
-
 	/*
 	 * if any interrupts are already enabled for the primary
 	 * core (e.g. timer irq), then they will not have been enabled
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 19/22] ARM: CPU hotplug: move cpu_killed completion to core code
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (17 preceding siblings ...)
  2010-12-03 20:25 ` [PATCH 18/22] ARM: SMP: consolidate trace_hardirqs_off() into common SMP code Russell King - ARM Linux
@ 2010-12-03 20:25 ` Russell King - ARM Linux
  2010-12-03 20:25 ` [PATCH 20/22] ARM: CPU hotplug: remove bug checks in platform_cpu_die() Russell King - ARM Linux
                   ` (4 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:25 UTC (permalink / raw)
  To: linux-arm-kernel

We always need to wait for the dying CPU to reach a safe state before
taking it down, irrespective of the requirements of the platform.
Move the completion code into the ARM SMP hotplug code rather than
having each platform re-implement this.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/kernel/smp.c              |   14 +++++++++++++-
 arch/arm/mach-omap2/omap-hotplug.c |    8 ++------
 arch/arm/mach-realview/hotplug.c   |    8 +-------
 arch/arm/mach-s5pv310/hotplug.c    |    8 +-------
 arch/arm/mach-tegra/hotplug.c      |    8 +-------
 arch/arm/mach-ux500/hotplug.c      |    8 +-------
 6 files changed, 19 insertions(+), 35 deletions(-)

diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 1f1de2b..bebe3bd 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -24,6 +24,7 @@
 #include <linux/irq.h>
 #include <linux/percpu.h>
 #include <linux/clockchips.h>
+#include <linux/completion.h>
 
 #include <asm/atomic.h>
 #include <asm/cacheflush.h>
@@ -238,12 +239,20 @@ int __cpu_disable(void)
 	return 0;
 }
 
+static DECLARE_COMPLETION(cpu_died);
+
 /*
  * called on the thread which is asking for a CPU to be shutdown -
  * waits until shutdown has completed, or it is timed out.
  */
 void __cpu_die(unsigned int cpu)
 {
+	if (wait_for_completion_timeout(&cpu_died, 5000)) {
+		printk(KERN_ERR "CPU%u: cpu didn't die\n", cpu);
+		return;
+	}
+	printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
+
 	if (!platform_cpu_kill(cpu))
 		printk("CPU%u: unable to kill\n", cpu);
 }
@@ -263,9 +272,12 @@ void __ref cpu_die(void)
 	local_irq_disable();
 	idle_task_exit();
 
+	/* Tell __cpu_die() that this CPU is now safe to dispose of */
+	complete(&cpu_died);
+
 	/*
 	 * actual CPU shutdown procedure is at least platform (if not
-	 * CPU) specific
+	 * CPU) specific.
 	 */
 	platform_cpu_die(cpu);
 
diff --git a/arch/arm/mach-omap2/omap-hotplug.c b/arch/arm/mach-omap2/omap-hotplug.c
index 6cee456..ace979d 100644
--- a/arch/arm/mach-omap2/omap-hotplug.c
+++ b/arch/arm/mach-omap2/omap-hotplug.c
@@ -17,16 +17,13 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/smp.h>
-#include <linux/completion.h>
 
 #include <asm/cacheflush.h>
 #include <mach/omap4-common.h>
 
-static DECLARE_COMPLETION(cpu_killed);
-
 int platform_cpu_kill(unsigned int cpu)
 {
-	return wait_for_completion_timeout(&cpu_killed, 5000);
+	return 1;
 }
 
 /*
@@ -42,8 +39,7 @@ void platform_cpu_die(unsigned int cpu)
 			   this_cpu, cpu);
 		BUG();
 	}
-	pr_notice("CPU%u: shutdown\n", cpu);
-	complete(&cpu_killed);
+
 	flush_cache_all();
 	dsb();
 
diff --git a/arch/arm/mach-realview/hotplug.c b/arch/arm/mach-realview/hotplug.c
index f95521a..7d58c16 100644
--- a/arch/arm/mach-realview/hotplug.c
+++ b/arch/arm/mach-realview/hotplug.c
@@ -11,14 +11,11 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/smp.h>
-#include <linux/completion.h>
 
 #include <asm/cacheflush.h>
 
 extern volatile int pen_release;
 
-static DECLARE_COMPLETION(cpu_killed);
-
 static inline void cpu_enter_lowpower(void)
 {
 	unsigned int v;
@@ -95,7 +92,7 @@ static inline void platform_do_lowpower(unsigned int cpu)
 
 int platform_cpu_kill(unsigned int cpu)
 {
-	return wait_for_completion_timeout(&cpu_killed, 5000);
+	return 1;
 }
 
 /*
@@ -115,9 +112,6 @@ void platform_cpu_die(unsigned int cpu)
 	}
 #endif
 
-	printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
-	complete(&cpu_killed);
-
 	/*
 	 * we're ready for shutdown now, so do it
 	 */
diff --git a/arch/arm/mach-s5pv310/hotplug.c b/arch/arm/mach-s5pv310/hotplug.c
index 03652c3..d7be70a 100644
--- a/arch/arm/mach-s5pv310/hotplug.c
+++ b/arch/arm/mach-s5pv310/hotplug.c
@@ -13,14 +13,11 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/smp.h>
-#include <linux/completion.h>
 
 #include <asm/cacheflush.h>
 
 extern volatile int pen_release;
 
-static DECLARE_COMPLETION(cpu_killed);
-
 static inline void cpu_enter_lowpower(void)
 {
 	unsigned int v;
@@ -98,7 +95,7 @@ static inline void platform_do_lowpower(unsigned int cpu)
 
 int platform_cpu_kill(unsigned int cpu)
 {
-	return wait_for_completion_timeout(&cpu_killed, 5000);
+	return 1;
 }
 
 /*
@@ -118,9 +115,6 @@ void platform_cpu_die(unsigned int cpu)
 	}
 #endif
 
-	printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
-	complete(&cpu_killed);
-
 	/*
 	 * we're ready for shutdown now, so do it
 	 */
diff --git a/arch/arm/mach-tegra/hotplug.c b/arch/arm/mach-tegra/hotplug.c
index 8e7f115..ecaa41c 100644
--- a/arch/arm/mach-tegra/hotplug.c
+++ b/arch/arm/mach-tegra/hotplug.c
@@ -11,12 +11,9 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/smp.h>
-#include <linux/completion.h>
 
 #include <asm/cacheflush.h>
 
-static DECLARE_COMPLETION(cpu_killed);
-
 static inline void cpu_enter_lowpower(void)
 {
 	unsigned int v;
@@ -94,7 +91,7 @@ static inline void platform_do_lowpower(unsigned int cpu)
 
 int platform_cpu_kill(unsigned int cpu)
 {
-	return wait_for_completion_timeout(&cpu_killed, 5000);
+	return 1;
 }
 
 /*
@@ -114,9 +111,6 @@ void platform_cpu_die(unsigned int cpu)
 	}
 #endif
 
-	printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
-	complete(&cpu_killed);
-
 	/*
 	 * we're ready for shutdown now, so do it
 	 */
diff --git a/arch/arm/mach-ux500/hotplug.c b/arch/arm/mach-ux500/hotplug.c
index b782a03..7a4890b 100644
--- a/arch/arm/mach-ux500/hotplug.c
+++ b/arch/arm/mach-ux500/hotplug.c
@@ -11,14 +11,11 @@
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/smp.h>
-#include <linux/completion.h>
 
 #include <asm/cacheflush.h>
 
 extern volatile int pen_release;
 
-static DECLARE_COMPLETION(cpu_killed);
-
 static inline void platform_do_lowpower(unsigned int cpu)
 {
 	flush_cache_all();
@@ -38,7 +35,7 @@ static inline void platform_do_lowpower(unsigned int cpu)
 
 int platform_cpu_kill(unsigned int cpu)
 {
-	return wait_for_completion_timeout(&cpu_killed, 5000);
+	return 1;
 }
 
 /*
@@ -58,9 +55,6 @@ void platform_cpu_die(unsigned int cpu)
 	}
 #endif
 
-	printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
-	complete(&cpu_killed);
-
 	/* directly enter low power state, skipping secure registers */
 	platform_do_lowpower(cpu);
 }
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 20/22] ARM: CPU hotplug: remove bug checks in platform_cpu_die()
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (18 preceding siblings ...)
  2010-12-03 20:25 ` [PATCH 19/22] ARM: CPU hotplug: move cpu_killed completion to core code Russell King - ARM Linux
@ 2010-12-03 20:25 ` Russell King - ARM Linux
  2010-12-03 20:26 ` [PATCH 21/22] ARM: CPU hotplug: ensure correct ordering of unplug Russell King - ARM Linux
                   ` (3 subsequent siblings)
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:25 UTC (permalink / raw)
  To: linux-arm-kernel

platform_cpu_die() is entered from the CPU's own idle thread, which
can not be migrated to other CPUs.  Moreover, the 'cpu' argument
comes from the thread info, which will always be the 'current'
CPU.  So remove this useless bug check.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/mach-omap2/omap-hotplug.c |    8 --------
 arch/arm/mach-realview/hotplug.c   |   10 ----------
 arch/arm/mach-s5pv310/hotplug.c    |   10 ----------
 arch/arm/mach-tegra/hotplug.c      |   10 ----------
 arch/arm/mach-ux500/hotplug.c      |   10 ----------
 5 files changed, 0 insertions(+), 48 deletions(-)

diff --git a/arch/arm/mach-omap2/omap-hotplug.c b/arch/arm/mach-omap2/omap-hotplug.c
index ace979d..4976b93 100644
--- a/arch/arm/mach-omap2/omap-hotplug.c
+++ b/arch/arm/mach-omap2/omap-hotplug.c
@@ -32,14 +32,6 @@ int platform_cpu_kill(unsigned int cpu)
  */
 void platform_cpu_die(unsigned int cpu)
 {
-	unsigned int this_cpu = hard_smp_processor_id();
-
-	if (cpu != this_cpu) {
-		pr_crit("platform_cpu_die running on %u, should be %u\n",
-			   this_cpu, cpu);
-		BUG();
-	}
-
 	flush_cache_all();
 	dsb();
 
diff --git a/arch/arm/mach-realview/hotplug.c b/arch/arm/mach-realview/hotplug.c
index 7d58c16..e06572e 100644
--- a/arch/arm/mach-realview/hotplug.c
+++ b/arch/arm/mach-realview/hotplug.c
@@ -102,16 +102,6 @@ int platform_cpu_kill(unsigned int cpu)
  */
 void platform_cpu_die(unsigned int cpu)
 {
-#ifdef DEBUG
-	unsigned int this_cpu = hard_smp_processor_id();
-
-	if (cpu != this_cpu) {
-		printk(KERN_CRIT "Eek! platform_cpu_die running on %u, should be %u\n",
-			   this_cpu, cpu);
-		BUG();
-	}
-#endif
-
 	/*
 	 * we're ready for shutdown now, so do it
 	 */
diff --git a/arch/arm/mach-s5pv310/hotplug.c b/arch/arm/mach-s5pv310/hotplug.c
index d7be70a..ea951ef 100644
--- a/arch/arm/mach-s5pv310/hotplug.c
+++ b/arch/arm/mach-s5pv310/hotplug.c
@@ -105,16 +105,6 @@ int platform_cpu_kill(unsigned int cpu)
  */
 void platform_cpu_die(unsigned int cpu)
 {
-#ifdef DEBUG
-	unsigned int this_cpu = hard_smp_processor_id();
-
-	if (cpu != this_cpu) {
-		printk(KERN_CRIT "Eek! platform_cpu_die running on %u, should be %u\n",
-			   this_cpu, cpu);
-		BUG();
-	}
-#endif
-
 	/*
 	 * we're ready for shutdown now, so do it
 	 */
diff --git a/arch/arm/mach-tegra/hotplug.c b/arch/arm/mach-tegra/hotplug.c
index ecaa41c..a5eeb91 100644
--- a/arch/arm/mach-tegra/hotplug.c
+++ b/arch/arm/mach-tegra/hotplug.c
@@ -101,16 +101,6 @@ int platform_cpu_kill(unsigned int cpu)
  */
 void platform_cpu_die(unsigned int cpu)
 {
-#ifdef DEBUG
-	unsigned int this_cpu = hard_smp_processor_id();
-
-	if (cpu != this_cpu) {
-		printk(KERN_CRIT "Eek! platform_cpu_die running on %u, should be %u\n",
-			   this_cpu, cpu);
-		BUG();
-	}
-#endif
-
 	/*
 	 * we're ready for shutdown now, so do it
 	 */
diff --git a/arch/arm/mach-ux500/hotplug.c b/arch/arm/mach-ux500/hotplug.c
index 7a4890b..dd8037e 100644
--- a/arch/arm/mach-ux500/hotplug.c
+++ b/arch/arm/mach-ux500/hotplug.c
@@ -45,16 +45,6 @@ int platform_cpu_kill(unsigned int cpu)
  */
 void platform_cpu_die(unsigned int cpu)
 {
-#ifdef DEBUG
-	unsigned int this_cpu = hard_smp_processor_id();
-
-	if (cpu != this_cpu) {
-		printk(KERN_CRIT "Eek! platform_cpu_die running on %u, should be %u\n",
-			   this_cpu, cpu);
-		BUG();
-	}
-#endif
-
 	/* directly enter low power state, skipping secure registers */
 	platform_do_lowpower(cpu);
 }
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 21/22] ARM: CPU hotplug: ensure correct ordering of unplug
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (19 preceding siblings ...)
  2010-12-03 20:25 ` [PATCH 20/22] ARM: CPU hotplug: remove bug checks in platform_cpu_die() Russell King - ARM Linux
@ 2010-12-03 20:26 ` Russell King - ARM Linux
  2010-12-06 18:13   ` Catalin Marinas
  2010-12-03 20:26 ` [PATCH 22/22] ARM: SMP: remove smp_mpidr.h Russell King - ARM Linux
                   ` (2 subsequent siblings)
  23 siblings, 1 reply; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:26 UTC (permalink / raw)
  To: linux-arm-kernel

Don't call idle_task_exit() with interrupts disabled, and ensure
that we have a memory barrier after interrupts are disabled but
before signalling that this CPU has shut down.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/kernel/smp.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index bebe3bd..8cc9c03 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -269,9 +269,11 @@ void __ref cpu_die(void)
 {
 	unsigned int cpu = smp_processor_id();
 
-	local_irq_disable();
 	idle_task_exit();
 
+	local_irq_disable();
+	mb();
+
 	/* Tell __cpu_die() that this CPU is now safe to dispose of */
 	complete(&cpu_died);
 
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 22/22] ARM: SMP: remove smp_mpidr.h
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (20 preceding siblings ...)
  2010-12-03 20:26 ` [PATCH 21/22] ARM: CPU hotplug: ensure correct ordering of unplug Russell King - ARM Linux
@ 2010-12-03 20:26 ` Russell King - ARM Linux
  2010-12-06  9:32   ` Santosh Shilimkar
  2010-12-03 20:37 ` [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
  2010-12-03 21:54 ` Daniel Walker
  23 siblings, 1 reply; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:26 UTC (permalink / raw)
  To: linux-arm-kernel

With "ARM: CPU hotplug: remove bug checks in platform_cpu_die()", we
now do not use hard_smp_processor_id(), we no longer need to read the
hardware processor ID.  Remove the include providing this function.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/include/asm/smp_mpidr.h          |   17 -----------------
 arch/arm/mach-realview/include/mach/smp.h |    1 -
 arch/arm/mach-s5pv310/include/mach/smp.h  |    1 -
 arch/arm/mach-tegra/include/mach/smp.h    |    1 -
 arch/arm/mach-ux500/include/mach/smp.h    |    1 -
 arch/arm/mach-vexpress/include/mach/smp.h |    1 -
 arch/arm/plat-omap/include/plat/smp.h     |    1 -
 7 files changed, 0 insertions(+), 23 deletions(-)
 delete mode 100644 arch/arm/include/asm/smp_mpidr.h

diff --git a/arch/arm/include/asm/smp_mpidr.h b/arch/arm/include/asm/smp_mpidr.h
deleted file mode 100644
index 6a9307d..0000000
--- a/arch/arm/include/asm/smp_mpidr.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef ASMARM_SMP_MIDR_H
-#define ASMARM_SMP_MIDR_H
-
-#define hard_smp_processor_id()						\
-	({								\
-		unsigned int cpunum;					\
-		__asm__("\n"						\
-			"1:	mrc p15, 0, %0, c0, c0, 5\n"		\
-			"	.pushsection \".alt.smp.init\", \"a\"\n"\
-			"	.long	1b\n"				\
-			"	mov	%0, #0\n"			\
-			"	.popsection"				\
-			: "=r" (cpunum));				\
-		cpunum &= 0x0F;						\
-	})
-
-#endif
diff --git a/arch/arm/mach-realview/include/mach/smp.h b/arch/arm/mach-realview/include/mach/smp.h
index d1aa704..c8221b3 100644
--- a/arch/arm/mach-realview/include/mach/smp.h
+++ b/arch/arm/mach-realview/include/mach/smp.h
@@ -2,7 +2,6 @@
 #define ASMARM_ARCH_SMP_H
 
 #include <asm/hardware/gic.h>
-#include <asm/smp_mpidr.h>
 
 /*
  * We use IRQ1 as the IPI
diff --git a/arch/arm/mach-s5pv310/include/mach/smp.h b/arch/arm/mach-s5pv310/include/mach/smp.h
index 2897747..77e5a84 100644
--- a/arch/arm/mach-s5pv310/include/mach/smp.h
+++ b/arch/arm/mach-s5pv310/include/mach/smp.h
@@ -7,7 +7,6 @@
 #define ASM_ARCH_SMP_H __FILE__
 
 #include <asm/hardware/gic.h>
-#include <asm/smp_mpidr.h>
 
 extern void __iomem *gic_cpu_base_addr;
 
diff --git a/arch/arm/mach-tegra/include/mach/smp.h b/arch/arm/mach-tegra/include/mach/smp.h
index d1aa704..c8221b3 100644
--- a/arch/arm/mach-tegra/include/mach/smp.h
+++ b/arch/arm/mach-tegra/include/mach/smp.h
@@ -2,7 +2,6 @@
 #define ASMARM_ARCH_SMP_H
 
 #include <asm/hardware/gic.h>
-#include <asm/smp_mpidr.h>
 
 /*
  * We use IRQ1 as the IPI
diff --git a/arch/arm/mach-ux500/include/mach/smp.h b/arch/arm/mach-ux500/include/mach/smp.h
index bd57c50..ca2b15b 100644
--- a/arch/arm/mach-ux500/include/mach/smp.h
+++ b/arch/arm/mach-ux500/include/mach/smp.h
@@ -10,7 +10,6 @@
 #define ASMARM_ARCH_SMP_H
 
 #include <asm/hardware/gic.h>
-#include <asm/smp_mpidr.h>
 
 /* This is required to wakeup the secondary core */
 extern void u8500_secondary_startup(void);
diff --git a/arch/arm/mach-vexpress/include/mach/smp.h b/arch/arm/mach-vexpress/include/mach/smp.h
index 721be0f..4c05e4a 100644
--- a/arch/arm/mach-vexpress/include/mach/smp.h
+++ b/arch/arm/mach-vexpress/include/mach/smp.h
@@ -2,7 +2,6 @@
 #define __MACH_SMP_H
 
 #include <asm/hardware/gic.h>
-#include <asm/smp_mpidr.h>
 
 /*
  * We use IRQ1 as the IPI
diff --git a/arch/arm/plat-omap/include/plat/smp.h b/arch/arm/plat-omap/include/plat/smp.h
index e5541e5..7a10257 100644
--- a/arch/arm/plat-omap/include/plat/smp.h
+++ b/arch/arm/plat-omap/include/plat/smp.h
@@ -18,7 +18,6 @@
 #define OMAP_ARCH_SMP_H
 
 #include <asm/hardware/gic.h>
-#include <asm/smp_mpidr.h>
 
 /* Needed for secondary core boot */
 extern void omap_secondary_startup(void);
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 0/22] More SMP cleanup
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (21 preceding siblings ...)
  2010-12-03 20:26 ` [PATCH 22/22] ARM: SMP: remove smp_mpidr.h Russell King - ARM Linux
@ 2010-12-03 20:37 ` Russell King - ARM Linux
  2010-12-03 21:54 ` Daniel Walker
  23 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 20:37 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Dec 03, 2010 at 08:07:46PM +0000, Russell King - ARM Linux wrote:
> This patch series incorporates patches from the previously posted
> "Clean up SMP IPI support" series of 9 patches.  Patch 5, and
> 11 onwards are new.

Sorry, patch 4 is the new one, not patch 5.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 0/22] More SMP cleanup
  2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
                   ` (22 preceding siblings ...)
  2010-12-03 20:37 ` [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
@ 2010-12-03 21:54 ` Daniel Walker
  2010-12-03 22:02   ` Russell King - ARM Linux
  23 siblings, 1 reply; 32+ messages in thread
From: Daniel Walker @ 2010-12-03 21:54 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 2010-12-03 at 20:07 +0000, Russell King - ARM Linux wrote:
> This patch series incorporates patches from the previously posted
> "Clean up SMP IPI support" series of 9 patches.  Patch 5, and
> 11 onwards are new.
> 
> This aims to reduce the amount of code in platform specific files
> to the barest minimum, while maintaining the flexibility of the
> API to allow platforms to decide which CPU numbers are populated.

Are you going to queue this for 2.6.38 or a later merge window?

Daniel
-- 
Sent by an consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
Forum.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 0/22] More SMP cleanup
  2010-12-03 21:54 ` Daniel Walker
@ 2010-12-03 22:02   ` Russell King - ARM Linux
  0 siblings, 0 replies; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-03 22:02 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Dec 03, 2010 at 01:54:44PM -0800, Daniel Walker wrote:
> On Fri, 2010-12-03 at 20:07 +0000, Russell King - ARM Linux wrote:
> > This patch series incorporates patches from the previously posted
> > "Clean up SMP IPI support" series of 9 patches.  Patch 5, and
> > 11 onwards are new.
> > 
> > This aims to reduce the amount of code in platform specific files
> > to the barest minimum, while maintaining the flexibility of the
> > API to allow platforms to decide which CPU numbers are populated.
> 
> Are you going to queue this for 2.6.38 or a later merge window?

The next merge window.  Many of the patches have already been in
linux-next for the odd occasion and not revealed any clashes.

Many of these patches are the result of larger patches I've posted
on these lists over the last week or so, broken up into smaller
chunks, massaged a bit more, and with other parts of the large
patches dropped.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 22/22] ARM: SMP: remove smp_mpidr.h
  2010-12-03 20:26 ` [PATCH 22/22] ARM: SMP: remove smp_mpidr.h Russell King - ARM Linux
@ 2010-12-06  9:32   ` Santosh Shilimkar
  2010-12-06 10:32     ` Russell King - ARM Linux
  0 siblings, 1 reply; 32+ messages in thread
From: Santosh Shilimkar @ 2010-12-06  9:32 UTC (permalink / raw)
  To: linux-arm-kernel

Russell,
> -----Original Message-----
> From: linux-arm-kernel-bounces at lists.infradead.org [mailto:linux-arm-
> kernel-bounces at lists.infradead.org] On Behalf Of Russell King - ARM
Linux
> Sent: Saturday, December 04, 2010 1:56 AM
> To: linux-arm-kernel at lists.infradead.org; Catalin Marinas
> Subject: [PATCH 22/22] ARM: SMP: remove smp_mpidr.h
>
> With "ARM: CPU hotplug: remove bug checks in platform_cpu_die()", we
> now do not use hard_smp_processor_id(), we no longer need to read the
> hardware processor ID.  Remove the include providing this function.
>
hard_smp_processor_id() is also useful when wakeup from low power
modes and wants to run specific restore code on specific
CPUs. Ofcourse platform have it's own custome macro, but having
ARM generic is better.

> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> ---
>  arch/arm/include/asm/smp_mpidr.h          |   17 -----------------
>  arch/arm/mach-realview/include/mach/smp.h |    1 -
>  arch/arm/mach-s5pv310/include/mach/smp.h  |    1 -
>  arch/arm/mach-tegra/include/mach/smp.h    |    1 -
>  arch/arm/mach-ux500/include/mach/smp.h    |    1 -
>  arch/arm/mach-vexpress/include/mach/smp.h |    1 -
>  arch/arm/plat-omap/include/plat/smp.h     |    1 -
>  7 files changed, 0 insertions(+), 23 deletions(-)
>  delete mode 100644 arch/arm/include/asm/smp_mpidr.h
>
> diff --git a/arch/arm/include/asm/smp_mpidr.h
> b/arch/arm/include/asm/smp_mpidr.h
> deleted file mode 100644
> index 6a9307d..0000000
> --- a/arch/arm/include/asm/smp_mpidr.h
> +++ /dev/null
> @@ -1,17 +0,0 @@
> -#ifndef ASMARM_SMP_MIDR_H
> -#define ASMARM_SMP_MIDR_H
> -
> -#define hard_smp_processor_id()
\
> -	({								\
> -		unsigned int cpunum;					\
> -		__asm__("\n"						\
> -			"1:	mrc p15, 0, %0, c0, c0, 5\n"		\
> -			"	.pushsection \".alt.smp.init\", \"a\"\n"\
> -			"	.long	1b\n"				\
> -			"	mov	%0, #0\n"			\
> -			"	.popsection"				\
> -			: "=r" (cpunum));				\
> -		cpunum &= 0x0F;						\
> -	})
> -
> -#endif
> diff --git a/arch/arm/mach-realview/include/mach/smp.h b/arch/arm/mach-
> realview/include/mach/smp.h
> index d1aa704..c8221b3 100644
> --- a/arch/arm/mach-realview/include/mach/smp.h
> +++ b/arch/arm/mach-realview/include/mach/smp.h
> @@ -2,7 +2,6 @@
>  #define ASMARM_ARCH_SMP_H
>
>  #include <asm/hardware/gic.h>
> -#include <asm/smp_mpidr.h>
>
>  /*
>   * We use IRQ1 as the IPI
> diff --git a/arch/arm/mach-s5pv310/include/mach/smp.h b/arch/arm/mach-
> s5pv310/include/mach/smp.h
> index 2897747..77e5a84 100644
> --- a/arch/arm/mach-s5pv310/include/mach/smp.h
> +++ b/arch/arm/mach-s5pv310/include/mach/smp.h
> @@ -7,7 +7,6 @@
>  #define ASM_ARCH_SMP_H __FILE__
>
>  #include <asm/hardware/gic.h>
> -#include <asm/smp_mpidr.h>
>
>  extern void __iomem *gic_cpu_base_addr;
>
> diff --git a/arch/arm/mach-tegra/include/mach/smp.h b/arch/arm/mach-
> tegra/include/mach/smp.h
> index d1aa704..c8221b3 100644
> --- a/arch/arm/mach-tegra/include/mach/smp.h
> +++ b/arch/arm/mach-tegra/include/mach/smp.h
> @@ -2,7 +2,6 @@
>  #define ASMARM_ARCH_SMP_H
>
>  #include <asm/hardware/gic.h>
> -#include <asm/smp_mpidr.h>
>
>  /*
>   * We use IRQ1 as the IPI
> diff --git a/arch/arm/mach-ux500/include/mach/smp.h b/arch/arm/mach-
> ux500/include/mach/smp.h
> index bd57c50..ca2b15b 100644
> --- a/arch/arm/mach-ux500/include/mach/smp.h
> +++ b/arch/arm/mach-ux500/include/mach/smp.h
> @@ -10,7 +10,6 @@
>  #define ASMARM_ARCH_SMP_H
>
>  #include <asm/hardware/gic.h>
> -#include <asm/smp_mpidr.h>
>
>  /* This is required to wakeup the secondary core */
>  extern void u8500_secondary_startup(void);
> diff --git a/arch/arm/mach-vexpress/include/mach/smp.h b/arch/arm/mach-
> vexpress/include/mach/smp.h
> index 721be0f..4c05e4a 100644
> --- a/arch/arm/mach-vexpress/include/mach/smp.h
> +++ b/arch/arm/mach-vexpress/include/mach/smp.h
> @@ -2,7 +2,6 @@
>  #define __MACH_SMP_H
>
>  #include <asm/hardware/gic.h>
> -#include <asm/smp_mpidr.h>
>
>  /*
>   * We use IRQ1 as the IPI
> diff --git a/arch/arm/plat-omap/include/plat/smp.h b/arch/arm/plat-
> omap/include/plat/smp.h
> index e5541e5..7a10257 100644
> --- a/arch/arm/plat-omap/include/plat/smp.h
> +++ b/arch/arm/plat-omap/include/plat/smp.h
> @@ -18,7 +18,6 @@
>  #define OMAP_ARCH_SMP_H
>
>  #include <asm/hardware/gic.h>
> -#include <asm/smp_mpidr.h>
>
>  /* Needed for secondary core boot */
>  extern void omap_secondary_startup(void);
> --
> 1.6.2.5
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 22/22] ARM: SMP: remove smp_mpidr.h
  2010-12-06  9:32   ` Santosh Shilimkar
@ 2010-12-06 10:32     ` Russell King - ARM Linux
  2010-12-06 10:47       ` Santosh Shilimkar
  0 siblings, 1 reply; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-06 10:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Dec 06, 2010 at 03:02:09PM +0530, Santosh Shilimkar wrote:
> Russell,
> > -----Original Message-----
> > From: linux-arm-kernel-bounces at lists.infradead.org [mailto:linux-arm-
> > kernel-bounces at lists.infradead.org] On Behalf Of Russell King - ARM
> Linux
> > Sent: Saturday, December 04, 2010 1:56 AM
> > To: linux-arm-kernel at lists.infradead.org; Catalin Marinas
> > Subject: [PATCH 22/22] ARM: SMP: remove smp_mpidr.h
> >
> > With "ARM: CPU hotplug: remove bug checks in platform_cpu_die()", we
> > now do not use hard_smp_processor_id(), we no longer need to read the
> > hardware processor ID.  Remove the include providing this function.
> >
> hard_smp_processor_id() is also useful when wakeup from low power
> modes and wants to run specific restore code on specific
> CPUs. Ofcourse platform have it's own custome macro, but having
> ARM generic is better.

Maybe, but there's no code in the kernel making use of it.  Also note
that there is a tendency to compare the kernel's CPU numbers (which are
the logical numbers) with hard_smp_processor_id() (the physical number)
which may not always be the same thing.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 22/22] ARM: SMP: remove smp_mpidr.h
  2010-12-06 10:32     ` Russell King - ARM Linux
@ 2010-12-06 10:47       ` Santosh Shilimkar
  0 siblings, 0 replies; 32+ messages in thread
From: Santosh Shilimkar @ 2010-12-06 10:47 UTC (permalink / raw)
  To: linux-arm-kernel

> -----Original Message-----
> From: Russell King - ARM Linux [mailto:linux at arm.linux.org.uk]
> Sent: Monday, December 06, 2010 4:02 PM
> To: Santosh Shilimkar
> Cc: linux-arm-kernel at lists.infradead.org; Catalin Marinas
> Subject: Re: [PATCH 22/22] ARM: SMP: remove smp_mpidr.h
>
> On Mon, Dec 06, 2010 at 03:02:09PM +0530, Santosh Shilimkar wrote:
> > Russell,
> > > -----Original Message-----
> > > From: linux-arm-kernel-bounces at lists.infradead.org
[mailto:linux-arm-
> > > kernel-bounces at lists.infradead.org] On Behalf Of Russell King - ARM
> > Linux
> > > Sent: Saturday, December 04, 2010 1:56 AM
> > > To: linux-arm-kernel at lists.infradead.org; Catalin Marinas
> > > Subject: [PATCH 22/22] ARM: SMP: remove smp_mpidr.h
> > >
> > > With "ARM: CPU hotplug: remove bug checks in platform_cpu_die()", we
> > > now do not use hard_smp_processor_id(), we no longer need to read
the
> > > hardware processor ID.  Remove the include providing this function.
> > >
> > hard_smp_processor_id() is also useful when wakeup from low power
> > modes and wants to run specific restore code on specific
> > CPUs. Ofcourse platform have it's own custome macro, but having
> > ARM generic is better.
>
> Maybe, but there's no code in the kernel making use of it.  Also note
> that there is a tendency to compare the kernel's CPU numbers (which are
> the logical numbers) with hard_smp_processor_id() (the physical number)
> which may not always be the same thing.
Agree. May be we can add it when the need arises.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 21/22] ARM: CPU hotplug: ensure correct ordering of unplug
  2010-12-03 20:26 ` [PATCH 21/22] ARM: CPU hotplug: ensure correct ordering of unplug Russell King - ARM Linux
@ 2010-12-06 18:13   ` Catalin Marinas
  2010-12-06 18:46     ` Russell King - ARM Linux
  0 siblings, 1 reply; 32+ messages in thread
From: Catalin Marinas @ 2010-12-06 18:13 UTC (permalink / raw)
  To: linux-arm-kernel

On 3 December 2010 20:26, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> Don't call idle_task_exit() with interrupts disabled, and ensure
> that we have a memory barrier after interrupts are disabled but
> before signalling that this CPU has shut down.
>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> ---
> ?arch/arm/kernel/smp.c | ? ?4 +++-
> ?1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
> index bebe3bd..8cc9c03 100644
> --- a/arch/arm/kernel/smp.c
> +++ b/arch/arm/kernel/smp.c
> @@ -269,9 +269,11 @@ void __ref cpu_die(void)
> ?{
> ? ? ? ?unsigned int cpu = smp_processor_id();
>
> - ? ? ? local_irq_disable();
> ? ? ? ?idle_task_exit();
>
> + ? ? ? local_irq_disable();
> + ? ? ? mb();
> +
> ? ? ? ?/* Tell __cpu_die() that this CPU is now safe to dispose of */
> ? ? ? ?complete(&cpu_died);

I don't fully understand the point of the mb() here. If you want to
drain the write buffer that would be a dsb().

-- 
Catalin

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 21/22] ARM: CPU hotplug: ensure correct ordering of unplug
  2010-12-06 18:13   ` Catalin Marinas
@ 2010-12-06 18:46     ` Russell King - ARM Linux
  2010-12-06 18:54       ` Catalin Marinas
  0 siblings, 1 reply; 32+ messages in thread
From: Russell King - ARM Linux @ 2010-12-06 18:46 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Dec 06, 2010 at 06:13:37PM +0000, Catalin Marinas wrote:
> On 3 December 2010 20:26, Russell King - ARM Linux
> <linux@arm.linux.org.uk> wrote:
> > Don't call idle_task_exit() with interrupts disabled, and ensure
> > that we have a memory barrier after interrupts are disabled but
> > before signalling that this CPU has shut down.
> >
> > Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> > ---
> > ?arch/arm/kernel/smp.c | ? ?4 +++-
> > ?1 files changed, 3 insertions(+), 1 deletions(-)
> >
> > diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
> > index bebe3bd..8cc9c03 100644
> > --- a/arch/arm/kernel/smp.c
> > +++ b/arch/arm/kernel/smp.c
> > @@ -269,9 +269,11 @@ void __ref cpu_die(void)
> > ?{
> > ? ? ? ?unsigned int cpu = smp_processor_id();
> >
> > - ? ? ? local_irq_disable();
> > ? ? ? ?idle_task_exit();
> >
> > + ? ? ? local_irq_disable();
> > + ? ? ? mb();
> > +
> > ? ? ? ?/* Tell __cpu_die() that this CPU is now safe to dispose of */
> > ? ? ? ?complete(&cpu_died);
> 
> I don't fully understand the point of the mb() here. If you want to
> drain the write buffer that would be a dsb().

It's there to ensure that writes prior to the IRQ disable do not
cross the complete() call, that is all.  local_irq_disable() does
not have any built-in barrier semantics.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 21/22] ARM: CPU hotplug: ensure correct ordering of unplug
  2010-12-06 18:46     ` Russell King - ARM Linux
@ 2010-12-06 18:54       ` Catalin Marinas
  0 siblings, 0 replies; 32+ messages in thread
From: Catalin Marinas @ 2010-12-06 18:54 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 2010-12-06 at 18:46 +0000, Russell King - ARM Linux wrote:
> On Mon, Dec 06, 2010 at 06:13:37PM +0000, Catalin Marinas wrote:
> > On 3 December 2010 20:26, Russell King - ARM Linux
> > <linux@arm.linux.org.uk> wrote:
> > > Don't call idle_task_exit() with interrupts disabled, and ensure
> > > that we have a memory barrier after interrupts are disabled but
> > > before signalling that this CPU has shut down.
> > >
> > > Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> > > ---
> > >  arch/arm/kernel/smp.c |    4 +++-
> > >  1 files changed, 3 insertions(+), 1 deletions(-)
> > >
> > > diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
> > > index bebe3bd..8cc9c03 100644
> > > --- a/arch/arm/kernel/smp.c
> > > +++ b/arch/arm/kernel/smp.c
> > > @@ -269,9 +269,11 @@ void __ref cpu_die(void)
> > >  {
> > >        unsigned int cpu = smp_processor_id();
> > >
> > > -       local_irq_disable();
> > >        idle_task_exit();
> > >
> > > +       local_irq_disable();
> > > +       mb();
> > > +
> > >        /* Tell __cpu_die() that this CPU is now safe to dispose of */
> > >        complete(&cpu_died);
> >
> > I don't fully understand the point of the mb() here. If you want to
> > drain the write buffer that would be a dsb().
> 
> It's there to ensure that writes prior to the IRQ disable do not
> cross the complete() call, that is all.  local_irq_disable() does
> not have any built-in barrier semantics.

The DMB only ensures relative ordering between memory accesses and not
function calls. What other memory access you try to prevent getting
reordered? The complete() function takes a spinlock anyway so it has a
memory barrier.

-- 
Catalin

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2010-12-06 18:54 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-03 20:07 [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
2010-12-03 20:19 ` [PATCH 01/22] ARM: remove obsolete smp_cross_call_done() Russell King - ARM Linux
2010-12-03 20:19 ` [PATCH 02/22] ARM: SMP: pass an ipi number to smp_cross_call() Russell King - ARM Linux
2010-12-03 20:19 ` [PATCH 03/22] ARM: SMP: avoid using bitmasks and locks for IPIs, use hardware instead Russell King - ARM Linux
2010-12-03 20:20 ` [PATCH 04/22] ARM: SMP: remove IRQ-disabling for smp_cross_call() Russell King - ARM Linux
2010-12-03 20:20 ` [PATCH 05/22] ARM: include local timer irq stats only when local timers configured Russell King - ARM Linux
2010-12-03 20:20 ` [PATCH 06/22] ARM: SMP: provide accessors for irq_stat data Russell King - ARM Linux
2010-12-03 20:21 ` [PATCH 07/22] ARM: SMP: move ipi_count into irq_stat structure Russell King - ARM Linux
2010-12-03 20:21 ` [PATCH 08/22] ARM: fix /proc/interrupts formatting Russell King - ARM Linux
2010-12-03 20:21 ` [PATCH 09/22] ARM: SMP: provide individual IPI interrupt statistics Russell King - ARM Linux
2010-12-03 20:22 ` [PATCH 10/22] ARM: SMP: collect IPI and local timer IRQs for /proc/stat Russell King - ARM Linux
2010-12-03 20:22 ` [PATCH 11/22] ARM: SMP: use more sane register allocation for __fixup_smp_on_up Russell King - ARM Linux
2010-12-03 20:23 ` [PATCH 12/22] ARM: SMP: ensure smp_send_stop() waits for CPUs to stop Russell King - ARM Linux
2010-12-03 20:23 ` [PATCH 13/22] ARM: SMP: move CPU number sanity checks to smp_init_cpus() Russell King - ARM Linux
2010-12-03 20:23 ` [PATCH 14/22] ARM: SMP: Clean up ncores sanity checks Russell King - ARM Linux
2010-12-03 20:24 ` [PATCH 15/22] ARM: SMP: get rid of get_core_count() Russell King - ARM Linux
2010-12-03 20:24 ` [PATCH 16/22] ARM: SMP: get rid of references to poke_milo and Milo Russell King - ARM Linux
2010-12-03 20:24 ` [PATCH 17/22] ARM: SMP: consolidate the common parts of smp_prepare_cpus() Russell King - ARM Linux
2010-12-03 20:25 ` [PATCH 18/22] ARM: SMP: consolidate trace_hardirqs_off() into common SMP code Russell King - ARM Linux
2010-12-03 20:25 ` [PATCH 19/22] ARM: CPU hotplug: move cpu_killed completion to core code Russell King - ARM Linux
2010-12-03 20:25 ` [PATCH 20/22] ARM: CPU hotplug: remove bug checks in platform_cpu_die() Russell King - ARM Linux
2010-12-03 20:26 ` [PATCH 21/22] ARM: CPU hotplug: ensure correct ordering of unplug Russell King - ARM Linux
2010-12-06 18:13   ` Catalin Marinas
2010-12-06 18:46     ` Russell King - ARM Linux
2010-12-06 18:54       ` Catalin Marinas
2010-12-03 20:26 ` [PATCH 22/22] ARM: SMP: remove smp_mpidr.h Russell King - ARM Linux
2010-12-06  9:32   ` Santosh Shilimkar
2010-12-06 10:32     ` Russell King - ARM Linux
2010-12-06 10:47       ` Santosh Shilimkar
2010-12-03 20:37 ` [PATCH 0/22] More SMP cleanup Russell King - ARM Linux
2010-12-03 21:54 ` Daniel Walker
2010-12-03 22:02   ` Russell King - ARM Linux

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.