Generic Linux architectural discussions
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Julian Vetter" <jvetter@kalrayinc.com>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Will Deacon" <will@kernel.org>, guoren <guoren@kernel.org>,
	"Huacai Chen" <chenhuacai@kernel.org>,
	"WANG Xuerui" <kernel@xen0n.name>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Geert Uytterhoeven" <geert@linux-m68k.org>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Niklas Schnelle" <schnelle@linux.ibm.com>,
	"Takashi Iwai" <tiwai@suse.com>,
	"Miquel Raynal" <miquel.raynal@bootlin.com>,
	"David Laight" <David.Laight@aculab.com>,
	"Johannes Berg" <johannes@sipsolutions.net>,
	"Christoph Hellwig" <hch@infradead.org>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	"linux-csky@vger.kernel.org" <linux-csky@vger.kernel.org>,
	loongarch@lists.linux.dev,
	Linux-Arch <linux-arch@vger.kernel.org>,
	"Yann Sionneau" <ysionneau@kalrayinc.com>
Subject: Re: [PATCH v9 1/4] Consolidate IO memcpy/memset into iomem_copy.c
Date: Fri, 11 Oct 2024 08:23:18 +0000	[thread overview]
Message-ID: <3e6d420e-5e81-4325-b5fd-a1746ff6216f@app.fastmail.com> (raw)
In-Reply-To: <20241010123627.695191-2-jvetter@kalrayinc.com>

On Thu, Oct 10, 2024, at 12:36, Julian Vetter wrote:
> Various architectures have almost the same implementations for
> memcpy_{to,from}io and memset_io functions. So, consolidate them
> into a common lib/iomem_copy.c.
>
> Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
> Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
> ---
> Changes for v9:
> - Moved all functions to iomem_copy.c
> - Build the new iomem_copy.c unconditionally
> - Guard prototypes in asm-generic/io.h with ifdefs

I'm happy with the patch contents, but it looks like you forgot
to update the description as this is not what this version of the
patch does: Instead of consolidating the identical versions (which
you do in patches 2-4), this changes the ones that use the
memcpy/memset fallback: arc, microblaze, mips, nios2, openrisc,
riscv, and xtensa.

> --- a/include/asm-generic/io.h
> +++ b/include/asm-generic/io.h
> @@ -102,6 +102,16 @@ static inline void log_post_read_mmio(u64 val, u8 
> width, const volatile void __i
> 
>  #endif /* CONFIG_TRACE_MMIO_ACCESS */
> 
> +#ifndef memcpy_fromio
> +void memcpy_fromio(void *to, const volatile void __iomem *from, size_t 
> count);
> +#endif
> +#ifndef memcpy_toio
> +void memcpy_toio(volatile void __iomem *to, const void *from, size_t 
> count);
> +#endif
> +#ifndef memset_io
> +void memset_io(volatile void __iomem *dst, int c, size_t count);
> +#endif
> +
>  /*
>   * __raw_{read,write}{b,w,l,q}() access memory in native endianness.
>   *
> @@ -1150,58 +1160,6 @@ static inline void 
> unxlate_dev_mem_ptr(phys_addr_t phys, void *addr)
>  }
>  #endif
> 
> -#ifndef memset_io
> -#define memset_io memset_io
> -/**
> - * memset_io	Set a range of I/O memory to a constant value
> - * @addr:	The beginning of the I/O-memory range to set
> - * @val:	The value to set the memory to
> - * @count:	The number of bytes to set
> - *
> - * Set a range of I/O memory to a given value.
> - */
> -static inline void memset_io(volatile void __iomem *addr, int value,
> -			     size_t size)
> -{
> -	memset(__io_virt(addr), value, size);
> -}
> -#endif

Unless there is a technical reason to move the location of
these I think it would be clearer to change it in place
and keep the three #ifdef but replace the contents.

You can also choose to add the definition in one patch
and then change the header in the next patch, which would
let you have more descriptive changelog texts for the
new common implementation and the second patch that changes
the fallback.

     Arnd

  parent reply	other threads:[~2024-10-11  8:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-10 12:36 [PATCH v9 0/4] Consolidate IO memcpy functions Julian Vetter
2024-10-10 12:36 ` [PATCH v9 1/4] Consolidate IO memcpy/memset into iomem_copy.c Julian Vetter
2024-10-11  7:49   ` Christoph Hellwig
2024-10-11  8:23   ` Arnd Bergmann [this message]
2024-10-10 12:36 ` [PATCH v9 2/4] arm64: Use generic IO memcpy/memset Julian Vetter
2024-10-10 12:36 ` [PATCH v9 3/4] csky: " Julian Vetter
2024-10-10 12:36 ` [PATCH v9 4/4] loongarch: " Julian Vetter

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=3e6d420e-5e81-4325-b5fd-a1746ff6216f@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=David.Laight@aculab.com \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=chenhuacai@kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=guoren@kernel.org \
    --cc=hch@infradead.org \
    --cc=johannes@sipsolutions.net \
    --cc=jvetter@kalrayinc.com \
    --cc=kernel@xen0n.name \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-csky@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard.henderson@linaro.org \
    --cc=schnelle@linux.ibm.com \
    --cc=tiwai@suse.com \
    --cc=will@kernel.org \
    --cc=ysionneau@kalrayinc.com \
    /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