From: Julian Vetter <julian@outer-limits.org>
To: Russell King <linux@armlinux.org.uk>
Cc: Linus Walleij <linusw@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Julian Vetter <julian@outer-limits.org>
Subject: [PATCH] ARM: fix big-endian check for IO memcpy and memset
Date: Fri, 30 Oct 2026 09:29:32 +0100 [thread overview]
Message-ID: <20261030082932.193164-1-julian@outer-limits.org> (raw)
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
reply other threads:[~2026-10-30 8:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261030082932.193164-1-julian@outer-limits.org \
--to=julian@outer-limits.org \
--cc=arnd@arndb.de \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®