mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ARM: fix big-endian check for IO memcpy and memset
@ 2026-10-30  8:29 Julian Vetter
  0 siblings, 0 replies; only message in thread
From: Julian Vetter @ 2026-10-30  8:29 UTC (permalink / raw)
  To: Russell King
  Cc: Linus Walleij, Arnd Bergmann, linux-arm-kernel, linux-kernel,
	Julian Vetter

The commit 7ddfe625cbc1 ("ARM: optimize
memset_io()/memcpy_fromio()/memcpy_toio()") switched little-endian
builds to mmioset()/mmiocpy() and intended to keep the byte-wise
_memset_io()/_memcpy_fromio()/_memcpy_toio() for big-endian builds.
However, the check uses __ARMBE__, which is not defined by GCC. The
define used throughout the kernel is __ARMEB__ for big-endian ARM. So,
big-endian builds have been using mmioset() and mmiocpy() ever since.

This is a problem on ARMv5 BE32 platforms like IXP4xx, where word
accesses to IO memory can end up on different byte lanes than byte
accesses. Fix the typo, so big-endian builds use the correct byte-wise
implementations again, as originally intended.

Switching big-endian builds to the generic implementation from
lib/iomem_copy.c instead is not an option either, because it also uses
word accesses for the aligned parts of a buffer and thus has the same
byte lane problem on BE32. ARMv6/v7 BE8 mode would work with both, but
it is marked as broken and is expected to be removed, so it is not worth
treating it differently from BE32.

Signed-off-by: Julian Vetter <julian@outer-limits.org>
---
This replaces my earlier patch that removed the byte-wise helpers:
https://lore.kernel.org/all/20241203083838.3260036-1-jvetter@outer-limits.org/

I have done a compilation test with ixp4xx_defconfig and see that
drivers/pci/pci-sysfs.o and drivers/mtd/maps/map_funcs.o now call
_memcpy_fromio()/_memcpy_toio() instead of mmiocpy(). This is however
untested on hardware. I think the problem didn't show up on Linus' hw
test, because platform doesn't use those drivers.
---
 arch/arm/include/asm/io.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index e6bd9e79737c..50e142f817f5 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -308,7 +308,7 @@ extern void _memset_io(volatile void __iomem *, int, size_t);
 #define writesw(p,d,l)		__raw_writesw(p,d,l)
 #define writesl(p,d,l)		__raw_writesl(p,d,l)
 
-#ifndef __ARMBE__
+#ifndef __ARMEB__
 static inline void memset_io(volatile void __iomem *dst, unsigned c,
 	size_t count)
 {
-- 
2.53.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-30  8:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-30  8:29 [PATCH] ARM: fix big-endian check for IO memcpy and memset Julian Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®