alpha: Remove IO memcpy and memset
PATCH 1/1 alpha: Remove IO memcpy and memset
Recently a new IO memcpy and memset was added in libs/iomem_copy.c. So, remove the alpha specific implementations and use the one from the lib.
--- arch/alpha/include/asm/io.h | 22 ----- arch/alpha/include/asm/vga.h | 2 +- arch/alpha/kernel/io.c | 171 ----------------------------------- 3 files changed, 1 insertion(+), 194 deletions(-)
arch/alpha/include/asm/io.h +0 -22
@@ -587,28 +587,6 @@ extern inline u64 readq_relaxed(const volatile void __iomem *addr)#define writel_relaxed writel#define writeq_relaxed writeq -/* -* String version of IO memory access ops: -*/ -extern void memcpy_fromio (void *,const volatile void __iomem *,long ); -extern void memcpy_toio (volatile void __iomem *,const void *,long ); -extern void _memset_c_io (volatile void __iomem *,unsigned long ,long ); - -static inline void memset_io (volatile void __iomem *addr,u8 c,long len) -{ -_memset_c_io (addr,0x0101010101010101UL * c, len); -} - -#define __HAVE_ARCH_MEMSETW_IO -static inline void memsetw_io (volatile void __iomem *addr,u16 c,long len) -{ -_memset_c_io (addr,0x0001000100010001UL * c, len); -} - -#define memset_io memset_io -#define memcpy_fromio memcpy_fromio -#define memcpy_toio memcpy_toio -/* * String versions of in/out ops: */
arch/alpha/include/asm/vga.h +1 -1
@@ -34,7 +34,7 @@ static inline u16 scr_readw(volatile const u16 *addr)static inline void scr_memsetw (u16 *s,u16 c,unsigned int count) {if (__is_ioaddr (s)) -memsetw_io ((u16 __iomem *) s, c, count); +memset_io ((u16 __iomem *) s, c, count);else memset16 (s, c, count /2 ); }
arch/alpha/kernel/io.c +0 -171
177 lines not on this page · raw message
Signature · 1 line
2.34.1
arch/alpha/include/asm/vga.h static inline u16 scr_readw(volatile const u16 *addr) · line 40
Quoted 13 lines · Julian Vetter
arch/alpha/include/asm/vga.h +1
-1@@ -34,7 +34,7 @@ static inline u16 scr_readw(volatile const u16 *addr)static inline void scr_memsetw (u16 *s,u16 c,unsigned int count) {if (__is_ioaddr (s)) -memsetw_io ((u16 __iomem *) s, c, count); +memset_io ((u16 __iomem *) s, c, count);else memset16 (s, c, count /2 ); }
I don't think this is a correct conversion, memset_io() will set every byte to the same value and ignore the upper half of the 16-bit value.
On all other architectures, scr_memsetw() turns into a memset(), but that does not work on older alpha machines since MMIO access has additional constraints.
scr_memsetw() is the only caller of _memset_c_io(), so I think it makes sense to move both inside of the CONFIG_VGA_CONSOLE block along with scr_memcpyw() and scr_memmovew().
Quoted 13 lines
arch/alpha/include/asm/vga.h +0
-13-void _memset_c_io (volatile void __iomem *to,unsigned long c,long count) -{ -/* Handle any initial odd byte */ -if (count >0 && ((u64 )to &1 )) { -__raw_writeb (c, to); - to++; - count--; - } - -/* Handle any initial odd halfword */ -if (count >=2 && ((u64 )to &2 )) { -__raw_writew (c, to); - to +=2 ;
arch/alpha/include/asm/vga.h
Quoted 10 lines
arch/alpha/include/asm/vga.h +0
-10- count -=2 ; - } - -/* Handle any initial odd word */ -if (count >=4 && ((u64 )to &4 )) { -__raw_writel (c, to); - to +=4 ; - count -=4 ; - } -
For this function I think it's close enough, the generic version is slightly simpler since it skips the 2-byte and 4-byte stores between single-byte and 'long' stores.
Arnd
Quoted 1 line · Julian Vetter
Recently a new IO memcpy and memset was added in
libs/iomem_copy.c. So,
^
This has to be lib/iomem_copy.c.
Quoted 1 line
remove the alpha specific implementations and use the one from the lib.
You're dropping the memory barriers, which the generic code doesn't have,
so should we agree to switch to the generic version it has to be confirmed what the right course of action is:
1. Use wrapper calls with memory barriers.
2. Add memory barriers to generic code.
3. Conclude that dropping is correct and adjust the callers where applicable.
4. Something else maybe.
See below for the actual places.
Quoted 15 lines
arch/alpha/kernel/io.c +0
-7@@ -476,177 +476,6 @@ void outsl(unsigned long port, const void *src, unsigned long count)EXPORT_SYMBOL (iowrite32_rep);EXPORT_SYMBOL (outsl); - -/* -* Copy data from IO memory space to "real" memory space. -* This needs to be optimized. -*/ -void memcpy_fromio (void *to,const volatile void __iomem *from,long count) -{
[...]
arch/alpha/kernel/io.c void outsl(unsigned long port, const void *src, unsigned long count) · line 528
Quoted 7 lines
arch/alpha/kernel/io.c +0
-7-while (count >0 ) { - *(u8 *) to =__raw_readb (from); - count--; - to++; - from++; - } -mb ();
Here...
Quoted 2 lines
arch/alpha/kernel/io.c +0
-2-void memcpy_toio (volatile void __iomem *to,const void *from,long count) -{
[...]
arch/alpha/kernel/io.c void outsl(unsigned long port, const void *src, unsigned long count) · line 583
Quoted 7 lines
arch/alpha/kernel/io.c +0
-7-while (count >0 ) { -__raw_writeb (*(const u8 *) from, to); - count--; - to++; - from++; - } -mb ();
... here...
Quoted 2 lines
arch/alpha/kernel/io.c +0
-2-void _memset_c_io (volatile void __iomem *to,unsigned long c,long count) -{
[...]
arch/alpha/kernel/io.c void outsl(unsigned long port, const void *src, unsigned long count) · line 645
Quoted 5 lines
arch/alpha/kernel/io.c +0
-5-/* And finally, one last byte.. */ -if (count) { -__raw_writeb (c, to); - } -mb ();
... and here.
Maciej