From: Julian Vetter <julian@outer-limits.org>
To: Arnd Bergmann <arnd@arndb.de>,
Richard Henderson <richard.henderson@linaro.org>,
Matt Turner <mattst88@gmail.com>,
"Paul E . McKenney" <paulmck@kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org,
Julian Vetter <julian@outer-limits.org>
Subject: [PATCH v2 1/2] alpha: rework use of memset_io, memsetw_io and scr_memsetw
Date: Mon, 3 Feb 2025 16:42:15 +0100 [thread overview]
Message-ID: <20250203154216.172040-1-julian@outer-limits.org> (raw)
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
next reply other threads:[~2025-02-03 15:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-03 15:42 Julian Vetter [this message]
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
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=20250203154216.172040-1-julian@outer-limits.org \
--to=julian@outer-limits.org \
--cc=arnd@arndb.de \
--cc=linus.walleij@linaro.org \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mattst88@gmail.com \
--cc=paulmck@kernel.org \
--cc=richard.henderson@linaro.org \
--cc=viro@zeniv.linux.org.uk \
/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®