alpha: rework use of memset_io, memsetw_io and scr_memsetw
PATCH v2 1/2 alpha: rework use of memset_io, memsetw_io and scr_memsetw
In order to prepare the alpha architecture to use the generic IO functions from lib/iomem_copy.c, rename _memset_c_io to memsetw_io. Then move scr_memsetw to io.c, along the scr_memcpyw and scr_memmovew, inside the CONFIG_VGA_CONSOLE.
---
Changes for V2:
- Split the patch into two:
- One that shuffles the memsetw_io and _memset_c_io around
- And one that removed the memcpy_fromio and memcpy_toio
--- arch/alpha/include/asm/io.h | 14 +------------ arch/alpha/include/asm/vga.h | 9 +-------- arch/alpha/kernel/io.c | 38 +++++++++++++++++++----------------- 3 files changed, 22 insertions(+), 39 deletions(-)
arch/alpha/include/asm/io.h +1 -13
@@ -592,20 +592,8 @@ extern inline u64 readq_relaxed(const volatile void __iomem *addr)*/ 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 ); +extern void memsetw_io (volatile void __iomem *to,u16 c,long count); -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
arch/alpha/include/asm/vga.h +1 -8
@@ -31,17 +31,10 @@ static inline u16 scr_readw(volatile const u16 *addr)return *addr; } -static inline void scr_memsetw (u16 *s,u16 c,unsigned int count) -{ -if (__is_ioaddr (s)) -memsetw_io ((u16 __iomem *) s, c, count); -else -memset16 (s, c, count /2 ); -} -/* Do not trust that the usage will be correct; analyze the arguments. */ extern void scr_memcpyw (u16 *d,const u16 *s,unsigned int count);extern void scr_memmovew (u16 *d,const u16 *s,unsigned int count); +extern void scr_memsetw (u16 *s,u16 c,unsigned int count);/* ??? These are currently only used for downloading character sets. As such, they don't need memory barriers. Is this all they are intended
arch/alpha/kernel/io.c +20 -18
@@ -585,29 +585,31 @@ void memcpy_toio(volatile void __iomem *to, const void *from, long count)EXPORT_SYMBOL (memcpy_toio); +#if IS_ENABLED (CONFIG_VGA_CONSOLE ) ||IS_ENABLED (CONFIG_MDA_CONSOLE ) -/* -* "memset" on IO memory space. -*/ -void _memset_c_io (volatile void __iomem *to,unsigned long c,long count) +#include <asm/vga.h> + +void memsetw_io (volatile void __iomem *to,u16 c,long count) { +unsigned long v =0x0001000100010001UL * c; +/* Handle any initial odd byte */ if (count >0 && ((u64 )to &1 )) { -__raw_writeb (c, to); +__raw_writeb (v, to); to++; count--; }/* Handle any initial odd halfword */ if (count >=2 && ((u64 )to &2 )) { -__raw_writew (c, to); +__raw_writew (v, to); to +=2 ; count -=2 ; }/* Handle any initial odd word */ if (count >=4 && ((u64 )to &4 )) { -__raw_writel (c, to); +__raw_writel (v, to); to +=4 ; count -=4 ; }
@@ -617,7 +619,7 @@ void _memset_c_io(volatile void __iomem *to, unsigned long c, long count) count -=8 ;if (count >=0 ) {do { -__raw_writeq (c, to); +__raw_writeq (v, to); to +=8 ; count -=8 ; }while (count >=0 );
@@ -626,14 +628,14 @@ void _memset_c_io(volatile void __iomem *to, unsigned long c, long count)/* The tail is word-aligned if we still have count >= 4 */ if (count >=4 ) { -__raw_writel (c, to); +__raw_writel (v, to); to +=4 ; count -=4 ; }/* The tail is half-word aligned if we have count >= 2 */ if (count >=2 ) { -__raw_writew (c, to); +__raw_writew (v, to); to +=2 ; count -=2 ; }
@@ -645,14 +647,14 @@ void _memset_c_io(volatile void __iomem *to, unsigned long c, long count)mb (); } -EXPORT_SYMBOL (_memset_c_io); - -#if IS_ENABLED (CONFIG_VGA_CONSOLE ) ||IS_ENABLED (CONFIG_MDA_CONSOLE ) - -#include <asm/vga.h> - -/* A version of memcpy used by the vga console routines to move data around -arbitrarily between screen and main memory. */ +void scr_memsetw (u16 *s,u16 c,unsigned int count) +{ +if (__is_ioaddr (s)) +memsetw_io ((u16 __iomem *) s, c, count); +else +memset16 (s, c, count /2 ); +} +EXPORT_SYMBOL (scr_memsetw);void scr_memcpyw (u16 *d,const u16 *s,unsigned int count)
Signature · 1 line
2.34.1
PATCH v2 2/2 alpha: Remove IO memcpy and memset
Recently new IO memcpy were added in libs/iomem_copy.c. So, remove the alpha specific implementations and use the ones from the lib code.
---
Changes for V2:
- Split the patch into two:
- One that shuffles the memsetw_io and _memset_c_io around
- And one that removed the memcpy_fromio and memcpy_toio
--- arch/alpha/include/asm/io.h | 5 -- arch/alpha/kernel/io.c | 109 ------------------------------------ 2 files changed, 114 deletions(-)
arch/alpha/include/asm/io.h +0 -5
@@ -590,13 +590,8 @@ extern inline u64 readq_relaxed(const volatile void __iomem *addr)/* * 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 memsetw_io (volatile void __iomem *to,u16 c,long count); -#define memcpy_fromio memcpy_fromio -#define memcpy_toio memcpy_toio -/* * String versions of in/out ops: */
arch/alpha/kernel/io.c +0 -109
115 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v2 2/2] alpha: Remove IO memcpy and memset
Quoted 4 lines · Julian Vetter
Recently new IO memcpy were added in
libs/iomem_copy.c. So, remove the alpha specific implementations and use the ones from the lib code.Signed-off-by Julian Vetter <[email protected]>
Re: [PATCH v2 2/2] alpha: Remove IO memcpy and memset
Quoted 6 lines · Arnd Bergmann
Quoted 4 lines
Recently new IO memcpy were added in
libs/iomem_copy.c. So, remove the alpha specific implementations and use the ones from the lib code.Signed-off-by Julian Vetter <[email protected]>Reviewed-by Arnd Bergmann <[email protected]>
NAK, see my comment for v1.
Maciej
Quoted 6 lines · Julian Vetter
In order to prepare the alpha architecture to use the generic IO functions from
lib/iomem_copy.c, rename_memset_c_iotomemsetw_io. Then movescr_memsetwtoio.c, along thescr_memcpywandscr_memmovew, inside theCONFIG_VGA_CONSOLE.Signed-off-by Julian Vetter <[email protected]>