[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <64035bbf-1872-4750-9988-6e7929be647e@app.fastmail.com>
Date: Mon, 03 Feb 2025 15:39:18 +0100
From: "Arnd Bergmann" <arnd@...db.de>
To: "Julian Vetter" <julian@...er-limits.org>,
"Richard Henderson" <richard.henderson@...aro.org>,
"Matt Turner" <mattst88@...il.com>, "Paul E. McKenney" <paulmck@...nel.org>,
"Linus Walleij" <linus.walleij@...aro.org>,
"Alexander Viro" <viro@...iv.linux.org.uk>
Cc: linux-alpha@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] alpha: Remove IO memcpy and memset
On Mon, Feb 3, 2025, at 15:18, Julian Vetter wrote:
> diff --git a/arch/alpha/include/asm/vga.h b/arch/alpha/include/asm/vga.h
> index 919931cb5b63..cac735bc3e16 100644
> --- a/arch/alpha/include/asm/vga.h
> +++ b/arch/alpha/include/asm/vga.h
> @@ -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().
> -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;
> - 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
Powered by blists - more mailing lists