Various SoCs with arm processors define their own platform hotplug related functions. These functions can be defined as part of the core cpu hotplug functions, this will avoid the duplication. This patchset is intended to address this issue.
This patchset covers arm-Cortex-A9 of exynos, imx, realview, spear and vexpress SoCs. Not having h/w, the patch is not tested.
Sanjay Singh Rawat (6): ARM: cpuhotplug: move common hotplug related functions to core ARM: imx: use the core cpu hotplug functions ARM: RealView: use the core cpu hotplug functions ARM: spear: use the core cpu hotplug functions ARM: vexpress: use the core cpu hotplug functions ARM: EXYNOS: use the core cpu hotplug functions
arch/arm/include/asm/hotplug.h | 24 ++++++++++++++ arch/arm/kernel/Makefile | 1 + arch/arm/kernel/cpuhotplug.c | 64 ++++++++++++++++++++++++++++++++++++++ arch/arm/mach-exynos/hotplug.c | 40 ++---------------------- arch/arm/mach-imx/hotplug.c | 22 +------------ arch/arm/mach-realview/hotplug.c | 37 +--------------------- arch/arm/mach-spear/hotplug.c | 37 +--------------------- arch/arm/mach-vexpress/hotplug.c | 38 +--------------------- 8 files changed, 95 insertions(+), 168 deletions(-) create mode 100644 arch/arm/include/asm/hotplug.h create mode 100644 arch/arm/kernel/cpuhotplug.c
Add function which prepare arm processors to enter the low power for hotplug functionality and handle the return path.
Signed-off-by: Sanjay Singh Rawat sanjay.rawat@linaro.org --- arch/arm/include/asm/hotplug.h | 24 +++++++++++++++ arch/arm/kernel/Makefile | 1 + arch/arm/kernel/cpuhotplug.c | 64 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 arch/arm/include/asm/hotplug.h create mode 100644 arch/arm/kernel/cpuhotplug.c
diff --git a/arch/arm/include/asm/hotplug.h b/arch/arm/include/asm/hotplug.h new file mode 100644 index 0000000..ae80f0e --- /dev/null +++ b/arch/arm/include/asm/hotplug.h @@ -0,0 +1,24 @@ +/* + * arch/arm/include/asm/hotplug.h + * + * 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. + */ + +#ifdef CONFIG_HOTPLUG_CPU + +extern inline void cpu_enter_lowpower(void); +extern inline void cpu_leave_lowpower(void); + +#else +static inline void cpu_enter_lowpower(void) +{ + return -ENODEV; +} +static inline void cpu_leave_lowpower(void) +{ + return -ENODEV; +} + +#endif diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index 5f3338e..9bd370b 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile @@ -33,6 +33,7 @@ obj-$(CONFIG_ISA_DMA) += dma-isa.o obj-$(CONFIG_PCI) += bios32.o isa.o obj-$(CONFIG_ARM_CPU_SUSPEND) += sleep.o suspend.o obj-$(CONFIG_SMP) += smp.o smp_tlb.o +obj-$(CONFIG_HOTPLUG_CPU) += cpuhotplug.o obj-$(CONFIG_HAVE_ARM_SCU) += smp_scu.o obj-$(CONFIG_HAVE_ARM_TWD) += smp_twd.o obj-$(CONFIG_ARM_ARCH_TIMER) += arch_timer.o diff --git a/arch/arm/kernel/cpuhotplug.c b/arch/arm/kernel/cpuhotplug.c new file mode 100644 index 0000000..8651b96 --- /dev/null +++ b/arch/arm/kernel/cpuhotplug.c @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2002 ARM Ltd. + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include <linux/kernel.h> +#include <asm/cp15.h> + +/* + * For Cortex-A9 processor + */ +static inline void ca9_enter_lowpower(void) +{ + unsigned int v; + + asm volatile( + " mcr p15, 0, %1, c7, c5, 0\n" + " mcr p15, 0, %1, c7, c10, 4\n" + /* + * Turn off coherency + */ + " mrc p15, 0, %0, c1, c0, 1\n" + " bic %0, %0, %3\n" + " mcr p15, 0, %0, c1, c0, 1\n" + " mrc p15, 0, %0, c1, c0, 0\n" + " bic %0, %0, %2\n" + " mcr p15, 0, %0, c1, c0, 0\n" + : "=&r" (v) + : "r" (0), "Ir" (CR_C), "Ir" (0x40) + : "cc"); +} + +inline void cpu_leave_lowpower(void) +{ + unsigned int v; + + asm volatile( + "mrc p15, 0, %0, c1, c0, 0\n" + " orr %0, %0, %1\n" + " mcr p15, 0, %0, c1, c0, 0\n" + " mrc p15, 0, %0, c1, c0, 1\n" + " orr %0, %0, %2\n" + " mcr p15, 0, %0, c1, c0, 1\n" + : "=&r" (v) + : "Ir" (CR_C), "Ir" (0x40) + : "cc"); +} + +void cpu_enter_lowpower(void) +{ + int id = 0; + + /* check the cpuid */ + asm("mrc p15, 0, %0, c0, c0, 0" : "=r"(id) : : "cc"); + + if ((id & 0xffffffff) == 0x411fc090) + ca9_enter_lowpower(); + else + pr_warn(KERN_WARNING "Unknown CPU type\n"); +}
Hi,
On Mon, May 20, 2013 at 3:33 PM, Sanjay Singh Rawat <sanjay.rawat@linaro.org
wrote:
Add function which prepare arm processors to enter the low power for hotplug functionality and handle the return path.
Signed-off-by: Sanjay Singh Rawat sanjay.rawat@linaro.org
arch/arm/include/asm/hotplug.h | 24 +++++++++++++++ arch/arm/kernel/Makefile | 1 + arch/arm/kernel/cpuhotplug.c | 64 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 arch/arm/include/asm/hotplug.h create mode 100644 arch/arm/kernel/cpuhotplug.c
diff --git a/arch/arm/include/asm/hotplug.h b/arch/arm/include/asm/hotplug.h new file mode 100644 index 0000000..ae80f0e --- /dev/null +++ b/arch/arm/include/asm/hotplug.h @@ -0,0 +1,24 @@ +/*
- arch/arm/include/asm/hotplug.h
- 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.
- */
+#ifdef CONFIG_HOTPLUG_CPU
+extern inline void cpu_enter_lowpower(void); +extern inline void cpu_leave_lowpower(void);
+#else +static inline void cpu_enter_lowpower(void) +{
return -ENODEV;
+} +static inline void cpu_leave_lowpower(void) +{
return -ENODEV;
+}
+#endif diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index 5f3338e..9bd370b 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile @@ -33,6 +33,7 @@ obj-$(CONFIG_ISA_DMA) += dma-isa.o obj-$(CONFIG_PCI) += bios32.o isa.o obj-$(CONFIG_ARM_CPU_SUSPEND) += sleep.o suspend.o obj-$(CONFIG_SMP) += smp.o smp_tlb.o +obj-$(CONFIG_HOTPLUG_CPU) += cpuhotplug.o obj-$(CONFIG_HAVE_ARM_SCU) += smp_scu.o obj-$(CONFIG_HAVE_ARM_TWD) += smp_twd.o obj-$(CONFIG_ARM_ARCH_TIMER) += arch_timer.o diff --git a/arch/arm/kernel/cpuhotplug.c b/arch/arm/kernel/cpuhotplug.c new file mode 100644 index 0000000..8651b96 --- /dev/null +++ b/arch/arm/kernel/cpuhotplug.c @@ -0,0 +1,64 @@ +/*
- Copyright (C) 2002 ARM Ltd.
- All Rights Reserved
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2 as
- published by the Free Software Foundation.
- */
+#include <linux/kernel.h> +#include <asm/cp15.h>
+/*
- For Cortex-A9 processor
- */
+static inline void ca9_enter_lowpower(void) +{
unsigned int v;
asm volatile(
" mcr p15, 0, %1, c7, c5, 0\n"
" mcr p15, 0, %1, c7, c10, 4\n"
/*
* Turn off coherency
*/
" mrc p15, 0, %0, c1, c0, 1\n"
" bic %0, %0, %3\n"
" mcr p15, 0, %0, c1, c0, 1\n"
" mrc p15, 0, %0, c1, c0, 0\n"
" bic %0, %0, %2\n"
" mcr p15, 0, %0, c1, c0, 0\n"
: "=&r" (v)
: "r" (0), "Ir" (CR_C), "Ir" (0x40)
: "cc");
+}
+inline void cpu_leave_lowpower(void) +{
unsigned int v;
asm volatile(
"mrc p15, 0, %0, c1, c0, 0\n"
" orr %0, %0, %1\n"
" mcr p15, 0, %0, c1, c0, 0\n"
" mrc p15, 0, %0, c1, c0, 1\n"
" orr %0, %0, %2\n"
" mcr p15, 0, %0, c1, c0, 1\n"
: "=&r" (v)
: "Ir" (CR_C), "Ir" (0x40)
: "cc");
+}
+void cpu_enter_lowpower(void) +{
int id = 0;
/* check the cpuid */
asm("mrc p15, 0, %0, c0, c0, 0" : "=r"(id) : : "cc");
do you want to call it every time? doesn't better to run it once and use the variable? or make function pointer and use it.
if ((id & 0xffffffff) == 0x411fc090)
ca9_enter_lowpower();
else
pr_warn(KERN_WARNING "Unknown CPU type\n");
+}
Thank you, Kyungmin Park
-- 1.7.9.5
linaro-dev mailing list linaro-dev@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-dev
Generic arm cpu hotplug related functions are moved to core hotplug code, remove the functions from the platform code.
Signed-off-by: Sanjay Singh Rawat sanjay.rawat@linaro.org --- arch/arm/mach-imx/hotplug.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-)
diff --git a/arch/arm/mach-imx/hotplug.c b/arch/arm/mach-imx/hotplug.c index 3daf1ed..280c6f3 100644 --- a/arch/arm/mach-imx/hotplug.c +++ b/arch/arm/mach-imx/hotplug.c @@ -14,30 +14,10 @@ #include <linux/jiffies.h> #include <asm/cp15.h> #include <asm/proc-fns.h> +#include <asm/hotplug.h>
#include "common.h"
-static inline void cpu_enter_lowpower(void) -{ - unsigned int v; - - asm volatile( - "mcr p15, 0, %1, c7, c5, 0\n" - " mcr p15, 0, %1, c7, c10, 4\n" - /* - * Turn off coherency - */ - " mrc p15, 0, %0, c1, c0, 1\n" - " bic %0, %0, %3\n" - " mcr p15, 0, %0, c1, c0, 1\n" - " mrc p15, 0, %0, c1, c0, 0\n" - " bic %0, %0, %2\n" - " mcr p15, 0, %0, c1, c0, 0\n" - : "=&r" (v) - : "r" (0), "Ir" (CR_C), "Ir" (0x40) - : "cc"); -} - /* * platform-specific code to shutdown a CPU *
Please read back on this list for my comments about such moves of this very code. You're not the first.
On Mon, May 20, 2013 at 12:03:24PM +0530, Sanjay Singh Rawat wrote:
Generic arm cpu hotplug related functions are moved to core hotplug code, remove the functions from the platform code.
Signed-off-by: Sanjay Singh Rawat sanjay.rawat@linaro.org
arch/arm/mach-imx/hotplug.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-)
diff --git a/arch/arm/mach-imx/hotplug.c b/arch/arm/mach-imx/hotplug.c index 3daf1ed..280c6f3 100644 --- a/arch/arm/mach-imx/hotplug.c +++ b/arch/arm/mach-imx/hotplug.c @@ -14,30 +14,10 @@ #include <linux/jiffies.h> #include <asm/cp15.h> #include <asm/proc-fns.h> +#include <asm/hotplug.h> #include "common.h" -static inline void cpu_enter_lowpower(void) -{
- unsigned int v;
- asm volatile(
"mcr p15, 0, %1, c7, c5, 0\n"
- " mcr p15, 0, %1, c7, c10, 4\n"
- /*
* Turn off coherency
*/
- " mrc p15, 0, %0, c1, c0, 1\n"
- " bic %0, %0, %3\n"
- " mcr p15, 0, %0, c1, c0, 1\n"
- " mrc p15, 0, %0, c1, c0, 0\n"
- " bic %0, %0, %2\n"
- " mcr p15, 0, %0, c1, c0, 0\n"
: "=&r" (v)
: "r" (0), "Ir" (CR_C), "Ir" (0x40)
: "cc");
-}
/*
- platform-specific code to shutdown a CPU
-- 1.7.9.5
linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Generic arm cpu hotplug related functions are moved to core hotplug code, remove the functions from the platform code.
Signed-off-by: Sanjay Singh Rawat sanjay.rawat@linaro.org --- arch/arm/mach-realview/hotplug.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-)
diff --git a/arch/arm/mach-realview/hotplug.c b/arch/arm/mach-realview/hotplug.c index ac22dd4..a48cc71 100644 --- a/arch/arm/mach-realview/hotplug.c +++ b/arch/arm/mach-realview/hotplug.c @@ -14,42 +14,7 @@
#include <asm/cp15.h> #include <asm/smp_plat.h> - -static inline void cpu_enter_lowpower(void) -{ - unsigned int v; - - asm volatile( - " mcr p15, 0, %1, c7, c5, 0\n" - " mcr p15, 0, %1, c7, c10, 4\n" - /* - * Turn off coherency - */ - " mrc p15, 0, %0, c1, c0, 1\n" - " bic %0, %0, #0x20\n" - " mcr p15, 0, %0, c1, c0, 1\n" - " mrc p15, 0, %0, c1, c0, 0\n" - " bic %0, %0, %2\n" - " mcr p15, 0, %0, c1, c0, 0\n" - : "=&r" (v) - : "r" (0), "Ir" (CR_C) - : "cc"); -} - -static inline void cpu_leave_lowpower(void) -{ - unsigned int v; - - asm volatile( "mrc p15, 0, %0, c1, c0, 0\n" - " orr %0, %0, %1\n" - " mcr p15, 0, %0, c1, c0, 0\n" - " mrc p15, 0, %0, c1, c0, 1\n" - " orr %0, %0, #0x20\n" - " mcr p15, 0, %0, c1, c0, 1\n" - : "=&r" (v) - : "Ir" (CR_C) - : "cc"); -} +#include <asm/hotplug.h>
static inline void platform_do_lowpower(unsigned int cpu, int *spurious) {
Generic arm cpu hotplug related functions are moved to core hotplug code, remove the functions from the platform code.
Signed-off-by: Sanjay Singh Rawat sanjay.rawat@linaro.org --- arch/arm/mach-spear/hotplug.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-)
diff --git a/arch/arm/mach-spear/hotplug.c b/arch/arm/mach-spear/hotplug.c index d97749c..988a9a6 100644 --- a/arch/arm/mach-spear/hotplug.c +++ b/arch/arm/mach-spear/hotplug.c @@ -15,42 +15,7 @@ #include <linux/smp.h> #include <asm/cp15.h> #include <asm/smp_plat.h> - -static inline void cpu_enter_lowpower(void) -{ - unsigned int v; - - asm volatile( - " mcr p15, 0, %1, c7, c5, 0\n" - " dsb\n" - /* - * Turn off coherency - */ - " mrc p15, 0, %0, c1, c0, 1\n" - " bic %0, %0, #0x20\n" - " mcr p15, 0, %0, c1, c0, 1\n" - " mrc p15, 0, %0, c1, c0, 0\n" - " bic %0, %0, %2\n" - " mcr p15, 0, %0, c1, c0, 0\n" - : "=&r" (v) - : "r" (0), "Ir" (CR_C) - : "cc", "memory"); -} - -static inline void cpu_leave_lowpower(void) -{ - unsigned int v; - - asm volatile("mrc p15, 0, %0, c1, c0, 0\n" - " orr %0, %0, %1\n" - " mcr p15, 0, %0, c1, c0, 0\n" - " mrc p15, 0, %0, c1, c0, 1\n" - " orr %0, %0, #0x20\n" - " mcr p15, 0, %0, c1, c0, 1\n" - : "=&r" (v) - : "Ir" (CR_C) - : "cc"); -} +#include <asm/hotplug.h>
static inline void spear13xx_do_lowpower(unsigned int cpu, int *spurious) {
Please write spear as SPEAr.
On 20 May 2013 12:03, Sanjay Singh Rawat sanjay.rawat@linaro.org wrote:
Generic arm cpu hotplug related functions are moved to core hotplug code, remove the functions from the platform code.
Signed-off-by: Sanjay Singh Rawat sanjay.rawat@linaro.org
arch/arm/mach-spear/hotplug.c | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-)
diff --git a/arch/arm/mach-spear/hotplug.c b/arch/arm/mach-spear/hotplug.c index d97749c..988a9a6 100644 --- a/arch/arm/mach-spear/hotplug.c +++ b/arch/arm/mach-spear/hotplug.c @@ -15,42 +15,7 @@ #include <linux/smp.h> #include <asm/cp15.h> #include <asm/smp_plat.h>
-static inline void cpu_enter_lowpower(void) -{
unsigned int v;
asm volatile(
" mcr p15, 0, %1, c7, c5, 0\n"
" dsb\n"
/*
* Turn off coherency
*/
" mrc p15, 0, %0, c1, c0, 1\n"
" bic %0, %0, #0x20\n"
" mcr p15, 0, %0, c1, c0, 1\n"
" mrc p15, 0, %0, c1, c0, 0\n"
" bic %0, %0, %2\n"
" mcr p15, 0, %0, c1, c0, 0\n"
: "=&r" (v)
: "r" (0), "Ir" (CR_C)
: "cc", "memory");
-}
-static inline void cpu_leave_lowpower(void) -{
unsigned int v;
asm volatile("mrc p15, 0, %0, c1, c0, 0\n"
" orr %0, %0, %1\n"
" mcr p15, 0, %0, c1, c0, 0\n"
" mrc p15, 0, %0, c1, c0, 1\n"
" orr %0, %0, #0x20\n"
" mcr p15, 0, %0, c1, c0, 1\n"
: "=&r" (v)
: "Ir" (CR_C)
: "cc");
-}
I am not the best at assembly code but I can see that the two codes (here and hotplug.c) are slightly different.
How can we ensure if this patch is okay?
Generic arm cpu hotplug related functions are moved to core hotplug code, remove the functions from the platform code.
Signed-off-by: Sanjay Singh Rawat sanjay.rawat@linaro.org --- arch/arm/mach-vexpress/hotplug.c | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-)
diff --git a/arch/arm/mach-vexpress/hotplug.c b/arch/arm/mach-vexpress/hotplug.c index f0ce6b8..cca1361 100644 --- a/arch/arm/mach-vexpress/hotplug.c +++ b/arch/arm/mach-vexpress/hotplug.c @@ -14,43 +14,7 @@
#include <asm/smp_plat.h> #include <asm/cp15.h> - -static inline void cpu_enter_lowpower(void) -{ - unsigned int v; - - asm volatile( - "mcr p15, 0, %1, c7, c5, 0\n" - " mcr p15, 0, %1, c7, c10, 4\n" - /* - * Turn off coherency - */ - " mrc p15, 0, %0, c1, c0, 1\n" - " bic %0, %0, %3\n" - " mcr p15, 0, %0, c1, c0, 1\n" - " mrc p15, 0, %0, c1, c0, 0\n" - " bic %0, %0, %2\n" - " mcr p15, 0, %0, c1, c0, 0\n" - : "=&r" (v) - : "r" (0), "Ir" (CR_C), "Ir" (0x40) - : "cc"); -} - -static inline void cpu_leave_lowpower(void) -{ - unsigned int v; - - asm volatile( - "mrc p15, 0, %0, c1, c0, 0\n" - " orr %0, %0, %1\n" - " mcr p15, 0, %0, c1, c0, 0\n" - " mrc p15, 0, %0, c1, c0, 1\n" - " orr %0, %0, %2\n" - " mcr p15, 0, %0, c1, c0, 1\n" - : "=&r" (v) - : "Ir" (CR_C), "Ir" (0x40) - : "cc"); -} +#include <asm/hotplug.h>
static inline void platform_do_lowpower(unsigned int cpu, int *spurious) {
Generic arm cpu hotplug related functions are moved to core hotplug code, Exynos-4 is having Cortex-A9, remove the functions from the platform code.
Signed-off-by: Sanjay Singh Rawat sanjay.rawat@linaro.org --- arch/arm/mach-exynos/hotplug.c | 40 ++-------------------------------------- 1 file changed, 2 insertions(+), 38 deletions(-)
diff --git a/arch/arm/mach-exynos/hotplug.c b/arch/arm/mach-exynos/hotplug.c index af90cfa..3489760 100644 --- a/arch/arm/mach-exynos/hotplug.c +++ b/arch/arm/mach-exynos/hotplug.c @@ -21,30 +21,10 @@
#include <mach/regs-pmu.h> #include <plat/cpu.h> +#include <asm/hotplug.h>
#include "common.h"
-static inline void cpu_enter_lowpower_a9(void) -{ - unsigned int v; - - asm volatile( - " mcr p15, 0, %1, c7, c5, 0\n" - " mcr p15, 0, %1, c7, c10, 4\n" - /* - * Turn off coherency - */ - " mrc p15, 0, %0, c1, c0, 1\n" - " bic %0, %0, %3\n" - " mcr p15, 0, %0, c1, c0, 1\n" - " mrc p15, 0, %0, c1, c0, 0\n" - " bic %0, %0, %2\n" - " mcr p15, 0, %0, c1, c0, 0\n" - : "=&r" (v) - : "r" (0), "Ir" (CR_C), "Ir" (0x40) - : "cc"); -} - static inline void cpu_enter_lowpower_a15(void) { unsigned int v; @@ -74,22 +54,6 @@ static inline void cpu_enter_lowpower_a15(void) dsb(); }
-static inline void cpu_leave_lowpower(void) -{ - unsigned int v; - - asm volatile( - "mrc p15, 0, %0, c1, c0, 0\n" - " orr %0, %0, %1\n" - " mcr p15, 0, %0, c1, c0, 0\n" - " mrc p15, 0, %0, c1, c0, 1\n" - " orr %0, %0, %2\n" - " mcr p15, 0, %0, c1, c0, 1\n" - : "=&r" (v) - : "Ir" (CR_C), "Ir" (0x40) - : "cc"); -} - static inline void platform_do_lowpower(unsigned int cpu, int *spurious) { for (;;) { @@ -144,7 +108,7 @@ void __ref exynos_cpu_die(unsigned int cpu) if ((primary_part & 0xfff0) == 0xc0f0) cpu_enter_lowpower_a15(); else - cpu_enter_lowpower_a9(); + cpu_enter_lowpower();
platform_do_lowpower(cpu, &spurious);