Skip to contentSkip to conversation

ARM: factorise CPU hotplug code

PATCH New Sundar Iyer 3 participants 10 messages Sep 3, 2010 – Sep 13, 2010

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

cover ARM: factorise CPU hotplug code

Inspired by Will Deacon's cleanup for the Realview series, this is an attempt to factor even more common code and move hotplug functions to the generic arch/arm/common folder

Sundar Iyer (2):
ARM: Generalize all CPU Hotplug code across platforms
ux500: Add CPU hotplug support

 arch/arm/common/Makefile           |    1 +
 arch/arm/common/hotplug.c          |   57 ++++++++++++++++++++++++++++++++++++
 arch/arm/include/asm/hotplug.h     |   18 +++++++++++
 arch/arm/mach-omap2/omap-hotplug.c |   24 +--------------
 arch/arm/mach-realview/hotplug.c   |   56 ++++-------------------------------
 arch/arm/mach-s5pv310/hotplug.c    |   56 ++++-------------------------------
 arch/arm/mach-tegra/hotplug.c      |   56 +++++------------------------------
 arch/arm/mach-ux500/Makefile       |    1 +
 arch/arm/mach-ux500/hotplug.c      |   30 +++++++++++++++++++
 arch/arm/mach-ux500/platsmp.c      |    4 ++-
 10 files changed, 134 insertions(+), 169 deletions(-)
 create mode 100644 arch/arm/common/hotplug.c
 create mode 100644 arch/arm/include/asm/hotplug.h
 create mode 100644 arch/arm/mach-ux500/hotplug.c
Signature · 1 line
1.7.2.dirty
#1 lore raw

PATCH 1/2 ARM: Generalize all CPU Hotplug code across platforms

Factor common cpu hotplug arcoss platforms and move hotplug to arch/arm/common.

---
 arch/arm/common/Makefile           |    1 +
 arch/arm/common/hotplug.c          |   57 ++++++++++++++++++++++++++++++++++++
 arch/arm/include/asm/hotplug.h     |   18 +++++++++++
 arch/arm/mach-omap2/omap-hotplug.c |   24 +--------------
 arch/arm/mach-realview/hotplug.c   |   56 ++++-------------------------------
 arch/arm/mach-s5pv310/hotplug.c    |   56 ++++-------------------------------
 arch/arm/mach-tegra/hotplug.c      |   56 +++++------------------------------
 7 files changed, 100 insertions(+), 168 deletions(-)
 create mode 100644 arch/arm/common/hotplug.c
 create mode 100644 arch/arm/include/asm/hotplug.h
arch/arm/common/Makefile +1 -0
index e6e8664..d0a22d2 100644
@@ -17,3 +17,4 @@ obj-$(CONFIG_ARCH_IXP2000)	+= uengine.o
 obj-$(CONFIG_ARCH_IXP23XX)	+= uengine.o
 obj-$(CONFIG_PCI_HOST_ITE8152)  += it8152.o
 obj-$(CONFIG_COMMON_CLKDEV)	+= clkdev.o
+obj-$(CONFIG_HOTPLUG_CPU)	+= hotplug.o
arch/arm/common/hotplug.c new file +57 -0

57 lines not on this page · raw message

arch/arm/include/asm/hotplug.h new file +18 -0
new file mode 100644
index 0000000..6aed089
@@ -0,0 +1,18 @@
+/*
+ *  arch/arm/common/hotplug.c
+ *
+ *  Copyright (C) 2002 ARM Ltd.
+ *  Copyright (C) 2010 ST-Ericsson
+ *
+ *  All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef __ASM_ARM_HOTPLUG_H
+#define __ASM_ARM_HOTPLUG_H
+
+void platform_do_lowpower(unsigned int cpu);
+
+#endif
arch/arm/mach-omap2/omap-hotplug.c +2 -22
index 6cee456..42ce438 100644
@@ -13,27 +13,15 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/smp.h>
-#include <linux/completion.h>
-
+#include <asm/hotplug.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);
-}
-
 /*
  * platform-specific code to shutdown a CPU
  * Called with IRQs disabled
  */
-void platform_cpu_die(unsigned int cpu)
+void platform_do_lowpower(unsigned int cpu)
 {
 	unsigned int this_cpu = hard_smp_processor_id();
 
@@ -69,11 +57,3 @@ void platform_cpu_die(unsigned int cpu)
 	}
 }
 
-int platform_cpu_disable(unsigned int cpu)
-{
-	/*
-	 * we don't allow CPU 0 to be shutdown (it is still too special
-	 * e.g. clock tick interrupts)
-	 */
-	return cpu == 0 ? -EPERM : 0;
-}
arch/arm/mach-realview/hotplug.c +7 -49

83 lines not on this page · raw message

arch/arm/mach-s5pv310/hotplug.c +7 -49

83 lines not on this page · raw message

arch/arm/mach-tegra/hotplug.c +8 -48

80 lines not on this page · raw message

Signature · 1 line
1.7.2.dirty
#2 lore raw

PATCH 2/2 ux500: Add CPU hotplug support

In reply to Sundar Iyer
---
 arch/arm/mach-ux500/Makefile  |    1 +
 arch/arm/mach-ux500/hotplug.c |   30 ++++++++++++++++++++++++++++++
 arch/arm/mach-ux500/platsmp.c |    4 +++-
 3 files changed, 34 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-ux500/hotplug.c
arch/arm/mach-ux500/Makefile +1 -0
index ed180b8..c07a1e8 100644
@@ -10,3 +10,4 @@ obj-$(CONFIG_MACH_U5500)	+= board-u5500.o
 obj-$(CONFIG_SMP)		+= platsmp.o headsmp.o
 obj-$(CONFIG_LOCAL_TIMERS)	+= localtimer.o
 obj-$(CONFIG_REGULATOR_AB8500)	+= board-mop500-regulators.o
+obj-$(CONFIG_HOTPLUG_CPU)	+= hotplug.o
arch/arm/mach-ux500/hotplug.c new file +30 -0
new file mode 100644
index 0000000..b212857
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) STMicroelectronics 2009
+ * Copyright (C) ST-Ericsson SA 2010
+ * 	Based on ARM realview platform
+ *
+ * License Terms: GNU General Public License v2
+ * Author: Sundar Iyer <[email protected]>
+ *
+ */
+#include <asm/hotplug.h>
+#include <asm/cacheflush.h>
+
+extern volatile int pen_release;
+
+void platform_do_lowpower(unsigned int cpu)
+{
+	flush_cache_all();
+
+	for (;;) {
+		__asm__ __volatile__("dsb\n\t" "wfi\n\t"
+				: : : "memory");
+		if (pen_release == cpu) {
+			/*
+			 * OK, proper wakeup, we're done
+			 */
+			break;
+		}
+	}
+}
+
arch/arm/mach-ux500/platsmp.c +3 -1
index 438ef16..ade2e17 100644
@@ -26,7 +26,7 @@
  * control for which core is the next to come out of the secondary
  * boot "holding pen"
  */
-volatile int __cpuinitdata pen_release = -1;
+volatile int pen_release = -1;
 
 static unsigned int __init get_core_count(void)
 {
@@ -78,6 +78,8 @@ 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));
+
 	timeout = jiffies + (1 * HZ);
 	while (time_before(jiffies, timeout)) {
 		if (pen_release == -1)
Signature · 1 line
1.7.2.dirty
#3 lore raw

cover ARM: factorise CPU hotplug code

In reply to Sundar Iyer

Hi All,

Any comments on these?

Regards,
Sundar

Quoted 33 lines

-----Original Message-----
From: Sundar R IYER
Sent: Friday, September 03, 2010 5:31 PM
To: linux-arm-kernel at lists.infradead.org
Cc: STEricsson_nomadik_linux; Sundar R IYER
Subject: [PATCH 0/2] ARM: factorise CPU hotplug code

Inspired by Will Deacon's cleanup for the Realview series, this is an attempt to factor even more common code and move hotplug functions to the generic arch/arm/common folder

Sundar Iyer (2):
ARM: Generalize all CPU Hotplug code across platforms
ux500: Add CPU hotplug support

arch/arm/common/Makefile | 1 +
arch/arm/common/hotplug.c | 57
++++++++++++++++++++++++++++++++++++

arch/arm/include/asm/hotplug.h     |   18 +++++++++++
arch/arm/mach-omap2/omap-hotplug.c |   24 +--------------
arch/arm/mach-realview/hotplug.c   |   56 ++++-------------------------------
arch/arm/mach-s5pv310/hotplug.c    |   56 ++++-------------------------------
arch/arm/mach-tegra/hotplug.c      |   56 +++++------------------------------
arch/arm/mach-ux500/Makefile       |    1 +
arch/arm/mach-ux500/hotplug.c      |   30 +++++++++++++++++++
arch/arm/mach-ux500/platsmp.c      |    4 ++-
10 files changed, 134 insertions(+), 169 deletions(-)

create mode 100644 arch/arm/common/hotplug.c
create mode 100644 arch/arm/include/asm/hotplug.h
create mode 100644 arch/arm/mach-ux500/hotplug.c

--
1.7.2.dirty

#4 lore raw

cover ARM: factorise CPU hotplug code

Sundar,

Quoted 21 lines

-----Original Message-----
From: Sundar R IYER [mailto:sundar.iyer at stericsson.com]
Sent: Monday, September 06, 2010 10:13 AM
To: Will Deacon; Shilimkar, Santosh; Kukjin Kim; Colin Cross
Cc: linux-arm-kernel at lists.infradead.org
Subject: RE: [PATCH 0/2] ARM: factorise CPU hotplug code

Hi All,

Any comments on these?

Regards,
Sundar

Quoted 7 lines

-----Original Message-----
From: Sundar R IYER
Sent: Friday, September 03, 2010 5:31 PM
To: linux-arm-kernel at lists.infradead.org
Cc: STEricsson_nomadik_linux; Sundar R IYER
Subject: [PATCH 0/2] ARM: factorise CPU hotplug code

Quoted 9 lines
Quoted 1 line

Inspired by Will Deacon's cleanup for the Realview series, this is an

attempt

Quoted 7 lines

to factor even more common code and move hotplug functions to the generic arch/arm/common folder

Sundar Iyer (2):
ARM: Generalize all CPU Hotplug code across platforms
ux500: Add CPU hotplug support

Generic Approach seems to be good but I think this might complicate few scenario's regarding how _A_ platform wants to handle the hotplug.

I let other comment on this.

Quoted 21 lines
Quoted 6 lines

arch/arm/common/Makefile | 1 +
arch/arm/common/hotplug.c | 57
++++++++++++++++++++++++++++++++++++

arch/arm/include/asm/hotplug.h     |   18 +++++++++++
arch/arm/mach-omap2/omap-hotplug.c |   24 +--------------
arch/arm/mach-realview/hotplug.c   |   56 ++++--------------------------

-----

Quoted 1 line

arch/arm/mach-s5pv310/hotplug.c | 56 ++++--------------------------

-----

Quoted 1 line

arch/arm/mach-tegra/hotplug.c | 56 +++++-------------------------

-----

Quoted 10 lines
arch/arm/mach-ux500/Makefile       |    1 +
arch/arm/mach-ux500/hotplug.c      |   30 +++++++++++++++++++
arch/arm/mach-ux500/platsmp.c      |    4 ++-
10 files changed, 134 insertions(+), 169 deletions(-)

create mode 100644 arch/arm/common/hotplug.c create mode 100644 arch/arm/include/asm/hotplug.h create mode 100644 arch/arm/mach-ux500/hotplug.c

--
1.7.2.dirty

#5 lore raw

cover ARM: factorise CPU hotplug code

Hi Santosh,

Quoted 6 lines

-----Original Message-----
From: Shilimkar, Santosh [mailto:santosh.shilimkar at ti.com]

Generic Approach seems to be good but I think this might complicate few scenario's regarding how _A_ platform wants to handle the hotplug.

Yes. But the functions cpu_enter_lowpower and cpu_leave_lowpower()
are still preserved in platform specific files. Only the top helpers are moved out. So, platforms can still work out their custom low power mode implementations; which I believe can vary according to the implementation of (say independent) power domains for each/multiple cores.

Is there anything still you think cannot be generalized?

Quoted 1 line

I let other comment on this.

Regards,
Sundar

#6 lore raw

cover ARM: factorise CPU hotplug code

Quoted 12 lines

-----Original Message-----
From: Sundar R IYER [mailto:sundar.iyer at stericsson.com]
Sent: Monday, September 06, 2010 12:46 PM
To: Shilimkar, Santosh; Will Deacon; Kukjin Kim; Colin Cross
Cc: linux-arm-kernel at lists.infradead.org
Subject: RE: [PATCH 0/2] ARM: factorise CPU hotplug code

Hi Santosh,

Quoted 2 lines

-----Original Message-----
From: Shilimkar, Santosh [mailto:santosh.shilimkar at ti.com]

Quoted 7 lines
Quoted 3 lines

Generic Approach seems to be good but I think this might complicate few scenario's regarding how _A_ platform wants to handle the hotplug.

Yes. But the functions cpu_enter_lowpower and cpu_leave_lowpower() are still preserved in platform specific files. Only the top helpers are moved out.

I saw that and hence was ok with the change to begin with.

Quoted 8 lines

So, platforms can still work out their custom low power mode implementations;
which I believe can vary according to the implementation of (say independent) power
domains for each/multiple cores.

Is there anything still you think cannot be generalized?

The generic timeout also can be optimized in certain cases or may be for all platforms.

I am ok with this change as such.

Regards,
Santosh

#7 lore raw

cover ARM: factorise CPU hotplug code

In reply to Sundar R IYER
Quoted 9 lines · Sundar R IYER

Hi Santosh,

Quoted 6 lines

-----Original Message-----
From: Shilimkar, Santosh [mailto:santosh.shilimkar at ti.com]

Generic Approach seems to be good but I think this might complicate few scenario's regarding how _A_ platform wants to handle the hotplug.

Quoted 8 lines

Yes. But the functions cpu_enter_lowpower and cpu_leave_lowpower() are still preserved in platform specific files. Only the top helpers are moved out.

So, platforms can still work out their custom low power mode implementations; which I believe can vary according to the implementation of (say independent) power domains for each/ multiple cores.

So what if a platform wants to completely power down a CPU?

You'd want to implement it such that platform_cpu_die() does all the shutdown of the CPU except for power-off, and platform_cpu_kill() waits for that to complete before turning power off.

With platform_cpu_kill() and platform_cpu_die() moved into generic code, you can no longer do this.

Lastly, what if you want to allow CPU0 to be offlined, which is possible, though its wake-up is a little more complex because it must not be allowed to go through its normal boot?

#8 lore raw

cover ARM: factorise CPU hotplug code

Hello,

Quoted 6 lines

-----Original Message-----
From: Russell King - ARM Linux [mailto:linux at arm.linux.org.uk]
Sent: Monday, September 06, 2010 2:27 PM

So what if a platform wants to completely power down a CPU?

Cannot this can be still implemented in the platform_do_lowpower() inside the platform code? I think all that would be replaced for the platform is the WFI portion, which might be accompanied by requests to turn the core off.

Quoted 6 lines

You'd want to implement it such that platform_cpu_die() does all the shutdown of the CPU except for power-off, and platform_cpu_kill() waits for that to complete before turning power off.

With platform_cpu_kill() and platform_cpu_die() moved into generic code, you can no longer do this.

I am sorry but I didn't understand this. The erstwhile platform_cpu_die contains helpers to prepare/enter/exit low power modes. Am I missing something here that the prepare/enter/exit cannot be included in a do_low_power() which is platform specific?

Quoted 3 lines

Lastly, what if you want to allow CPU0 to be offlined, which is possible, though its wake-up is a little more complex because it must not be allowed to go through its normal boot?

I moved this because none of the platforms currently support offlining CPU0 in the current code. But, even if it may be possible, wouldn't it be generic for the architecture?

Regards,
Sundar

#9 lore raw

cover ARM: factorise CPU hotplug code

In reply to Russell King - ARM Linux

Hello again,

Any recent comments on the cpu hotplug re-factoring patches? Do I need to make any further changes in there or should I drop them?

Regards,
Sundar

Quoted 4 lines

-----Original Message-----
From: Sundar R IYER
Sent: Tuesday, September 07, 2010 3:02 PM
Sundar