Skip to contentSkip to conversation

ARM: imx6: move v7_cpu_resume() into suspend-imx6.S

PATCH New Shawn Guo 3 participants 8 messages Feb 26, 2014 – Feb 27, 2014

Subsystems (3)
lore
Share & tools
lore

Shawn Guo

author
#0 lore raw

PATCH 1/4 ARM: imx6: move v7_cpu_resume() into suspend-imx6.S

The suspend-imx6.S is introduced recently for suspend low-level assembly code. Since function v7_cpu_resume() is only used by suspend support, it makes sense to move the function into suspend-imx6.S, and control the build of the file with CONFIG_SUSPEND option.

---
 arch/arm/mach-imx/Makefile       |    5 +++--
 arch/arm/mach-imx/common.h       |    8 +++++++-
 arch/arm/mach-imx/headsmp.S      |   36 ------------------------------------
 arch/arm/mach-imx/suspend-imx6.S |   33 +++++++++++++++++++++++++++++++++
 4 files changed, 43 insertions(+), 39 deletions(-)
arch/arm/mach-imx/Makefile +3 -2
index 979ff84..b4c19cd 100644
@@ -103,9 +103,10 @@ obj-$(CONFIG_SOC_IMX6Q) += clk-imx6q.o mach-imx6q.o
 obj-$(CONFIG_SOC_IMX6SL) += clk-imx6sl.o mach-imx6sl.o
 
 AFLAGS_suspend-imx6.o :=-Wa,-march=armv7-a
-obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o headsmp.o suspend-imx6.o
+obj-$(CONFIG_SUSPEND) += suspend-imx6.o
+obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o headsmp.o
 # i.MX6SL reuses i.MX6Q code
-obj-$(CONFIG_SOC_IMX6SL) += pm-imx6q.o headsmp.o suspend-imx6.o
+obj-$(CONFIG_SOC_IMX6SL) += pm-imx6q.o headsmp.o
 
 # i.MX5 based machines
 obj-$(CONFIG_MACH_MX51_BABBAGE) += mach-mx51_babbage.o
arch/arm/mach-imx/common.h +7 -1
index 91d69cc..b5241ea 100644
@@ -116,7 +116,6 @@ void imx_enable_cpu(int cpu, bool enable);
 void imx_set_cpu_jump(int cpu, void *jump_addr);
 u32 imx_get_cpu_arg(int cpu);
 void imx_set_cpu_arg(int cpu, u32 arg);
-void v7_cpu_resume(void);
 #ifdef CONFIG_SMP
 void v7_secondary_startup(void);
 void imx_scu_map_io(void);
@@ -145,7 +144,14 @@ void imx6sl_set_wait_clk(bool enter);
 void imx_cpu_die(unsigned int cpu);
 int imx_cpu_kill(unsigned int cpu);
 
+#ifdef CONFIG_SUSPEND
+void v7_cpu_resume(void);
 void imx6_suspend(void __iomem *ocram_vbase);
+#else
+static inline void v7_cpu_resume(void) {}
+static inline void imx6_suspend(void __iomem *ocram_vbase) {}
+#endif
+
 void imx6q_pm_init(void);
 void imx6dl_pm_init(void);
 void imx6sl_pm_init(void);
arch/arm/mach-imx/headsmp.S +0 -36
index 627f16f..e4b9fed 100644
@@ -12,8 +12,6 @@
 
 #include <linux/linkage.h>
 #include <linux/init.h>
-#include <asm/asm-offsets.h>
-#include <asm/hardware/cache-l2x0.h>
 
 	.section ".text.head", "ax"
 
@@ -35,37 +33,3 @@ ENTRY(v7_secondary_startup)
 	b	secondary_startup
 ENDPROC(v7_secondary_startup)
 #endif
-
-#ifdef CONFIG_ARM_CPU_SUSPEND
-/*
- * The following code must assume it is running from physical address
- * where absolute virtual addresses to the data section have to be
- * turned into relative ones.
- */
-
-#ifdef CONFIG_CACHE_L2X0
-	.macro	pl310_resume
-	adr	r0, l2x0_saved_regs_offset
-	ldr	r2, [r0]
-	add	r2, r2, r0
-	ldr	r0, [r2, #L2X0_R_PHY_BASE]	@ get physical base of l2x0
-	ldr	r1, [r2, #L2X0_R_AUX_CTRL]	@ get aux_ctrl value
-	str	r1, [r0, #L2X0_AUX_CTRL]	@ restore aux_ctrl
-	mov	r1, #0x1
-	str	r1, [r0, #L2X0_CTRL]		@ re-enable L2
-	.endm
-
-l2x0_saved_regs_offset:
-	.word	l2x0_saved_regs - .
-
-#else
-	.macro	pl310_resume
-	.endm
-#endif
-
-ENTRY(v7_cpu_resume)
-	bl	v7_invalidate_l1
-	pl310_resume
-	b	cpu_resume
-ENDPROC(v7_cpu_resume)
-#endif
arch/arm/mach-imx/suspend-imx6.S +33 -0
index 81b9d1d..20048ff 100644
@@ -10,6 +10,7 @@
  */
 
 #include <linux/linkage.h>
+#include <asm/asm-offsets.h>
 #include <asm/hardware/cache-l2x0.h>
 #include "hardware.h"
 
@@ -326,3 +327,35 @@ resume:
 
 	mov	pc, lr
 ENDPROC(imx6_suspend)
+
+/*
+ * The following code must assume it is running from physical address
+ * where absolute virtual addresses to the data section have to be
+ * turned into relative ones.
+ */
+
+#ifdef CONFIG_CACHE_L2X0
+	.macro	pl310_resume
+	adr	r0, l2x0_saved_regs_offset
+	ldr	r2, [r0]
+	add	r2, r2, r0
+	ldr	r0, [r2, #L2X0_R_PHY_BASE]	@ get physical base of l2x0
+	ldr	r1, [r2, #L2X0_R_AUX_CTRL]	@ get aux_ctrl value
+	str	r1, [r0, #L2X0_AUX_CTRL]	@ restore aux_ctrl
+	mov	r1, #0x1
+	str	r1, [r0, #L2X0_CTRL]		@ re-enable L2
+	.endm
+
+l2x0_saved_regs_offset:
+	.word	l2x0_saved_regs - .
+
+#else
+	.macro	pl310_resume
+	.endm
+#endif
+
+ENTRY(v7_cpu_resume)
+	bl	v7_invalidate_l1
+	pl310_resume
+	b	cpu_resume
+ENDPROC(v7_cpu_resume)
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 2/4 ARM: imx6: build headsmp.o only on CONFIG_SMP

With v7_cpu_resume() being moved out of headsmp.S, all the remaining code in the file is only needed by CONFIG_SMP build. So we can control the build of headsmp.o with only obj-$(CONFIG_SMP) now.

---
 arch/arm/mach-imx/Makefile  |    4 ++--
 arch/arm/mach-imx/headsmp.S |    2 --
 2 files changed, 2 insertions(+), 4 deletions(-)
arch/arm/mach-imx/Makefile +2 -2
index b4c19cd..9c776a0 100644
@@ -104,9 +104,9 @@ obj-$(CONFIG_SOC_IMX6SL) += clk-imx6sl.o mach-imx6sl.o
 
 AFLAGS_suspend-imx6.o :=-Wa,-march=armv7-a
 obj-$(CONFIG_SUSPEND) += suspend-imx6.o
-obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o headsmp.o
+obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o
 # i.MX6SL reuses i.MX6Q code
-obj-$(CONFIG_SOC_IMX6SL) += pm-imx6q.o headsmp.o
+obj-$(CONFIG_SOC_IMX6SL) += pm-imx6q.o
 
 # i.MX5 based machines
 obj-$(CONFIG_MACH_MX51_BABBAGE) += mach-mx51_babbage.o
arch/arm/mach-imx/headsmp.S +0 -2
index e4b9fed..6e1a56d 100644
@@ -15,7 +15,6 @@
 
 	.section ".text.head", "ax"
 
-#ifdef CONFIG_SMP
 diag_reg_offset:
 	.word	g_diag_reg - .
 
@@ -32,4 +31,3 @@ ENTRY(v7_secondary_startup)
 	set_diag_reg
 	b	secondary_startup
 ENDPROC(v7_secondary_startup)
-#endif
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/4 ARM: imx6: build headsmp.o only on CONFIG_SMP

arch/arm/mach-imx/headsmp.S line 16

Quoted 7 lines · Shawn Guo
arch/arm/mach-imx/headsmp.S +0 -0
index e4b9fed..6e1a56d 100644
@@ -15,7 +15,6 @@
 
 	.section ".text.head", "ax"

While you're here, can you please fix the above section name. I think a .text will do just fine here.

Signature · 2 lines
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
improving, and getting towards what was expected from it.
author
#3 lore raw

PATCH 2/4 ARM: imx6: build headsmp.o only on CONFIG_SMP

Quoted 11 lines · Russell King - ARM Linux

arch/arm/mach-imx/headsmp.S line 16

Quoted 7 lines · Shawn Guo
arch/arm/mach-imx/headsmp.S +0 -0
index e4b9fed..6e1a56d 100644
@@ -15,7 +15,6 @@
 
 	.section ".text.head", "ax"

While you're here, can you please fix the above section name. I think a .text will do just fine here.

Indeed. I will post a patch for it shortly.

Shawn

author
#4 lore raw

PATCH 3/4 ARM: imx6: call suspend_set_ops() from suspend routine

In reply to Shawn Guo

Rename function imx6q_ocram_suspend_init() to imx6q_suspend_init() and call suspend_set_ops() from there. Now we get a centralized function for suspend initialization.

---
 arch/arm/mach-imx/pm-imx6q.c |   12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
arch/arm/mach-imx/pm-imx6q.c +5 -7
index a9a187d..2473ad4 100644
@@ -382,8 +382,7 @@ out:
 	return ret;
 }
 
-static int __init imx6q_ocram_suspend_init(const struct imx6_pm_socdata
-					*socdata)
+static int __init imx6q_suspend_init(const struct imx6_pm_socdata *socdata)
 {
 	phys_addr_t ocram_pbase;
 	struct device_node *node;
@@ -394,6 +393,8 @@ static int __init imx6q_ocram_suspend_init(const struct imx6_pm_socdata
 	int i, ret = 0;
 	const u32 *mmdc_offset_array;
 
+	suspend_set_ops(&imx6q_pm_ops);
+
 	if (!socdata) {
 		pr_warn("%s: invalid argument!\n", __func__);
 		return -EINVAL;
@@ -515,9 +516,9 @@ static void __init imx6_pm_common_init(const struct imx6_pm_socdata
 
 	WARN_ON(!ccm_base);
 
-	ret = imx6q_ocram_suspend_init(socdata);
+	ret = imx6q_suspend_init(socdata);
 	if (ret)
-		pr_warn("%s: failed to initialize ocram suspend %d!\n",
+		pr_warn("%s: No DDR LPM support with suspend %d!\n",
 			__func__, ret);
 
 	/*
@@ -531,9 +532,6 @@ static void __init imx6_pm_common_init(const struct imx6_pm_socdata
 	if (!IS_ERR(gpr))
 		regmap_update_bits(gpr, IOMUXC_GPR1, IMX6Q_GPR1_GINT,
 				   IMX6Q_GPR1_GINT);
-
-
-	suspend_set_ops(&imx6q_pm_ops);
 }
 
 void __init imx6q_pm_init(void)
Signature · 1 line
1.7.9.5
author
#5 lore raw

PATCH 4/4 ARM: imx6: do not call imx6q_suspend_init() with !CONFIG_SUSPEND

In reply to Shawn Guo

When CONFIG_SUSPEND is not enabled, we should reasonably skip the call to imx6q_suspend_init().

---
 arch/arm/mach-imx/pm-imx6q.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
arch/arm/mach-imx/pm-imx6q.c +6 -4
index 2473ad4..16f0d24 100644
@@ -516,10 +516,12 @@ static void __init imx6_pm_common_init(const struct imx6_pm_socdata
 
 	WARN_ON(!ccm_base);
 
-	ret = imx6q_suspend_init(socdata);
-	if (ret)
-		pr_warn("%s: No DDR LPM support with suspend %d!\n",
-			__func__, ret);
+	if (IS_ENABLED(CONFIG_SUSPEND)) {
+		ret = imx6q_suspend_init(socdata);
+		if (ret)
+			pr_warn("%s: No DDR LPM support with suspend %d!\n",
+				__func__, ret);
+	}
 
 	/*
 	 * This is for SW workaround step #1 of ERR007265, see comments
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH 1/4 ARM: imx6: move v7_cpu_resume() into suspend-imx6.S

In reply to Shawn Guo

Review

Quoted 9 lines · Shawn Guo

AFLAGS_suspend-imx6.o :=-Wa,-march=armv7-a

(quoted diff) +3 -2
-obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o headsmp.o suspend-imx6.o
+obj-$(CONFIG_SUSPEND) += suspend-imx6.o
+obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o headsmp.o
 # i.MX6SL reuses i.MX6Q code
-obj-$(CONFIG_SOC_IMX6SL) += pm-imx6q.o headsmp.o suspend-imx6.o
+obj-$(CONFIG_SOC_IMX6SL) += pm-imx6q.o headsmp.o

I noticed a small bug during randconfig testing (starting to like my tests more recently):

You build suspend-imx6.o for all SoCs now when SUSPEND is enabled, so this will fail for an ARMv5-only configuration. You probably need something like

arch/arm/mach-imx/Makefile +3 -3
index 9c776a0..4dd45db 100644
@@ -103,10 +103,10 @@ obj-$(CONFIG_SOC_IMX6Q) += clk-imx6q.o mach-imx6q.o
 obj-$(CONFIG_SOC_IMX6SL) += clk-imx6sl.o mach-imx6sl.o
 
 AFLAGS_suspend-imx6.o :=-Wa,-march=armv7-a
-obj-$(CONFIG_SUSPEND) += suspend-imx6.o
-obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o
+imx6-$(CONFIG_SUSPEND) += suspend-imx6.o
+obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o $(imx6-y)
 # i.MX6SL reuses i.MX6Q code
-obj-$(CONFIG_SOC_IMX6SL) += pm-imx6q.o
+obj-$(CONFIG_SOC_IMX6SL) += pm-imx6q.o $(imx6-y)
 
 # i.MX5 based machines
 obj-$(CONFIG_MACH_MX51_BABBAGE) += mach-mx51_babbage.o

Arnd

author
#7 lore raw

PATCH 1/4 ARM: imx6: move v7_cpu_resume() into suspend-imx6.S

Quoted 13 lines · Arnd Bergmann

Review

Quoted 9 lines · Shawn Guo

AFLAGS_suspend-imx6.o :=-Wa,-march=armv7-a

(quoted diff) +3 -2
-obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o headsmp.o suspend-imx6.o
+obj-$(CONFIG_SUSPEND) += suspend-imx6.o
+obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o headsmp.o
 # i.MX6SL reuses i.MX6Q code
-obj-$(CONFIG_SOC_IMX6SL) += pm-imx6q.o headsmp.o suspend-imx6.o
+obj-$(CONFIG_SOC_IMX6SL) += pm-imx6q.o headsmp.o

I noticed a small bug during randconfig testing (starting to like my tests more recently):

Sorry for that.

Quoted 4 lines

You build suspend-imx6.o for all SoCs now when SUSPEND is enabled, so this will fail for an ARMv5-only configuration. You probably need something like

I received a report from 0-DAY kbuild test robot on this, and sent a small cleanup series which fixes the error along the way.

Shawn

[1] http://thread.gmane.org/gmane.linux.ports.arm.kernel/305262

Quoted 25 lines
arch/arm/mach-imx/Makefile +3 -3
index 9c776a0..4dd45db 100644
@@ -103,10 +103,10 @@ obj-$(CONFIG_SOC_IMX6Q) += clk-imx6q.o mach-imx6q.o
 obj-$(CONFIG_SOC_IMX6SL) += clk-imx6sl.o mach-imx6sl.o
 
 AFLAGS_suspend-imx6.o :=-Wa,-march=armv7-a
-obj-$(CONFIG_SUSPEND) += suspend-imx6.o
-obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o
+imx6-$(CONFIG_SUSPEND) += suspend-imx6.o
+obj-$(CONFIG_SOC_IMX6Q) += pm-imx6q.o $(imx6-y)
 # i.MX6SL reuses i.MX6Q code
-obj-$(CONFIG_SOC_IMX6SL) += pm-imx6q.o
+obj-$(CONFIG_SOC_IMX6SL) += pm-imx6q.o $(imx6-y)
 
 # i.MX5 based machines
 obj-$(CONFIG_MACH_MX51_BABBAGE) += mach-mx51_babbage.o

Arnd