Skip to contentSkip to conversation

pxa: fix memory coherency problem after relocation

PATCH New Mike Dunn 3 participants 6 messages Jun 21, 2013 – Jun 22, 2013 Arm (32-bit)

lore
Share & tools
lore

Mike Dunn

author
#0 lore raw

cover pxa: fix memory coherency problem after relocation

These patches fix a memory coherency problem that sometimes occurs on xscale after code relocation. The first patch changes the options passed to the compiler so that the __XSCALE__ macro is defined. This is used in the second patch to limit the change to xscale cores, where the necessary cache operations are performed before jumping to the relocated code.

Whether other cores need a similiar operation after code relocation remains an open question.

Thanks Albert.

Mike Dunn (2):
pxa: use -mcpu=xscale compiler option
pxa: fix memory coherency problem after relocation

 arch/arm/cpu/pxa/config.mk |    2 +-
 arch/arm/lib/relocate.S    |    9 +++++++++
 2 files changed, 10 insertions(+), 1 deletions(-)
Signature · 1 line
1.7.8.6
author
#1 lore raw

PATCH 1/2 pxa: use -mcpu=xscale compiler option

Pass '-mcpu=xscale' to the compiler instead of march and mtune. This will cause gcc to define the __XSCALE__ macro.

---
 arch/arm/cpu/pxa/config.mk |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/cpu/pxa/config.mk +1 -1
index 0bbe295..ea55859 100644
@@ -24,7 +24,7 @@
 
 PLATFORM_RELFLAGS += -fno-common -ffixed-r8 -msoft-float
 
-PLATFORM_CPPFLAGS += -march=armv5te -mtune=xscale
+PLATFORM_CPPFLAGS += -mcpu=xscale
 # =========================================================================
 #
 # Supply options according to compiler version
Signature · 1 line
1.7.8.6
#2 lore raw

PATCH 1/2 pxa: use -mcpu=xscale compiler option

Dear Mike Dunn,

Quoted 19 lines

Pass '-mcpu=xscale' to the compiler instead of march and mtune. This will cause gcc to define the __XSCALE__ macro.

---
 arch/arm/cpu/pxa/config.mk |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/cpu/pxa/config.mk +1 -1
index 0bbe295..ea55859 100644
@@ -24,7 +24,7 @@
 
 PLATFORM_RELFLAGS += -fno-common -ffixed-r8 -msoft-float
 
-PLATFORM_CPPFLAGS += -march=armv5te -mtune=xscale
+PLATFORM_CPPFLAGS += -mcpu=xscale
 #
Quoted 3 lines

=========================================================================
#
# Supply options according to compiler version

Best regards,
Marek Vasut

author
#3 lore raw

PATCH 2/2 pxa: fix memory coherency problem after relocation

In reply to Mike Dunn

On the xscale, the icache must be invalidated and the write buffers drained after writing code over the data bus, even if the caches are disabled. Tested on the pxa270.

---
 arch/arm/lib/relocate.S |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
arch/arm/lib/relocate.S +9 -0
index 4446da9..eedf314 100644
@@ -92,6 +92,15 @@ fixnext:
 
 relocate_done:
 
+#ifdef __XSCALE__
+	/*
+	 * On xscale, icache must be invalidated and write buffers drained,
+	 * even with cache disabled - 4.2.7 of xscale core developer's manual
+	 */
+	mcr	p15, 0, r0, c7, c7, 0	/* invalidate icache */
+	mcr	p15, 0, r0, c7, c10, 4	/* drain write buffer */
+#endif
+
 	/* ARMv4- don't know bx lr but the assembler fails to see that */
 
 #ifdef __ARM_ARCH_4__
Signature · 1 line
1.7.8.6
#4 lore raw

PATCH 2/2 pxa: fix memory coherency problem after relocation

Dear Mike Dunn,

Quoted 19 lines

On the xscale, the icache must be invalidated and the write buffers drained after writing code over the data bus, even if the caches are disabled. Tested on the pxa270.

---
 arch/arm/lib/relocate.S |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
arch/arm/lib/relocate.S +2 -0
index 4446da9..eedf314 100644
@@ -92,6 +92,15 @@ fixnext:
 
 relocate_done:
 
+#ifdef __XSCALE__
+	/*

arch/arm/lib/relocate.S fixnext: · line 106

Quoted 10 lines
arch/arm/lib/relocate.S +7 -0
+	 * On xscale, icache must be invalidated and write buffers drained,
+	 * even with cache disabled - 4.2.7 of xscale core developer's manual
+	 */
+	mcr	p15, 0, r0, c7, c7, 0	/* invalidate icache */
+	mcr	p15, 0, r0, c7, c10, 4	/* drain write buffer */
+#endif
+
 	/* ARMv4- don't know bx lr but the assembler fails to see that */
 
 #ifdef __ARM_ARCH_4__

Albert, do you want me to pick these or will you?

Best regards,
Marek Vasut

#5 lore raw

PATCH 2/2 pxa: fix memory coherency problem after relocation

Hi Marek,

Quoted 1 line · Marek Vasut

Albert, do you want me to pick these or will you?

Pick them and PR me.

Quoted 2 lines

Best regards,
Marek Vasut

Amicalement,

Signature · 1 line
Albert.