mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Julian Vetter <julian@outer-limits.org>
To: "David S . Miller" <davem@davemloft.net>,
	Andreas Larsson <andreas@gaisler.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org,
	Julian Vetter <julian@outer-limits.org>
Subject: [PATCH] sparc: Remove IO memcpy and memset from sparc code
Date: Thu, 29 Oct 2026 15:53:09 +0100	[thread overview]
Message-ID: <20261029145309.132218-1-julian@outer-limits.org> (raw)

Remove the IO memcpy and memset from sparc specific code and fall back
to the implementations from lib/iomem_copy.c. They use word accesses if
the buffers are aligned and only fall back to byte accesses for
potentially unaligned parts of a buffer, while the sparc versions always
use byte-wise readb()/writeb() accesses. Other architectures, such as
arm64, csky, loongarch and parisc, have already been converted to the
generic implementation.

This does not drop any memory barriers. The sparc versions don't use
mb(), and the rmb()/wmb() implied by readb()/writeb() on sparc32 and
sparc64 are only compiler barriers.

Signed-off-by: Julian Vetter <julian@outer-limits.org>
---
 arch/sparc/include/asm/io_32.h | 40 ----------------------------------
 arch/sparc/include/asm/io_64.h | 38 --------------------------------
 2 files changed, 78 deletions(-)

diff --git a/arch/sparc/include/asm/io_32.h b/arch/sparc/include/asm/io_32.h
index 549f0a72280d..5df651ee5935 100644
--- a/arch/sparc/include/asm/io_32.h
+++ b/arch/sparc/include/asm/io_32.h
@@ -7,10 +7,6 @@
 
 #define IO_SPACE_LIMIT 0xffffffff
 
-#define memset_io(d,c,sz)     _memset_io(d,c,sz)
-#define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz)
-#define memcpy_toio(d,s,sz)   _memcpy_toio(d,s,sz)
-
 /*
  * Bus number may be embedded in the higher bits of the physical address.
  * This is why we have no bus number argument to ioremap().
@@ -20,42 +16,6 @@ void iounmap(volatile void __iomem *addr);
 
 #include <asm-generic/io.h>
 
-static inline void _memset_io(volatile void __iomem *dst,
-                              int c, __kernel_size_t n)
-{
-	volatile void __iomem *d = dst;
-
-	while (n--) {
-		writeb(c, d);
-		d++;
-	}
-}
-
-static inline void _memcpy_fromio(void *dst, const volatile void __iomem *src,
-                                  __kernel_size_t n)
-{
-	char *d = dst;
-
-	while (n--) {
-		char tmp = readb(src);
-		*d++ = tmp;
-		src++;
-	}
-}
-
-static inline void _memcpy_toio(volatile void __iomem *dst, const void *src,
-                                __kernel_size_t n)
-{
-	const char *s = src;
-	volatile void __iomem *d = dst;
-
-	while (n--) {
-		char tmp = *s++;
-		writeb(tmp, d);
-		d++;
-	}
-}
-
 /*
  * SBus accessors.
  *
diff --git a/arch/sparc/include/asm/io_64.h b/arch/sparc/include/asm/io_64.h
index d8ed296624af..83fb1cf90601 100644
--- a/arch/sparc/include/asm/io_64.h
+++ b/arch/sparc/include/asm/io_64.h
@@ -349,17 +349,6 @@ static inline void sbus_memset_io(volatile void __iomem *dst, int c, __kernel_si
 	}
 }
 
-static inline void memset_io(volatile void __iomem *dst, int c, __kernel_size_t n)
-{
-	volatile void __iomem *d = dst;
-
-	while (n--) {
-		writeb(c, d);
-		d++;
-	}
-}
-#define memset_io memset_io
-
 static inline void sbus_memcpy_fromio(void *dst, const volatile void __iomem *src,
 				      __kernel_size_t n)
 {
@@ -373,19 +362,6 @@ static inline void sbus_memcpy_fromio(void *dst, const volatile void __iomem *sr
 }
 
 
-static inline void memcpy_fromio(void *dst, const volatile void __iomem *src,
-				 __kernel_size_t n)
-{
-	char *d = dst;
-
-	while (n--) {
-		char tmp = readb(src);
-		*d++ = tmp;
-		src++;
-	}
-}
-#define memcpy_fromio memcpy_fromio
-
 static inline void sbus_memcpy_toio(volatile void __iomem *dst, const void *src,
 				    __kernel_size_t n)
 {
@@ -399,20 +375,6 @@ static inline void sbus_memcpy_toio(volatile void __iomem *dst, const void *src,
 	}
 }
 
-static inline void memcpy_toio(volatile void __iomem *dst, const void *src,
-			       __kernel_size_t n)
-{
-	const char *s = src;
-	volatile void __iomem *d = dst;
-
-	while (n--) {
-		char tmp = *s++;
-		writeb(tmp, d);
-		d++;
-	}
-}
-#define memcpy_toio memcpy_toio
-
 #ifdef __KERNEL__
 
 /* On sparc64 we have the whole physical IO address space accessible
-- 
2.53.0


             reply	other threads:[~2026-10-29 14:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 14:53 Julian Vetter [this message]
2026-10-29 15:13 ` Arnd Bergmann

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=20261029145309.132218-1-julian@outer-limits.org \
    --to=julian@outer-limits.org \
    --cc=andreas@gaisler.com \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sparclinux@vger.kernel.org \
    /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®