Skip to contentSkip to conversation

arm: plat-samsung: check processor type before cache restoration in resume

PATCH Superseded Inderpal Singh 2 participants 5 messages Feb 26, 2013

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 arm: plat-samsung: check processor type before cache restoration in resume

Only cortex-a9 based samsung platforms have l2x0 cache controller. Hence check the same before restoring the cache in resume.

This is needed for single kernel image.

---
changes in v2:
- check processor midr instead of checking all soc ids as suggested by Kukjin

 arch/arm/mach-exynos/common.c           |    4 ++++
 arch/arm/plat-samsung/include/plat/pm.h |    1 +
 arch/arm/plat-samsung/s5p-sleep.S       |   10 ++++++++++
 3 files changed, 15 insertions(+)
arch/arm/mach-exynos/common.c +4 -0
index c4b2071..5585325 100644
@@ -31,6 +31,7 @@
 #include <asm/mach/map.h>
 #include <asm/mach/irq.h>
 #include <asm/cacheflush.h>
+#include <asm/cputype.h>
 
 #include <mach/regs-irq.h>
 #include <mach/regs-pmu.h>
@@ -53,6 +54,7 @@
 #include "common.h"
 #define L2_AUX_VAL 0x7C470001
 #define L2_AUX_MASK 0xC200ffff
+#define CPU_MASK	0xff0ffff0
 
 static const char name_exynos4210[] = "EXYNOS4210";
 static const char name_exynos4212[] = "EXYNOS4212";
@@ -716,6 +718,8 @@ static int __init exynos4_l2x0_cache_init(void)
 	if (soc_is_exynos5250() || soc_is_exynos5440())
 		return 0;
 
+	cpu_midr = read_cpuid_id() & CPU_MASK;
+
 	ret = l2x0_of_init(L2_AUX_VAL, L2_AUX_MASK);
 	if (!ret) {
 		l2x0_regs_phys = virt_to_phys(&l2x0_saved_regs);
arch/arm/plat-samsung/include/plat/pm.h +1 -0
index f6fcade..532f5d7 100644
@@ -184,3 +184,4 @@ extern void samsung_pm_save_gpios(void);
 
 extern void s3c_pm_save_core(void);
 extern void s3c_pm_restore_core(void);
+extern unsigned long cpu_midr;
arch/arm/plat-samsung/s5p-sleep.S +10 -0
index bdf6dad..3b350d0 100644
@@ -25,6 +25,8 @@
 #include <asm/asm-offsets.h>
 #include <asm/hardware/cache-l2x0.h>
 
+#define CPU_CORTEX_A9		0x410FC090
+
 /*
  *	 The following code is located into the .data section. This is to
  *	 allow l2x0_regs_phys to be accessed with a relative load while we
@@ -51,6 +53,11 @@
 
 ENTRY(s3c_cpu_resume)
 #ifdef CONFIG_CACHE_L2X0
+	adr	r0, cpu_midr
+	ldr	r1, [r0]
+	ldr	r0, =CPU_CORTEX_A9
+	cmp	r1, r0
+	bne	resume_l2on
 	adr	r0, l2x0_regs_phys
 	ldr	r0, [r0]
 	ldr	r1, [r0, #L2X0_R_PHY_BASE]
@@ -77,4 +84,7 @@ ENDPROC(s3c_cpu_resume)
 	.globl l2x0_regs_phys
 l2x0_regs_phys:
 	.long	0
+	.globl cpu_midr
+cpu_midr:
+	.long	0
 #endif
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/1 arm: plat-samsung: check processor type before cache restoration in resume

Quoted 2 lines · Inderpal Singh

Only cortex-a9 based samsung platforms have l2x0 cache controller. Hence check the same before restoring the cache in resume.

Why is this patch soo complicated? Can't you read the CPUs MIDR register from assembly code?

#2 lore raw

PATCH v2 1/1 arm: plat-samsung: check processor type before cache restoration in resume

Quoted 6 lines · Russell King - ARM Linux
Quoted 2 lines · Inderpal Singh

Only cortex-a9 based samsung platforms have l2x0 cache controller. Hence check the same before restoring the cache in resume.

Why is this patch soo complicated? Can't you read the CPUs MIDR register from assembly code?

I wanted to read MIDR only once thats why didn't read in resume function in assembly as the same resume function gets used in cpuidle path.

Regards,
Inder

#3 lore raw

PATCH v2 1/1 arm: plat-samsung: check processor type before cache restoration in resume

Quoted 6 lines · Inderpal Singh
Quoted 4 lines · Russell King - ARM Linux
Quoted 2 lines · Inderpal Singh

Only cortex-a9 based samsung platforms have l2x0 cache controller. Hence check the same before restoring the cache in resume.

Quoted 6 lines
Quoted 2 lines

Why is this patch soo complicated? Can't you read the CPUs MIDR register from assembly code?

I wanted to read MIDR only once thats why didn't read in resume function in assembly as the same resume function gets used in cpuidle path.

It's more expensive to load it from memory than to read it from CP15.

#4 lore raw

PATCH v2 1/1 arm: plat-samsung: check processor type before cache restoration in resume

Quoted 7 lines · Russell King - ARM Linux
Quoted 6 lines · Inderpal Singh
Quoted 4 lines · Russell King - ARM Linux
Quoted 2 lines · Inderpal Singh

Only cortex-a9 based samsung platforms have l2x0 cache controller. Hence check the same before restoring the cache in resume.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Why is this patch soo complicated? Can't you read the CPUs MIDR register from assembly code?

I wanted to read MIDR only once thats why didn't read in resume function in assembly as the same resume function gets used in cpuidle path.

It's more expensive to load it from memory than to read it from CP15.

Ok, I will change it to read from CP15 in assembly and resubmit the patch. Thanks for the review.

Regards,
Inder