Alpha arch development list
 help / color / mirror / Atom feed
* [PATCH v2 1/2] alpha: rework use of memset_io, memsetw_io and scr_memsetw
@ 2025-02-03 15:42 Julian Vetter
  2025-02-03 15:42 ` [PATCH v2 2/2] alpha: Remove IO memcpy and memset Julian Vetter
  2025-02-03 17:24 ` [PATCH v2 1/2] alpha: rework use of memset_io, memsetw_io and scr_memsetw Arnd Bergmann
  0 siblings, 2 replies; 5+ messages in thread
From: Julian Vetter @ 2025-02-03 15:42 UTC (permalink / raw)
  To: Arnd Bergmann, Richard Henderson, Matt Turner, Paul E . McKenney,
	Linus Walleij, Al Viro
  Cc: linux-alpha, linux-kernel, Julian Vetter

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.

Signed-off-by: Julian Vetter <julian@outer-limits.org>
---
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(-)

diff --git a/arch/alpha/include/asm/io.h b/arch/alpha/include/asm/io.h
index 65fe1e54c6da..d6e868872e19 100644
--- a/arch/alpha/include/asm/io.h
+++ b/arch/alpha/include/asm/io.h
@@ -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
 
diff --git a/arch/alpha/include/asm/vga.h b/arch/alpha/include/asm/vga.h
index 919931cb5b63..01611d792597 100644
--- a/arch/alpha/include/asm/vga.h
+++ b/arch/alpha/include/asm/vga.h
@@ -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
diff --git a/arch/alpha/kernel/io.c b/arch/alpha/kernel/io.c
index c28035d6d1e6..353b1dcbd422 100644
--- a/arch/alpha/kernel/io.c
+++ b/arch/alpha/kernel/io.c
@@ -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)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] alpha: Remove IO memcpy and memset
  2025-02-03 15:42 [PATCH v2 1/2] alpha: rework use of memset_io, memsetw_io and scr_memsetw Julian Vetter
@ 2025-02-03 15:42 ` Julian Vetter
  2025-02-03 17:24   ` Arnd Bergmann
  2025-02-03 17:24 ` [PATCH v2 1/2] alpha: rework use of memset_io, memsetw_io and scr_memsetw Arnd Bergmann
  1 sibling, 1 reply; 5+ messages in thread
From: Julian Vetter @ 2025-02-03 15:42 UTC (permalink / raw)
  To: Arnd Bergmann, Richard Henderson, Matt Turner, Paul E . McKenney,
	Linus Walleij, Al Viro
  Cc: linux-alpha, linux-kernel, 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 <julian@outer-limits.org>
---
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(-)

diff --git a/arch/alpha/include/asm/io.h b/arch/alpha/include/asm/io.h
index d6e868872e19..ba45f84c97f1 100644
--- a/arch/alpha/include/asm/io.h
+++ b/arch/alpha/include/asm/io.h
@@ -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:
  */
diff --git a/arch/alpha/kernel/io.c b/arch/alpha/kernel/io.c
index 353b1dcbd422..a6a53fcfafb6 100644
--- a/arch/alpha/kernel/io.c
+++ b/arch/alpha/kernel/io.c
@@ -476,115 +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)
-{
-	/* Optimize co-aligned transfers.  Everything else gets handled
-	   a byte at a time. */
-
-	if (count >= 8 && ((u64)to & 7) == ((u64)from & 7)) {
-		count -= 8;
-		do {
-			*(u64 *)to = __raw_readq(from);
-			count -= 8;
-			to += 8;
-			from += 8;
-		} while (count >= 0);
-		count += 8;
-	}
-
-	if (count >= 4 && ((u64)to & 3) == ((u64)from & 3)) {
-		count -= 4;
-		do {
-			*(u32 *)to = __raw_readl(from);
-			count -= 4;
-			to += 4;
-			from += 4;
-		} while (count >= 0);
-		count += 4;
-	}
-
-	if (count >= 2 && ((u64)to & 1) == ((u64)from & 1)) {
-		count -= 2;
-		do {
-			*(u16 *)to = __raw_readw(from);
-			count -= 2;
-			to += 2;
-			from += 2;
-		} while (count >= 0);
-		count += 2;
-	}
-
-	while (count > 0) {
-		*(u8 *) to = __raw_readb(from);
-		count--;
-		to++;
-		from++;
-	}
-	mb();
-}
-
-EXPORT_SYMBOL(memcpy_fromio);
-
-
-/*
- * Copy data from "real" memory space to IO memory space.
- * This needs to be optimized.
- */
-void memcpy_toio(volatile void __iomem *to, const void *from, long count)
-{
-	/* Optimize co-aligned transfers.  Everything else gets handled
-	   a byte at a time. */
-	/* FIXME -- align FROM.  */
-
-	if (count >= 8 && ((u64)to & 7) == ((u64)from & 7)) {
-		count -= 8;
-		do {
-			__raw_writeq(*(const u64 *)from, to);
-			count -= 8;
-			to += 8;
-			from += 8;
-		} while (count >= 0);
-		count += 8;
-	}
-
-	if (count >= 4 && ((u64)to & 3) == ((u64)from & 3)) {
-		count -= 4;
-		do {
-			__raw_writel(*(const u32 *)from, to);
-			count -= 4;
-			to += 4;
-			from += 4;
-		} while (count >= 0);
-		count += 4;
-	}
-
-	if (count >= 2 && ((u64)to & 1) == ((u64)from & 1)) {
-		count -= 2;
-		do {
-			__raw_writew(*(const u16 *)from, to);
-			count -= 2;
-			to += 2;
-			from += 2;
-		} while (count >= 0);
-		count += 2;
-	}
-
-	while (count > 0) {
-		__raw_writeb(*(const u8 *) from, to);
-		count--;
-		to++;
-		from++;
-	}
-	mb();
-}
-
-EXPORT_SYMBOL(memcpy_toio);
-
 #if IS_ENABLED(CONFIG_VGA_CONSOLE) || IS_ENABLED(CONFIG_MDA_CONSOLE)
 
 #include <asm/vga.h>
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] alpha: rework use of memset_io, memsetw_io and scr_memsetw
  2025-02-03 15:42 [PATCH v2 1/2] alpha: rework use of memset_io, memsetw_io and scr_memsetw Julian Vetter
  2025-02-03 15:42 ` [PATCH v2 2/2] alpha: Remove IO memcpy and memset Julian Vetter
@ 2025-02-03 17:24 ` Arnd Bergmann
  1 sibling, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2025-02-03 17:24 UTC (permalink / raw)
  To: Julian Vetter, Richard Henderson, Matt Turner, Paul E. McKenney,
	Linus Walleij, Alexander Viro
  Cc: linux-alpha, linux-kernel

On Mon, Feb 3, 2025, at 16:42, Julian Vetter wrote:
> 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.
>
> Signed-off-by: Julian Vetter <julian@outer-limits.org>

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] alpha: Remove IO memcpy and memset
  2025-02-03 15:42 ` [PATCH v2 2/2] alpha: Remove IO memcpy and memset Julian Vetter
@ 2025-02-03 17:24   ` Arnd Bergmann
  2025-02-04 21:10     ` Maciej W. Rozycki
  0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2025-02-03 17:24 UTC (permalink / raw)
  To: Julian Vetter, Richard Henderson, Matt Turner, Paul E. McKenney,
	Linus Walleij, Alexander Viro
  Cc: linux-alpha, linux-kernel

On Mon, Feb 3, 2025, at 16:42, Julian Vetter wrote:
> 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 <julian@outer-limits.org>

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] alpha: Remove IO memcpy and memset
  2025-02-03 17:24   ` Arnd Bergmann
@ 2025-02-04 21:10     ` Maciej W. Rozycki
  0 siblings, 0 replies; 5+ messages in thread
From: Maciej W. Rozycki @ 2025-02-04 21:10 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Julian Vetter, Richard Henderson, Matt Turner, Paul E. McKenney,
	Linus Walleij, Alexander Viro, linux-alpha, linux-kernel

On Mon, 3 Feb 2025, Arnd Bergmann wrote:

> > 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 <julian@outer-limits.org>
> 
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>

 NAK, see my comment for v1.

  Maciej

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-02-04 21:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-03 15:42 [PATCH v2 1/2] alpha: rework use of memset_io, memsetw_io and scr_memsetw Julian Vetter
2025-02-03 15:42 ` [PATCH v2 2/2] alpha: Remove IO memcpy and memset Julian Vetter
2025-02-03 17:24   ` Arnd Bergmann
2025-02-04 21:10     ` Maciej W. Rozycki
2025-02-03 17:24 ` [PATCH v2 1/2] alpha: rework use of memset_io, memsetw_io and scr_memsetw Arnd Bergmann

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