ARM: fix big-endian check for IO memcpy and memset
PATCH 1/1 ARM: fix big-endian check for IO memcpy and memset
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.
---
This replaces my earlier patch that removed the byte-wise helpers:
https://lore.kernel.org/all/[email protected]/
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(-)
arch/arm/include/asm/io.h +1 -1
@@ -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) {
Signature · 1 line
2.53.0
Quoted 13 lines · 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 usingmmioset()andmmiocpy()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.
Quoted 8 lines
Switching big-endian builds to the generic implementation from
lib/iomem_copy.cinstead 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 <[email protected]>
Please put this patch into Russell's patch tracker.
Yours,
Linus Walleij