Skip to contentSkip to conversation

ARM: S5PV310: Update S5PV310 CPU hotplug implementation

PATCH New Kukjin Kim 3 participants 7 messages Sep 17, 2010 – Sep 30, 2010

Subsystems (4)
lore
Share & tools
lore

Kukjin Kim

author
#0 lore raw

cover ARM: S5PV310: Update S5PV310 CPU hotplug implementation

This patch updates S5PV310 CPU hotplug implementation to reduce power consumption.

[PATCH 1/2] ARM: S5PV310: Add PMU for S5PV310 hotplug [PATCH 2/2] ARM: S5PV310: Update CPU hotplug implementation

author
#1 lore raw

PATCH 1/2 ARM: S5PV310: Add PMU for S5PV310 hotplug

From: Changhwan Youn <[email protected]>

This patch adds PMU(Power Management Unit) for S5PV310/S5PC210 hotplug.

---
 arch/arm/mach-s5pv310/cpu.c                   |    5 +++++
 arch/arm/mach-s5pv310/include/mach/map.h      |    2 ++
 arch/arm/mach-s5pv310/include/mach/regs-pmu.h |   25 +++++++++++++++++++++++++
 arch/arm/plat-s5p/include/plat/map-s5p.h      |    1 +
 4 files changed, 33 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-s5pv310/include/mach/regs-pmu.h
arch/arm/mach-s5pv310/cpu.c +5 -0
index 4add398..3a3f90a 100644
@@ -41,6 +41,11 @@ static struct map_desc s5pv310_iodesc[] __initdata = {
 		.length		= SZ_128K,
 		.type		= MT_DEVICE,
 	}, {
+		.virtual	= (unsigned long)S5P_VA_PMU,
+		.pfn		= __phys_to_pfn(S5PV310_PA_PMU),
+		.length		= SZ_16K,
+		.type		= MT_DEVICE,
+	}, {
 		.virtual	= (unsigned long)S5P_VA_COMBINER_BASE,
 		.pfn		= __phys_to_pfn(S5PV310_PA_COMBINER),
 		.length		= SZ_4K,
arch/arm/mach-s5pv310/include/mach/map.h +2 -0
index aff6d23..c953c94 100644
@@ -37,6 +37,8 @@
 #define S5PV310_PA_SYSCON		(0x10010000)
 #define S5P_PA_SYSCON			S5PV310_PA_SYSCON
 
+#define S5PV310_PA_PMU			(0x10020000)
+
 #define S5PV310_PA_CMU			(0x10030000)
 
 #define S5PV310_PA_WATCHDOG		(0x10060000)
arch/arm/mach-s5pv310/include/mach/regs-pmu.h new file +25 -0
new file mode 100644
index 0000000..bb15a40
@@ -0,0 +1,25 @@
+/* linux/arch/arm/mach-s5pv310/include/mach/regs-pmu.h
+ *
+ * Copyright (c) 2010 Samsung Electronics Co., Ltd.
+ *		http://www.samsung.com
+ *
+ * S5PV310 - Power management unit definition
+ *
+ * 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_ARCH_REGS_PMU_H
+#define __ASM_ARCH_REGS_PMU_H __FILE__
+
+#include <mach/map.h>
+
+#define S5PV310_PMU(x)			(S5P_VA_PMU + (x))
+
+#define S5PV310_ARM_CORE1_CONF		S5P_PMU(0x2080)
+#define S5PV310_ARM_CORE1_STAT		S5P_PMU(0x2084)
+
+#define S5PV310_CORE_PWR_EN		0x3
+
+#endif /* __ASM_ARCH_REGS_PMU_H */
arch/arm/plat-s5p/include/plat/map-s5p.h +1 -0
index c4ff88b..bee029e 100644
@@ -31,6 +31,7 @@
 
 #define S5P_VA_L2CC		S3C_ADDR(0x00900000)
 #define S5P_VA_CMU		S3C_ADDR(0x00920000)
+#define S5P_VA_PMU		S3C_ADDR(0x00940000)
 
 #define S5P_VA_UART(x)		(S3C_VA_UART + ((x) * S3C_UART_OFFSET))
 #define S5P_VA_UART0		S5P_VA_UART(0)
Signature · 1 line
1.6.2.5
author
#2 lore raw

PATCH 1/2 ARM: S5PV310: Add PMU for S5PV310 hotplug

Quoted 6 lines · Kukjin Kim

From: Changhwan Youn <[email protected]>

This patch adds PMU(Power Management Unit) for S5PV310/S5PC210 hotplug.

missed...when submitted...

Review

Quoted 40 lines
---
 arch/arm/mach-s5pv310/cpu.c                   |    5 +++++
 arch/arm/mach-s5pv310/include/mach/map.h      |    2 ++
 arch/arm/mach-s5pv310/include/mach/regs-pmu.h |   25
+++++++++++++++++++++++++
 arch/arm/plat-s5p/include/plat/map-s5p.h      |    1 +
 4 files changed, 33 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-s5pv310/include/mach/regs-pmu.h
arch/arm/mach-s5pv310/cpu.c +5 -0
index 4add398..3a3f90a 100644
@@ -41,6 +41,11 @@ static struct map_desc s5pv310_iodesc[] __initdata = {
 		.length		= SZ_128K,
 		.type		= MT_DEVICE,
 	}, {
+		.virtual	= (unsigned long)S5P_VA_PMU,
+		.pfn		= __phys_to_pfn(S5PV310_PA_PMU),
+		.length		= SZ_16K,
+		.type		= MT_DEVICE,
+	}, {
 		.virtual	= (unsigned long)S5P_VA_COMBINER_BASE,
 		.pfn		= __phys_to_pfn(S5PV310_PA_COMBINER),
 		.length		= SZ_4K,
arch/arm/mach- renamed from arch/arm/mach-s5pv310/include/mach/map.h +0 -0

s5pv310/include/mach/map.h
index aff6d23..c953c94 100644

arch/arm/mach-s5pv310/include/mach/map.h +2 -0
@@ -37,6 +37,8 @@
 #define S5PV310_PA_SYSCON		(0x10010000)
 #define S5P_PA_SYSCON			S5PV310_PA_SYSCON
 
+#define S5PV310_PA_PMU			(0x10020000)
+
 #define S5PV310_PA_CMU			(0x10030000)
 
 #define S5PV310_PA_WATCHDOG		(0x10060000)
(quoted diff) +0 -0

b/arch/arm/mach-

Quoted 44 lines

s5pv310/include/mach/regs-pmu.h
new file mode 100644
index 0000000..bb15a40

arch/arm/mach-s5pv310/include/mach/regs-pmu.h new file +25 -0
@@ -0,0 +1,25 @@
+/* linux/arch/arm/mach-s5pv310/include/mach/regs-pmu.h
+ *
+ * Copyright (c) 2010 Samsung Electronics Co., Ltd.
+ *		http://www.samsung.com
+ *
+ * S5PV310 - Power management unit definition
+ *
+ * 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_ARCH_REGS_PMU_H
+#define __ASM_ARCH_REGS_PMU_H __FILE__
+
+#include <mach/map.h>
+
+#define S5PV310_PMU(x)			(S5P_VA_PMU + (x))
+
+#define S5PV310_ARM_CORE1_CONF		S5P_PMU(0x2080)
+#define S5PV310_ARM_CORE1_STAT		S5P_PMU(0x2084)
+
+#define S5PV310_CORE_PWR_EN		0x3
+
+#endif /* __ASM_ARCH_REGS_PMU_H */
arch/arm/plat- renamed from arch/arm/plat-s5p/include/plat/map-s5p.h +0 -0

s5p/include/plat/map-s5p.h
index c4ff88b..bee029e 100644

arch/arm/plat-s5p/include/plat/map-s5p.h +1 -0
@@ -31,6 +31,7 @@
 
 #define S5P_VA_L2CC		S3C_ADDR(0x00900000)
 #define S5P_VA_CMU		S3C_ADDR(0x00920000)
+#define S5P_VA_PMU		S3C_ADDR(0x00940000)
 
 #define S5P_VA_UART(x)		(S3C_VA_UART + ((x) *
 S3C_UART_OFFSET))
Quoted 2 lines

#define S5P_VA_UART0 S5P_VA_UART(0)
--

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.

author
#3 lore raw

PATCH 2/2 ARM: S5PV310: Update CPU hotplug implementation

In reply to Kukjin Kim

From: Changhwan Youn <[email protected]>

This patch updates CPU hotplug implementation to reduce CPU power consumption and will turn off the CPU power when CPU1 is unplugged while previous CPU hotplug used CPU idle.
This patch removes init memory freeing code to use CPU boot code when CPU1 is plugged-in again and adds vfp_enable() call to allow to access CP10 and CP11.

---
 arch/arm/mach-s5pv310/hotplug.c |   12 +++++++-----
 arch/arm/mach-s5pv310/platsmp.c |   34 ++++++++++++++++++++++++++++++++++
 arch/arm/mm/init.c              |    2 ++
 arch/arm/vfp/vfpmodule.c        |    2 +-
 4 files changed, 44 insertions(+), 6 deletions(-)
arch/arm/mach-s5pv310/hotplug.c +7 -5
index 03652c3..0e188fe 100644
@@ -14,9 +14,12 @@
 #include <linux/errno.h>
 #include <linux/smp.h>
 #include <linux/completion.h>
+#include <linux/io.h>
 
 #include <asm/cacheflush.h>
 
+#include <mach/regs-pmu.h>
+
 extern volatile int pen_release;
 
 static DECLARE_COMPLETION(cpu_killed);
@@ -61,12 +64,11 @@ static inline void cpu_leave_lowpower(void)
 
 static inline void platform_do_lowpower(unsigned int cpu)
 {
-	/*
-	 * there is no power-control hardware on this platform, so all
-	 * we can do is put the core into WFI; this is safe as the calling
-	 * code will have already disabled interrupts
-	 */
 	for (;;) {
+		/* make cpu1 to be turned off at next WFI command */
+		if (cpu == 1)
+			__raw_writel(0, S5PV310_ARM_CORE1_CONF);
+
 		/*
 		 * here's the WFI
 		 */
arch/arm/mach-s5pv310/platsmp.c +34 -0
index d357c19..d10c4ad 100644
@@ -28,8 +28,10 @@
 
 #include <mach/hardware.h>
 #include <mach/regs-clock.h>
+#include <mach/regs-pmu.h>
 
 extern void s5pv310_secondary_startup(void);
+extern void vfp_enable(void *unused);
 
 /*
  * control for which core is the next to come out of the secondary
@@ -47,6 +49,10 @@ static DEFINE_SPINLOCK(boot_lock);
 
 void __cpuinit platform_secondary_init(unsigned int cpu)
 {
+#ifdef CONFIG_VFP
+	vfp_enable(NULL);
+#endif
+
 	trace_hardirqs_off();
 
 	/*
@@ -92,6 +98,27 @@ 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));
 
+	if (!(__raw_readl(S5PV310_ARM_CORE1_STAT) & S5PV310_CORE_PWR_EN)) {
+		__raw_writel(S5PV310_CORE_PWR_EN,
+			     S5PV310_ARM_CORE1_CONF);
+
+		timeout = 10;
+
+		/* wait max 10 ms until cpu1 is on */
+		while ((__raw_readl(S5PV310_ARM_CORE1_STAT)
+			& S5PV310_CORE_PWR_EN) != S5PV310_CORE_PWR_EN) {
+			if (timeout-- == 0)
+				break;
+
+			mdelay(1);
+		}
+
+		if (timeout == 0) {
+			printk(KERN_ERR "cpu1 power-up failed");
+			return -ETIMEDOUT;
+		}
+	}
+
 	/*
 	 * Send the secondary CPU a soft interrupt, thereby causing
 	 * the boot monitor to read the system wide flags register,
@@ -102,6 +129,13 @@ int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
 	timeout = jiffies + (1 * HZ);
 	while (time_before(jiffies, timeout)) {
 		smp_rmb();
+
+		if (!__raw_readl(S5P_VA_SYSRAM)) {
+			__raw_writel(BSYM(virt_to_phys(s5pv310_secondary_startup)),
+				     S5P_VA_SYSRAM);
+			smp_cross_call(cpumask_of(cpu));
+		}
+
 		if (pen_release == -1)
 			break;
 
arch/arm/mm/init.c +2 -0
index 7185b00..57c4c5c 100644
@@ -589,10 +589,12 @@ void free_initmem(void)
 				    "TCM link");
 #endif
 
+#ifndef CONFIG_HOTPLUG_CPU
 	if (!machine_is_integrator() && !machine_is_cintegrator())
 		totalram_pages += free_area(__phys_to_pfn(__pa(__init_begin)),
 					    __phys_to_pfn(__pa(__init_end)),
 					    "init");
+#endif
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
arch/arm/vfp/vfpmodule.c +1 -1
index 8063a32..eee8f67 100644
@@ -364,7 +364,7 @@ void VFP_bounce(u32 trigger, u32 fpexc, struct pt_regs *regs)
 	preempt_enable();
 }
 
-static void vfp_enable(void *unused)
+void vfp_enable(void *unused)
 {
 	u32 access = get_copro_access();
 
Signature · 1 line
1.6.2.5
author
#4 lore raw

PATCH 2/2 ARM: S5PV310: Update CPU hotplug implementation

Quoted 9 lines · Kukjin Kim

From: Changhwan Youn <[email protected]>

This patch updates CPU hotplug implementation to reduce CPU power consumption
and will turn off the CPU power when CPU1 is unplugged while previous CPU hotplug
used CPU idle.
This patch removes init memory freeing code to use CPU boot code when CPU1

is

Quoted 1 line

plugged-in again and adds vfp_enable() call to allow to access CP10 and

CP11.

Quoted 4 lines
Cc Tony Lindgren <[email protected]>
Cc Colin Cross <[email protected]>
Cc Erik Gilling <[email protected]>
Cc Olof Johansson <[email protected]>

Hi all,

Please check changing of arch/arm/mm/init.c and arch/arm/vfp/vfpmodule.c.
- Removed init memory freeing code to use CPU boot code when CPU1 is plugged-in again.
- Added vfp_enable() call to allow to access CP10 and CP11.

Review

Quoted 9 lines
---
 arch/arm/mach-s5pv310/hotplug.c |   12 +++++++-----
 arch/arm/mach-s5pv310/platsmp.c |   34
++++++++++++++++++++++++++++++++++
 arch/arm/mm/init.c              |    2 ++
 arch/arm/vfp/vfpmodule.c        |    2 +-
 4 files changed, 44 insertions(+), 6 deletions(-)
(quoted diff) +0 -0

b/arch/arm/mach-s5pv310/hotplug.c

Review

Quoted 34 lines

index 03652c3..0e188fe 100644

arch/arm/mach-s5pv310/hotplug.c +7 -5
@@ -14,9 +14,12 @@
 #include <linux/errno.h>
 #include <linux/smp.h>
 #include <linux/completion.h>
+#include <linux/io.h>
 
 #include <asm/cacheflush.h>
 
+#include <mach/regs-pmu.h>
+
 extern volatile int pen_release;
 
 static DECLARE_COMPLETION(cpu_killed);
@@ -61,12 +64,11 @@ static inline void cpu_leave_lowpower(void)
 
 static inline void platform_do_lowpower(unsigned int cpu)
 {
-	/*
-	 * there is no power-control hardware on this platform, so all
-	 * we can do is put the core into WFI; this is safe as the calling
-	 * code will have already disabled interrupts
-	 */
 	for (;;) {
+		/* make cpu1 to be turned off at next WFI command */
+		if (cpu == 1)
+			__raw_writel(0, S5PV310_ARM_CORE1_CONF);
+
 		/*
 		 * here's the WFI
 		 */
(quoted diff) +0 -0

b/arch/arm/mach-s5pv310/platsmp.c

Quoted 77 lines

index d357c19..d10c4ad 100644

arch/arm/mach-s5pv310/platsmp.c +27 -0
@@ -28,8 +28,10 @@
 
 #include <mach/hardware.h>
 #include <mach/regs-clock.h>
+#include <mach/regs-pmu.h>
 
 extern void s5pv310_secondary_startup(void);
+extern void vfp_enable(void *unused);
 
 /*
  * control for which core is the next to come out of the secondary
@@ -47,6 +49,10 @@ static DEFINE_SPINLOCK(boot_lock);
 
 void __cpuinit platform_secondary_init(unsigned int cpu)
 {
+#ifdef CONFIG_VFP
+	vfp_enable(NULL);
+#endif
+
 	trace_hardirqs_off();
 
 	/*
@@ -92,6 +98,27 @@ 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));
 
+	if (!(__raw_readl(S5PV310_ARM_CORE1_STAT) &
 S5PV310_CORE_PWR_EN)) {
+		__raw_writel(S5PV310_CORE_PWR_EN,
+			     S5PV310_ARM_CORE1_CONF);
+
+		timeout = 10;
+
+		/* wait max 10 ms until cpu1 is on */
+		while ((__raw_readl(S5PV310_ARM_CORE1_STAT)
+			& S5PV310_CORE_PWR_EN) !=
 S5PV310_CORE_PWR_EN) {
+			if (timeout-- == 0)
+				break;
+
+			mdelay(1);
+		}
+
+		if (timeout == 0) {
+			printk(KERN_ERR "cpu1 power-up failed");
+			return -ETIMEDOUT;
+		}
+	}
+
arch/arm/mach-s5pv310/platsmp.c +7 -0
 	/*
 	 * Send the secondary CPU a soft interrupt, thereby causing
 	 * the boot monitor to read the system wide flags register,
@@ -102,6 +129,13 @@ int __cpuinit boot_secondary(unsigned int cpu, struct
 task_struct *idle)
 	timeout = jiffies + (1 * HZ);
 	while (time_before(jiffies, timeout)) {
 		smp_rmb();
+
+		if (!__raw_readl(S5P_VA_SYSRAM)) {
+
 	__raw_writel(BSYM(virt_to_phys(s5pv310_secondary_startup)),
+				     S5P_VA_SYSRAM);
+			smp_cross_call(cpumask_of(cpu));
+		}
+
 		if (pen_release == -1)
arch/arm/mach-s5pv310/platsmp.c +0 -0
 			break;
arch/arm/mm/init.c +0 -0
index 7185b00..57c4c5c 100644

arch/arm/mm/init.c void free_initmem(void) · line 594

Quoted 6 lines
arch/arm/mm/init.c +1 -0
@@ -589,10 +589,12 @@ void free_initmem(void)
 				    "TCM link");
 #endif
 
+#ifndef CONFIG_HOTPLUG_CPU
 	if (!machine_is_integrator() && !machine_is_cintegrator())
 		totalram_pages +=

free_area(__phys_to_pfn(__pa(__init_begin)),

Quoted 11 lines
arch/arm/mm/init.c +1 -0
 					    __phys_to_pfn(__pa(__init_end)),
 					    "init");
+#endif
 }
 
 #ifdef CONFIG_BLK_DEV_INITRD
arch/arm/vfp/vfpmodule.c +0 -0
index 8063a32..eee8f67 100644

arch/arm/vfp/vfpmodule.c void VFP_bounce(u32 trigger, u32 fpexc, struct pt_regs

Quoted 10 lines
arch/arm/vfp/vfpmodule.c +1 -2
@@ -364,7 +364,7 @@ void VFP_bounce(u32 trigger, u32 fpexc, struct pt_regs
 *regs)
 	preempt_enable();
 }
 
-static void vfp_enable(void *unused)
+void vfp_enable(void *unused)
 {
 	u32 access = get_copro_access();
 
--

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.

#5 lore raw

PATCH 2/2 ARM: S5PV310: Update CPU hotplug implementation

Quoted 22 lines · Kukjin Kim
Quoted 9 lines · Kukjin Kim

From: Changhwan Youn <[email protected]>

This patch updates CPU hotplug implementation to reduce CPU power consumption
and will turn off the CPU power when CPU1 is unplugged while previous CPU hotplug
used CPU idle.
This patch removes init memory freeing code to use CPU boot code when CPU1

is

Quoted 1 line

plugged-in again and adds vfp_enable() call to allow to access CP10 and

CP11.

Quoted 4 lines
Cc Tony Lindgren <[email protected]>
Cc Colin Cross <[email protected]>
Cc Erik Gilling <[email protected]>
Cc Olof Johansson <[email protected]>

snip

Quoted 10 lines
Quoted 3 lines

+#ifndef CONFIG_HOTPLUG_CPU
? ? ? if (!machine_is_integrator() && !machine_is_cintegrator()) ? ? ? ? ? ? ? totalram_pages +=

free_area(__phys_to_pfn(__pa(__init_begin)),

Quoted 6 lines

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? __phys_to_pfn(__pa(__init_end)), ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "init");
+#endif
?}

?#ifdef CONFIG_BLK_DEV_INITRD

I don't think this is necessary. Any symbol that is necessary for CPU hotplug should be marked with __cpuinit instead of __init. The linker script will put __cpuinit symbols outside the __init_begin - __init_end section if CONFIG_HOTPLUG_CPU is enabled.

#6 lore raw

PATCH 2/2 ARM: S5PV310: Update CPU hotplug implementation

Quoted 35 lines · Colin Cross
Quoted 22 lines · Kukjin Kim
Quoted 9 lines · Kukjin Kim

From: Changhwan Youn <[email protected]>

This patch updates CPU hotplug implementation to reduce CPU power consumption
and will turn off the CPU power when CPU1 is unplugged while previous CPU hotplug
used CPU idle.
This patch removes init memory freeing code to use CPU boot code when CPU1

is

Quoted 1 line

plugged-in again and adds vfp_enable() call to allow to access CP10 and

CP11.

Quoted 4 lines
Cc Tony Lindgren <[email protected]>
Cc Colin Cross <[email protected]>
Cc Erik Gilling <[email protected]>
Cc Olof Johansson <[email protected]>

snip

Quoted 9 lines
Quoted 3 lines

+#ifndef CONFIG_HOTPLUG_CPU
? ? ? if (!machine_is_integrator() && !machine_is_cintegrator()) ? ? ? ? ? ? ? totalram_pages +=

free_area(__phys_to_pfn(__pa(__init_begin)),

Quoted 5 lines

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? __phys_to_pfn(__pa(__init_end)), ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "init");
+#endif
?}

Quoted 6 lines
Quoted 1 line
Quoted 1 line

?#ifdef CONFIG_BLK_DEV_INITRD

I don't think this is necessary. Any symbol that is necessary for CPU hotplug should be marked with __cpuinit instead of __init. The linker script will put __cpuinit symbols outside the __init_begin - __init_end section if CONFIG_HOTPLUG_CPU is enabled.

That's the theory, but not everything required for a complete restart of a secondary CPU (iow, if it's powered off) is in the right section yet. I'll have patches hopefully tomorrow to address this.