pxa: fix memory coherency problem after relocation
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
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
@@ -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
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.Signed-off-by Mike Dunn <[email protected]>--- arch/arm/cpu/pxa/config.mk | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)arch/arm/cpu/pxa/config.mk +1
-1@@ -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
PATCH 2/2 pxa: fix memory coherency problem after relocation
In reply to Mike DunnOn 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
@@ -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
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.
Signed-off-by Mike Dunn <[email protected]>--- arch/arm/lib/relocate.S | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)arch/arm/lib/relocate.S +2
-0@@ -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
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.