Alpha arch development list
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Julian Vetter" <julian@outer-limits.org>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Matt Turner" <mattst88@gmail.com>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Alexander Viro" <viro@zeniv.linux.org.uk>
Cc: linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] alpha: Remove IO memcpy and memset
Date: Mon, 03 Feb 2025 15:39:18 +0100	[thread overview]
Message-ID: <64035bbf-1872-4750-9988-6e7929be647e@app.fastmail.com> (raw)
In-Reply-To: <20250203141800.69126-1-julian@outer-limits.org>

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

  reply	other threads:[~2025-02-03 14:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-03 14:18 [PATCH] alpha: Remove IO memcpy and memset Julian Vetter
2025-02-03 14:39 ` Arnd Bergmann [this message]
2025-02-04 21:07 ` Maciej W. Rozycki

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=64035bbf-1872-4750-9988-6e7929be647e@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=julian@outer-limits.org \
    --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