Re: [PATCH] alpha: Remove IO memcpy and memset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux