linux-m68k.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v8 00/14] Consolidate IO memcpy functions
@ 2024-10-08  7:50 Julian Vetter
  2024-10-08  7:50 ` [PATCH v8 01/14] Consolidate IO memcpy/memset into iomap_copy.c Julian Vetter
                   ` (13 more replies)
  0 siblings, 14 replies; 23+ messages in thread
From: Julian Vetter @ 2024-10-08  7:50 UTC (permalink / raw)
  To: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
	Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, James E . J . Bottomley, Helge Deller,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao,
	Madhavan Srinivasan, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Niklas Schnelle, Manivannan Sadhasivam, Miquel Raynal,
	Vignesh Raghavendra, Jaroslav Kysela, Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
	linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
	linuxppc-dev, linux-s390, mhi, linux-arm-msm, linux-mtd,
	linux-sound, Yann Sionneau, Julian Vetter

New patch set with all remarks taken into account.

Thank you Richard and David. I have masked the int with 0xff for alpha
and parisc, and I have replaced the shift operation by the
multiplication as you proposed.

Thank you Johannes for your remarks on the UM arch. Finally, I have
created an UM allyesconfig. I have manually disabled HAS_IOMEM and
INDIRECT_IOMEM. This way I was able to identify the drivers which don't
guard with 'depends on HAS_IOMEM || INDIRECT_IOMEM'. It was only a small
number. I changed them and added the patches to this series (see patch
12 to 14).

Thank you Niklas for your feedback. Unfortunately I was not able to
simply change the prototypes of the zpci_memcpy functions because they
return an int to indicate whether the pci transaction was successful. At
the same time they are used as generic memcpy IO functions in the driver
code. To resolve this, I implemented three wrapper functions and added
defines to overwrite the default. So, on s390 we always use the fast
zpci operations and don't fall back to the generic ones.

Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
Changes for v8:
- Dropped the arch/um patch that adds dummy implementations for IO
  memcpy functions
- Added 3 new patches that fix the dependency problem for UM (added
  dependencies on HAS_IOMEM || INDIRECT_IOMEM)
- Added new patch for s390 to internally call the zpci_memcpy functions
  and not the generic ones from libs/iomap_copy.c
- Addressed reviewer comments and replaced 2 or 3 shifts by
  'qc *= ~0UL / 0xff;'
- Addressed reviewer comments on pasrisc (masking the int value)
- Addressed reviewer comments on alpha (masking the int value)

Changes for v7:
- Added dummy implementations for memcpy_{to,from}io and memset_io on um
  architecture so drivers that use these functions build for um
- Replaced all accesses and checks by long type
- Added function prototypes as extern to asm-generic/io.h
- Removed '__' from the 3 new function names
- Some archs implement their own version of these IO functions with
  slightly different prototypes. So, I added 3 new patches to align
  prototypes with new ones in iomap_copy.c + io.h

Changes for v6:
- Added include of linux/align.h to fix build on arm arch
- Replaced compile-time check by ifdef for the CONFIG_64BIT otherwise we
  get a warning for the 'qc << 32' for archs with 32bit int types
- Suffixed arch commits by arch name

Changes for v5:
- Added functions to iomap_copy.c as proposed by Arndt
- Removed again the new io_copy.c and related objects
- Removed GENERIC_IO_COPY symbol and instead rely on the existing
  HAS_IOMEM symbol
- Added prototypes of __memcpy_{to,from}io and __memset_io functions to
  asm-generic/io.h

Changes for v4:
- Replaced memcpy/memset in asm-generic/io.h by the new
  __memcpy_{to,from}io and __memset_io, so individual architectures can
  use it instead of using their own implementation.

Changes for v3:
- Replaced again 'if(IS_ENABLED(CONFIG_64BIT))' by '#ifdef CONFIG_64BIT'
  because on 32bit architectures (e.g., csky), __raw_{read,write}q are
  not defined. So, it leads to compilation errors

Changes for v2:
- Renamed io.c -> io_copy.c
- Updated flag to 'GENERIC_IO_COPY'
- Replaced pointer dereferences by 'put_unaligned()'/'get_unaligned()'
- Replaced '#ifdef CONFIG_64BIT' by 'if(IS_ENABLED(CONFIG_64BIT))'
- Removed '__raw_{read,write}_native' and replaced by
  'if(IS_ENABLED(CONFIG_64BIT))' -> '__raw_write{l,q}'
---
Julian Vetter (14):
  Consolidate IO memcpy/memset into iomap_copy.c
  arm64: Use generic IO memcpy/memset
  csky: Use generic IO memcpy/memset
  loongarch: Use generic IO memcpy/memset
  m68k: Align prototypes of IO memcpy/memset
  alpha: Align prototypes of IO memcpy/memset
  parisc: Align prototypes of IO memcpy/memset
  sh: Align prototypes of IO memcpy/memset
  arm: Align prototype of IO memset
  powerpc: Align prototypes of IO memcpy and memset
  s390: Add wrappers around zpci_memcpy/zpci_memset
  bus: mhi: ep: Add HAS_IOMEM || INDIRECT_IOMEM dependency
  mtd: Add HAS_IOMEM || INDIRECT_IOMEM dependency
  sound: Make CONFIG_SND depend on INDIRECT_IOMEM instead of UML

 arch/alpha/include/asm/io.h        |   6 +-
 arch/alpha/kernel/io.c             |   4 +-
 arch/arm/include/asm/io.h          |   2 +-
 arch/arm64/include/asm/io.h        |  11 ---
 arch/arm64/kernel/io.c             |  87 --------------------
 arch/csky/include/asm/io.h         |  11 ---
 arch/csky/kernel/Makefile          |   2 +-
 arch/csky/kernel/io.c              |  91 ---------------------
 arch/loongarch/include/asm/io.h    |  10 ---
 arch/loongarch/kernel/Makefile     |   2 +-
 arch/loongarch/kernel/io.c         |  94 ---------------------
 arch/m68k/include/asm/kmap.h       |   8 +-
 arch/parisc/include/asm/io.h       |   3 -
 arch/parisc/lib/io.c               |  12 ++-
 arch/powerpc/include/asm/io-defs.h |   6 +-
 arch/powerpc/include/asm/io.h      |   6 +-
 arch/powerpc/kernel/io.c           |   6 +-
 arch/s390/include/asm/io.h         |  27 +++++-
 arch/s390/include/asm/pci_io.h     |   6 +-
 arch/sh/include/asm/io.h           |   3 -
 arch/sh/kernel/io.c                |   6 +-
 drivers/bus/mhi/ep/Kconfig         |   1 +
 drivers/mtd/chips/Kconfig          |   4 +
 drivers/mtd/lpddr/Kconfig          |   1 +
 include/asm-generic/io.h           |  58 ++-----------
 lib/iomap_copy.c                   | 127 +++++++++++++++++++++++++++++
 sound/Kconfig                      |   2 +-
 27 files changed, 197 insertions(+), 399 deletions(-)
 delete mode 100644 arch/csky/kernel/io.c
 delete mode 100644 arch/loongarch/kernel/io.c

-- 
2.34.1






^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH v8 01/14] Consolidate IO memcpy/memset into iomap_copy.c
  2024-10-08  7:50 [PATCH v8 00/14] Consolidate IO memcpy functions Julian Vetter
@ 2024-10-08  7:50 ` Julian Vetter
  2024-10-08  9:27   ` Arnd Bergmann
  2024-10-08 11:46   ` Christoph Hellwig
  2024-10-08  7:50 ` [PATCH v8 02/14] arm64: Use generic IO memcpy/memset Julian Vetter
                   ` (12 subsequent siblings)
  13 siblings, 2 replies; 23+ messages in thread
From: Julian Vetter @ 2024-10-08  7:50 UTC (permalink / raw)
  To: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
	Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, James E . J . Bottomley, Helge Deller,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao,
	Madhavan Srinivasan, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Niklas Schnelle, Manivannan Sadhasivam, Miquel Raynal,
	Vignesh Raghavendra, Jaroslav Kysela, Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
	linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
	linuxppc-dev, linux-s390, mhi, linux-arm-msm, linux-mtd,
	linux-sound, Yann Sionneau, Julian Vetter

Various architectures have almost the same implementations for
memcpy_{to,from}io and memset_io functions. So, consolidate them
into the existing lib/iomap_copy.c.

Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
Changes for v8:
- Replaced shifts by 'qc *= ~0UL / 0xff'
- Modification in v6.12-rc2: Include 'linux/unaligned.h' instead of
  'asm/unaligned.h'
---
 include/asm-generic/io.h |  58 ++----------------
 lib/iomap_copy.c         | 127 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 133 insertions(+), 52 deletions(-)

diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 80de699bf6af..f14655ed4d9d 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -102,6 +102,12 @@ static inline void log_post_read_mmio(u64 val, u8 width, const volatile void __i
 
 #endif /* CONFIG_TRACE_MMIO_ACCESS */
 
+extern void memcpy_fromio(void *to, const volatile void __iomem *from,
+			  size_t count);
+extern void memcpy_toio(volatile void __iomem *to, const void *from,
+			size_t count);
+extern void memset_io(volatile void __iomem *dst, int c, size_t count);
+
 /*
  * __raw_{read,write}{b,w,l,q}() access memory in native endianness.
  *
@@ -1150,58 +1156,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
-
-#ifndef memcpy_fromio
-#define memcpy_fromio memcpy_fromio
-/**
- * memcpy_fromio	Copy a block of data from I/O memory
- * @dst:		The (RAM) destination for the copy
- * @src:		The (I/O memory) source for the data
- * @count:		The number of bytes to copy
- *
- * Copy a block of data from I/O memory.
- */
-static inline void memcpy_fromio(void *buffer,
-				 const volatile void __iomem *addr,
-				 size_t size)
-{
-	memcpy(buffer, __io_virt(addr), size);
-}
-#endif
-
-#ifndef memcpy_toio
-#define memcpy_toio memcpy_toio
-/**
- * memcpy_toio		Copy a block of data into I/O memory
- * @dst:		The (I/O memory) destination for the copy
- * @src:		The (RAM) source for the data
- * @count:		The number of bytes to copy
- *
- * Copy a block of data to I/O memory.
- */
-static inline void memcpy_toio(volatile void __iomem *addr, const void *buffer,
-			       size_t size)
-{
-	memcpy(__io_virt(addr), buffer, size);
-}
-#endif
-
 extern int devmem_is_allowed(unsigned long pfn);
 
 #endif /* __KERNEL__ */
diff --git a/lib/iomap_copy.c b/lib/iomap_copy.c
index 2fd5712fb7c0..175d6930c293 100644
--- a/lib/iomap_copy.c
+++ b/lib/iomap_copy.c
@@ -3,8 +3,11 @@
  * Copyright 2006 PathScale, Inc.  All Rights Reserved.
  */
 
+#include <linux/align.h>
 #include <linux/export.h>
 #include <linux/io.h>
+#include <linux/types.h>
+#include <linux/unaligned.h>
 
 /**
  * __iowrite32_copy - copy data to MMIO space, in 32-bit units
@@ -76,3 +79,127 @@ void __iowrite64_copy(void __iomem *to, const void *from, size_t count)
 }
 EXPORT_SYMBOL_GPL(__iowrite64_copy);
 #endif
+
+#ifndef memcpy_fromio
+/**
+ * memcpy_fromio	Copy a block of data from I/O memory
+ * @to:			The (RAM) destination for the copy
+ * @from:		The (I/O memory) source for the data
+ * @count:		The number of bytes to copy
+ *
+ * Copy a block of data from I/O memory.
+ */
+void memcpy_fromio(void *to, const volatile void __iomem *from, size_t count)
+{
+	while (count && !IS_ALIGNED((long)from, sizeof(long))) {
+		*(u8 *)to = __raw_readb(from);
+		from++;
+		to++;
+		count--;
+	}
+
+	while (count >= sizeof(long)) {
+#ifdef CONFIG_64BIT
+		long val = __raw_readq(from);
+#else
+		long val = __raw_readl(from);
+#endif
+		put_unaligned(val, (long *)to);
+
+
+		from += sizeof(long);
+		to += sizeof(long);
+		count -= sizeof(long);
+	}
+
+	while (count) {
+		*(u8 *)to = __raw_readb(from);
+		from++;
+		to++;
+		count--;
+	}
+}
+EXPORT_SYMBOL(memcpy_fromio);
+#endif
+
+#ifndef memcpy_toio
+/**
+ * memcpy_toio		Copy a block of data into I/O memory
+ * @to:			The (I/O memory) destination for the copy
+ * @from:		The (RAM) source for the data
+ * @count:		The number of bytes to copy
+ *
+ * Copy a block of data to I/O memory.
+ */
+void memcpy_toio(volatile void __iomem *to, const void *from, size_t count)
+{
+	while (count && !IS_ALIGNED((long)to, sizeof(long))) {
+		__raw_writeb(*(u8 *)from, to);
+		from++;
+		to++;
+		count--;
+	}
+
+	while (count >= sizeof(long)) {
+		long val = get_unaligned((long *)from);
+#ifdef CONFIG_64BIT
+		__raw_writeq(val, to);
+#else
+		__raw_writel(val, to);
+#endif
+
+		from += sizeof(long);
+		to += sizeof(long);
+		count -= sizeof(long);
+	}
+
+	while (count) {
+		__raw_writeb(*(u8 *)from, to);
+		from++;
+		to++;
+		count--;
+	}
+}
+EXPORT_SYMBOL(memcpy_toio);
+#endif
+
+#ifndef memset_io
+/**
+ * memset_io		Set a range of I/O memory to a constant value
+ * @dst:		The beginning of the I/O-memory range to set
+ * @c:			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.
+ */
+void memset_io(volatile void __iomem *dst, int c, size_t count)
+{
+	long qc = (u8)c;
+
+	qc *= ~0UL / 0xff;
+
+	while (count && !IS_ALIGNED((long)dst, sizeof(long))) {
+		__raw_writeb(c, dst);
+		dst++;
+		count--;
+	}
+
+	while (count >= sizeof(long)) {
+#ifdef CONFIG_64BIT
+		__raw_writeq(qc, dst);
+#else
+		__raw_writel(qc, dst);
+#endif
+
+		dst += sizeof(long);
+		count -= sizeof(long);
+	}
+
+	while (count) {
+		__raw_writeb(c, dst);
+		dst++;
+		count--;
+	}
+}
+EXPORT_SYMBOL(memset_io);
+#endif
-- 
2.34.1






^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v8 02/14] arm64: Use generic IO memcpy/memset
  2024-10-08  7:50 [PATCH v8 00/14] Consolidate IO memcpy functions Julian Vetter
  2024-10-08  7:50 ` [PATCH v8 01/14] Consolidate IO memcpy/memset into iomap_copy.c Julian Vetter
@ 2024-10-08  7:50 ` Julian Vetter
  2024-10-08  7:50 ` [PATCH v8 03/14] csky: " Julian Vetter
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: Julian Vetter @ 2024-10-08  7:50 UTC (permalink / raw)
  To: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
	Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, James E . J . Bottomley, Helge Deller,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao,
	Madhavan Srinivasan, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Niklas Schnelle, Manivannan Sadhasivam, Miquel Raynal,
	Vignesh Raghavendra, Jaroslav Kysela, Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
	linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
	linuxppc-dev, linux-s390, mhi, linux-arm-msm, linux-mtd,
	linux-sound, Yann Sionneau, Julian Vetter

Use the generic memcpy_{from,to}io and memset_io functions on the
arm64 processor architecture.

Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
Changes for v8:
- No changes
---
 arch/arm64/include/asm/io.h | 11 -----
 arch/arm64/kernel/io.c      | 87 -------------------------------------
 2 files changed, 98 deletions(-)

diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h
index 1ada23a6ec19..463067bffdfd 100644
--- a/arch/arm64/include/asm/io.h
+++ b/arch/arm64/include/asm/io.h
@@ -128,17 +128,6 @@ static __always_inline u64 __raw_readq(const volatile void __iomem *addr)
 #define IO_SPACE_LIMIT		(PCI_IO_SIZE - 1)
 #define PCI_IOBASE		((void __iomem *)PCI_IO_START)
 
-/*
- * String version of I/O memory access operations.
- */
-extern void __memcpy_fromio(void *, const volatile void __iomem *, size_t);
-extern void __memcpy_toio(volatile void __iomem *, const void *, size_t);
-extern void __memset_io(volatile void __iomem *, int, size_t);
-
-#define memset_io(c,v,l)	__memset_io((c),(v),(l))
-#define memcpy_fromio(a,c,l)	__memcpy_fromio((a),(c),(l))
-#define memcpy_toio(c,a,l)	__memcpy_toio((c),(a),(l))
-
 /*
  * The ARM64 iowrite implementation is intended to support drivers that want to
  * use write combining. For instance PCI drivers using write combining with a 64
diff --git a/arch/arm64/kernel/io.c b/arch/arm64/kernel/io.c
index ef48089fbfe1..fe86ada23c7d 100644
--- a/arch/arm64/kernel/io.c
+++ b/arch/arm64/kernel/io.c
@@ -9,34 +9,6 @@
 #include <linux/types.h>
 #include <linux/io.h>
 
-/*
- * Copy data from IO memory space to "real" memory space.
- */
-void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count)
-{
-	while (count && !IS_ALIGNED((unsigned long)from, 8)) {
-		*(u8 *)to = __raw_readb(from);
-		from++;
-		to++;
-		count--;
-	}
-
-	while (count >= 8) {
-		*(u64 *)to = __raw_readq(from);
-		from += 8;
-		to += 8;
-		count -= 8;
-	}
-
-	while (count) {
-		*(u8 *)to = __raw_readb(from);
-		from++;
-		to++;
-		count--;
-	}
-}
-EXPORT_SYMBOL(__memcpy_fromio);
-
 /*
  * This generates a memcpy that works on a from/to address which is aligned to
  * bits. Count is in terms of the number of bits sized quantities to copy. It
@@ -78,62 +50,3 @@ void __iowrite32_copy_full(void __iomem *to, const void *from, size_t count)
 	dgh();
 }
 EXPORT_SYMBOL(__iowrite32_copy_full);
-
-/*
- * Copy data from "real" memory space to IO memory space.
- */
-void __memcpy_toio(volatile void __iomem *to, const void *from, size_t count)
-{
-	while (count && !IS_ALIGNED((unsigned long)to, 8)) {
-		__raw_writeb(*(u8 *)from, to);
-		from++;
-		to++;
-		count--;
-	}
-
-	while (count >= 8) {
-		__raw_writeq(*(u64 *)from, to);
-		from += 8;
-		to += 8;
-		count -= 8;
-	}
-
-	while (count) {
-		__raw_writeb(*(u8 *)from, to);
-		from++;
-		to++;
-		count--;
-	}
-}
-EXPORT_SYMBOL(__memcpy_toio);
-
-/*
- * "memset" on IO memory space.
- */
-void __memset_io(volatile void __iomem *dst, int c, size_t count)
-{
-	u64 qc = (u8)c;
-
-	qc |= qc << 8;
-	qc |= qc << 16;
-	qc |= qc << 32;
-
-	while (count && !IS_ALIGNED((unsigned long)dst, 8)) {
-		__raw_writeb(c, dst);
-		dst++;
-		count--;
-	}
-
-	while (count >= 8) {
-		__raw_writeq(qc, dst);
-		dst += 8;
-		count -= 8;
-	}
-
-	while (count) {
-		__raw_writeb(c, dst);
-		dst++;
-		count--;
-	}
-}
-EXPORT_SYMBOL(__memset_io);
-- 
2.34.1






^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v8 03/14] csky: Use generic IO memcpy/memset
  2024-10-08  7:50 [PATCH v8 00/14] Consolidate IO memcpy functions Julian Vetter
  2024-10-08  7:50 ` [PATCH v8 01/14] Consolidate IO memcpy/memset into iomap_copy.c Julian Vetter
  2024-10-08  7:50 ` [PATCH v8 02/14] arm64: Use generic IO memcpy/memset Julian Vetter
@ 2024-10-08  7:50 ` Julian Vetter
  2024-10-08  7:50 ` [PATCH v8 04/14] loongarch: " Julian Vetter
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: Julian Vetter @ 2024-10-08  7:50 UTC (permalink / raw)
  To: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
	Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, James E . J . Bottomley, Helge Deller,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao,
	Madhavan Srinivasan, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Niklas Schnelle, Manivannan Sadhasivam, Miquel Raynal,
	Vignesh Raghavendra, Jaroslav Kysela, Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
	linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
	linuxppc-dev, linux-s390, mhi, linux-arm-msm, linux-mtd,
	linux-sound, Yann Sionneau, Julian Vetter

Use the generic memcpy_{from,to}io and memset_io functions on the csky
processor architecture.

Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
Changes for v8:
- No changes
---
 arch/csky/include/asm/io.h | 11 -----
 arch/csky/kernel/Makefile  |  2 +-
 arch/csky/kernel/io.c      | 91 --------------------------------------
 3 files changed, 1 insertion(+), 103 deletions(-)
 delete mode 100644 arch/csky/kernel/io.c

diff --git a/arch/csky/include/asm/io.h b/arch/csky/include/asm/io.h
index 4725bb977b0f..ed53f0b47388 100644
--- a/arch/csky/include/asm/io.h
+++ b/arch/csky/include/asm/io.h
@@ -31,17 +31,6 @@
 #define writel(v,c)		({ wmb(); writel_relaxed((v),(c)); mb(); })
 #endif
 
-/*
- * String version of I/O memory access operations.
- */
-extern void __memcpy_fromio(void *, const volatile void __iomem *, size_t);
-extern void __memcpy_toio(volatile void __iomem *, const void *, size_t);
-extern void __memset_io(volatile void __iomem *, int, size_t);
-
-#define memset_io(c,v,l)        __memset_io((c),(v),(l))
-#define memcpy_fromio(a,c,l)    __memcpy_fromio((a),(c),(l))
-#define memcpy_toio(c,a,l)      __memcpy_toio((c),(a),(l))
-
 /*
  * I/O memory mapping functions.
  */
diff --git a/arch/csky/kernel/Makefile b/arch/csky/kernel/Makefile
index 8a868316b912..de1c3472e8f0 100644
--- a/arch/csky/kernel/Makefile
+++ b/arch/csky/kernel/Makefile
@@ -2,7 +2,7 @@
 extra-y := vmlinux.lds
 
 obj-y += head.o entry.o atomic.o signal.o traps.o irq.o time.o vdso.o vdso/
-obj-y += power.o syscall.o syscall_table.o setup.o io.o
+obj-y += power.o syscall.o syscall_table.o setup.o
 obj-y += process.o cpu-probe.o ptrace.o stacktrace.o
 obj-y += probes/
 
diff --git a/arch/csky/kernel/io.c b/arch/csky/kernel/io.c
deleted file mode 100644
index 5883f13fa2b1..000000000000
--- a/arch/csky/kernel/io.c
+++ /dev/null
@@ -1,91 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-
-#include <linux/export.h>
-#include <linux/types.h>
-#include <linux/io.h>
-
-/*
- * Copy data from IO memory space to "real" memory space.
- */
-void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count)
-{
-	while (count && !IS_ALIGNED((unsigned long)from, 4)) {
-		*(u8 *)to = __raw_readb(from);
-		from++;
-		to++;
-		count--;
-	}
-
-	while (count >= 4) {
-		*(u32 *)to = __raw_readl(from);
-		from += 4;
-		to += 4;
-		count -= 4;
-	}
-
-	while (count) {
-		*(u8 *)to = __raw_readb(from);
-		from++;
-		to++;
-		count--;
-	}
-}
-EXPORT_SYMBOL(__memcpy_fromio);
-
-/*
- * Copy data from "real" memory space to IO memory space.
- */
-void __memcpy_toio(volatile void __iomem *to, const void *from, size_t count)
-{
-	while (count && !IS_ALIGNED((unsigned long)to, 4)) {
-		__raw_writeb(*(u8 *)from, to);
-		from++;
-		to++;
-		count--;
-	}
-
-	while (count >= 4) {
-		__raw_writel(*(u32 *)from, to);
-		from += 4;
-		to += 4;
-		count -= 4;
-	}
-
-	while (count) {
-		__raw_writeb(*(u8 *)from, to);
-		from++;
-		to++;
-		count--;
-	}
-}
-EXPORT_SYMBOL(__memcpy_toio);
-
-/*
- * "memset" on IO memory space.
- */
-void __memset_io(volatile void __iomem *dst, int c, size_t count)
-{
-	u32 qc = (u8)c;
-
-	qc |= qc << 8;
-	qc |= qc << 16;
-
-	while (count && !IS_ALIGNED((unsigned long)dst, 4)) {
-		__raw_writeb(c, dst);
-		dst++;
-		count--;
-	}
-
-	while (count >= 4) {
-		__raw_writel(qc, dst);
-		dst += 4;
-		count -= 4;
-	}
-
-	while (count) {
-		__raw_writeb(c, dst);
-		dst++;
-		count--;
-	}
-}
-EXPORT_SYMBOL(__memset_io);
-- 
2.34.1






^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v8 04/14] loongarch: Use generic IO memcpy/memset
  2024-10-08  7:50 [PATCH v8 00/14] Consolidate IO memcpy functions Julian Vetter
                   ` (2 preceding siblings ...)
  2024-10-08  7:50 ` [PATCH v8 03/14] csky: " Julian Vetter
@ 2024-10-08  7:50 ` Julian Vetter
  2024-10-08  7:50 ` [PATCH v8 05/14] m68k: Align prototypes of " Julian Vetter
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: Julian Vetter @ 2024-10-08  7:50 UTC (permalink / raw)
  To: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
	Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, James E . J . Bottomley, Helge Deller,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao,
	Madhavan Srinivasan, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Niklas Schnelle, Manivannan Sadhasivam, Miquel Raynal,
	Vignesh Raghavendra, Jaroslav Kysela, Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
	linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
	linuxppc-dev, linux-s390, mhi, linux-arm-msm, linux-mtd,
	linux-sound, Yann Sionneau, Julian Vetter

Use the generic memcpy_{from,to}io and memset_io functions on the
loongarch processor architecture.

Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
Changes for v8:
- No changes
---
 arch/loongarch/include/asm/io.h | 10 ----
 arch/loongarch/kernel/Makefile  |  2 +-
 arch/loongarch/kernel/io.c      | 94 ---------------------------------
 3 files changed, 1 insertion(+), 105 deletions(-)
 delete mode 100644 arch/loongarch/kernel/io.c

diff --git a/arch/loongarch/include/asm/io.h b/arch/loongarch/include/asm/io.h
index 5e95a60df180..e77a56eaf906 100644
--- a/arch/loongarch/include/asm/io.h
+++ b/arch/loongarch/include/asm/io.h
@@ -62,16 +62,6 @@ static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size,
 
 #define mmiowb() wmb()
 
-/*
- * String version of I/O memory access operations.
- */
-extern void __memset_io(volatile void __iomem *dst, int c, size_t count);
-extern void __memcpy_toio(volatile void __iomem *to, const void *from, size_t count);
-extern void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count);
-#define memset_io(c, v, l)     __memset_io((c), (v), (l))
-#define memcpy_fromio(a, c, l) __memcpy_fromio((a), (c), (l))
-#define memcpy_toio(c, a, l)   __memcpy_toio((c), (a), (l))
-
 #define __io_aw() mmiowb()
 
 #ifdef CONFIG_KFENCE
diff --git a/arch/loongarch/kernel/Makefile b/arch/loongarch/kernel/Makefile
index c9bfeda89e40..9497968ee158 100644
--- a/arch/loongarch/kernel/Makefile
+++ b/arch/loongarch/kernel/Makefile
@@ -8,7 +8,7 @@ OBJECT_FILES_NON_STANDARD_head.o := y
 extra-y		:= vmlinux.lds
 
 obj-y		+= head.o cpu-probe.o cacheinfo.o env.o setup.o entry.o genex.o \
-		   traps.o irq.o idle.o process.o dma.o mem.o io.o reset.o switch.o \
+		   traps.o irq.o idle.o process.o dma.o mem.o reset.o switch.o \
 		   elf.o syscall.o signal.o time.o topology.o inst.o ptrace.o vdso.o \
 		   alternative.o unwind.o
 
diff --git a/arch/loongarch/kernel/io.c b/arch/loongarch/kernel/io.c
deleted file mode 100644
index cb85bda5a6ad..000000000000
--- a/arch/loongarch/kernel/io.c
+++ /dev/null
@@ -1,94 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
- */
-#include <linux/export.h>
-#include <linux/types.h>
-#include <linux/io.h>
-
-/*
- * Copy data from IO memory space to "real" memory space.
- */
-void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count)
-{
-	while (count && !IS_ALIGNED((unsigned long)from, 8)) {
-		*(u8 *)to = __raw_readb(from);
-		from++;
-		to++;
-		count--;
-	}
-
-	while (count >= 8) {
-		*(u64 *)to = __raw_readq(from);
-		from += 8;
-		to += 8;
-		count -= 8;
-	}
-
-	while (count) {
-		*(u8 *)to = __raw_readb(from);
-		from++;
-		to++;
-		count--;
-	}
-}
-EXPORT_SYMBOL(__memcpy_fromio);
-
-/*
- * Copy data from "real" memory space to IO memory space.
- */
-void __memcpy_toio(volatile void __iomem *to, const void *from, size_t count)
-{
-	while (count && !IS_ALIGNED((unsigned long)to, 8)) {
-		__raw_writeb(*(u8 *)from, to);
-		from++;
-		to++;
-		count--;
-	}
-
-	while (count >= 8) {
-		__raw_writeq(*(u64 *)from, to);
-		from += 8;
-		to += 8;
-		count -= 8;
-	}
-
-	while (count) {
-		__raw_writeb(*(u8 *)from, to);
-		from++;
-		to++;
-		count--;
-	}
-}
-EXPORT_SYMBOL(__memcpy_toio);
-
-/*
- * "memset" on IO memory space.
- */
-void __memset_io(volatile void __iomem *dst, int c, size_t count)
-{
-	u64 qc = (u8)c;
-
-	qc |= qc << 8;
-	qc |= qc << 16;
-	qc |= qc << 32;
-
-	while (count && !IS_ALIGNED((unsigned long)dst, 8)) {
-		__raw_writeb(c, dst);
-		dst++;
-		count--;
-	}
-
-	while (count >= 8) {
-		__raw_writeq(qc, dst);
-		dst += 8;
-		count -= 8;
-	}
-
-	while (count) {
-		__raw_writeb(c, dst);
-		dst++;
-		count--;
-	}
-}
-EXPORT_SYMBOL(__memset_io);
-- 
2.34.1






^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v8 05/14] m68k: Align prototypes of IO memcpy/memset
  2024-10-08  7:50 [PATCH v8 00/14] Consolidate IO memcpy functions Julian Vetter
                   ` (3 preceding siblings ...)
  2024-10-08  7:50 ` [PATCH v8 04/14] loongarch: " Julian Vetter
@ 2024-10-08  7:50 ` Julian Vetter
  2024-10-08  7:50 ` [PATCH v8 06/14] alpha: " Julian Vetter
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: Julian Vetter @ 2024-10-08  7:50 UTC (permalink / raw)
  To: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
	Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, James E . J . Bottomley, Helge Deller,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao,
	Madhavan Srinivasan, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Niklas Schnelle, Manivannan Sadhasivam, Miquel Raynal,
	Vignesh Raghavendra, Jaroslav Kysela, Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
	linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
	linuxppc-dev, linux-s390, mhi, linux-arm-msm, linux-mtd,
	linux-sound, Yann Sionneau, Julian Vetter

Align the prototypes of the memcpy_{from,to}io and memset_io functions
with the new ones from iomap_copy.c.

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
Changes for v8:
- No changes
---
 arch/m68k/include/asm/kmap.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/m68k/include/asm/kmap.h b/arch/m68k/include/asm/kmap.h
index b778f015c917..e459f1911155 100644
--- a/arch/m68k/include/asm/kmap.h
+++ b/arch/m68k/include/asm/kmap.h
@@ -33,22 +33,22 @@ static inline void __iomem *ioremap_wt(unsigned long physaddr,
 }
 
 #define memset_io memset_io
-static inline void memset_io(volatile void __iomem *addr, unsigned char val,
-			     int count)
+static inline void memset_io(volatile void __iomem *addr, int val,
+			     size_t count)
 {
 	__builtin_memset((void __force *) addr, val, count);
 }
 
 #define memcpy_fromio memcpy_fromio
 static inline void memcpy_fromio(void *dst, const volatile void __iomem *src,
-				 int count)
+				 size_t count)
 {
 	__builtin_memcpy(dst, (void __force *) src, count);
 }
 
 #define memcpy_toio memcpy_toio
 static inline void memcpy_toio(volatile void __iomem *dst, const void *src,
-			       int count)
+			       size_t count)
 {
 	__builtin_memcpy((void __force *) dst, src, count);
 }
-- 
2.34.1






^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v8 06/14] alpha: Align prototypes of IO memcpy/memset
  2024-10-08  7:50 [PATCH v8 00/14] Consolidate IO memcpy functions Julian Vetter
                   ` (4 preceding siblings ...)
  2024-10-08  7:50 ` [PATCH v8 05/14] m68k: Align prototypes of " Julian Vetter
@ 2024-10-08  7:50 ` Julian Vetter
  2024-10-08 14:54   ` Richard Henderson
  2024-10-08  7:50 ` [PATCH v8 07/14] parisc: " Julian Vetter
                   ` (7 subsequent siblings)
  13 siblings, 1 reply; 23+ messages in thread
From: Julian Vetter @ 2024-10-08  7:50 UTC (permalink / raw)
  To: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
	Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, James E . J . Bottomley, Helge Deller,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao,
	Madhavan Srinivasan, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Niklas Schnelle, Manivannan Sadhasivam, Miquel Raynal,
	Vignesh Raghavendra, Jaroslav Kysela, Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
	linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
	linuxppc-dev, linux-s390, mhi, linux-arm-msm, linux-mtd,
	linux-sound, Yann Sionneau, Julian Vetter

Align the prototypes of the memcpy_{from,to}io and memset_io functions
with the new ones from iomap_copy.c and remove function declarations,
because they are now declared in asm-generic/io.h.

Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
Changes for v8:
- Mask the argument with 0xff because now it's an int and not a u8
  anymore
---
 arch/alpha/include/asm/io.h | 6 ++----
 arch/alpha/kernel/io.c      | 4 ++--
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/alpha/include/asm/io.h b/arch/alpha/include/asm/io.h
index b191d87f89c4..e7d52c8159b0 100644
--- a/arch/alpha/include/asm/io.h
+++ b/arch/alpha/include/asm/io.h
@@ -591,13 +591,11 @@ extern inline u64 readq_relaxed(const volatile void __iomem *addr)
 /*
  * String version of IO memory access ops:
  */
-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);
 
-static inline void memset_io(volatile void __iomem *addr, u8 c, long len)
+static inline void memset_io(volatile void __iomem *dst, int c, size_t count)
 {
-	_memset_c_io(addr, 0x0101010101010101UL * c, len);
+	_memset_c_io(dst, 0x0101010101010101UL * (c & 0xff), count);
 }
 
 #define __HAVE_ARCH_MEMSETW_IO
diff --git a/arch/alpha/kernel/io.c b/arch/alpha/kernel/io.c
index c28035d6d1e6..69c06f1b158d 100644
--- a/arch/alpha/kernel/io.c
+++ b/arch/alpha/kernel/io.c
@@ -481,7 +481,7 @@ EXPORT_SYMBOL(outsl);
  * Copy data from IO memory space to "real" memory space.
  * This needs to be optimized.
  */
-void memcpy_fromio(void *to, const volatile void __iomem *from, long count)
+void memcpy_fromio(void *to, const volatile void __iomem *from, size_t count)
 {
 	/* Optimize co-aligned transfers.  Everything else gets handled
 	   a byte at a time. */
@@ -535,7 +535,7 @@ EXPORT_SYMBOL(memcpy_fromio);
  * Copy data from "real" memory space to IO memory space.
  * This needs to be optimized.
  */
-void memcpy_toio(volatile void __iomem *to, const void *from, long count)
+void memcpy_toio(volatile void __iomem *to, const void *from, size_t count)
 {
 	/* Optimize co-aligned transfers.  Everything else gets handled
 	   a byte at a time. */
-- 
2.34.1






^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v8 07/14] parisc: Align prototypes of IO memcpy/memset
  2024-10-08  7:50 [PATCH v8 00/14] Consolidate IO memcpy functions Julian Vetter
                   ` (5 preceding siblings ...)
  2024-10-08  7:50 ` [PATCH v8 06/14] alpha: " Julian Vetter
@ 2024-10-08  7:50 ` Julian Vetter
  2024-10-08  7:50 ` [PATCH v8 08/14] sh: " Julian Vetter
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: Julian Vetter @ 2024-10-08  7:50 UTC (permalink / raw)
  To: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
	Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, James E . J . Bottomley, Helge Deller,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao,
	Madhavan Srinivasan, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Niklas Schnelle, Manivannan Sadhasivam, Miquel Raynal,
	Vignesh Raghavendra, Jaroslav Kysela, Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
	linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
	linuxppc-dev, linux-s390, mhi, linux-arm-msm, linux-mtd,
	linux-sound, Yann Sionneau, Julian Vetter

Align the prototypes of the memcpy_{from,to}io and memset_io functions
with the new ones from iomap_copy.c and remove function declarations,
because they are now declared in asm-generic/io.h.

Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
Changes for v8:
- Mask the argument with 0xff because now it's an int and not a unsigned
  char anymore
---
 arch/parisc/include/asm/io.h |  3 ---
 arch/parisc/lib/io.c         | 12 ++++++++----
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/arch/parisc/include/asm/io.h b/arch/parisc/include/asm/io.h
index a63190af2f05..5cfaa76bb899 100644
--- a/arch/parisc/include/asm/io.h
+++ b/arch/parisc/include/asm/io.h
@@ -135,9 +135,6 @@ static inline void gsc_writeq(unsigned long long val, unsigned long addr)
 
 #define pci_iounmap			pci_iounmap
 
-void memset_io(volatile void __iomem *addr, unsigned char val, int count);
-void memcpy_fromio(void *dst, const volatile void __iomem *src, int count);
-void memcpy_toio(volatile void __iomem *dst, const void *src, int count);
 #define memset_io memset_io
 #define memcpy_fromio memcpy_fromio
 #define memcpy_toio memcpy_toio
diff --git a/arch/parisc/lib/io.c b/arch/parisc/lib/io.c
index 7c00496b47d4..aef9b0124811 100644
--- a/arch/parisc/lib/io.c
+++ b/arch/parisc/lib/io.c
@@ -16,7 +16,7 @@
  * Assumes the device can cope with 32-bit transfers.  If it can't,
  * don't use this function.
  */
-void memcpy_toio(volatile void __iomem *dst, const void *src, int count)
+void memcpy_toio(volatile void __iomem *dst, const void *src, size_t count)
 {
 	if (((unsigned long)dst & 3) != ((unsigned long)src & 3))
 		goto bytecopy;
@@ -51,7 +51,7 @@ void memcpy_toio(volatile void __iomem *dst, const void *src, int count)
 **      Minimize total number of transfers at cost of CPU cycles.
 **	TODO: only look at src alignment and adjust the stores to dest.
 */
-void memcpy_fromio(void *dst, const volatile void __iomem *src, int count)
+void memcpy_fromio(void *dst, const volatile void __iomem *src, size_t count)
 {
 	/* first compare alignment of src/dst */ 
 	if ( (((unsigned long)dst ^ (unsigned long)src) & 1) || (count < 2) )
@@ -103,9 +103,13 @@ void memcpy_fromio(void *dst, const volatile void __iomem *src, int count)
  * Assumes the device can cope with 32-bit transfers.  If it can't,
  * don't use this function.
  */
-void memset_io(volatile void __iomem *addr, unsigned char val, int count)
+void memset_io(volatile void __iomem *addr, int val, size_t count)
 {
-	u32 val32 = (val << 24) | (val << 16) | (val << 8) | val;
+	u32 val32;
+
+	val &= 0xff;
+	val32 = (val << 24) | (val << 16) | (val << 8) | val;
+
 	while ((unsigned long)addr & 3) {
 		writeb(val, addr++);
 		count--;
-- 
2.34.1






^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v8 08/14] sh: Align prototypes of IO memcpy/memset
  2024-10-08  7:50 [PATCH v8 00/14] Consolidate IO memcpy functions Julian Vetter
                   ` (6 preceding siblings ...)
  2024-10-08  7:50 ` [PATCH v8 07/14] parisc: " Julian Vetter
@ 2024-10-08  7:50 ` Julian Vetter
  2024-10-08  7:50 ` [PATCH v8 09/14] arm: Align prototype of IO memset Julian Vetter
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: Julian Vetter @ 2024-10-08  7:50 UTC (permalink / raw)
  To: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
	Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, James E . J . Bottomley, Helge Deller,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao,
	Madhavan Srinivasan, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Niklas Schnelle, Manivannan Sadhasivam, Miquel Raynal,
	Vignesh Raghavendra, Jaroslav Kysela, Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
	linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
	linuxppc-dev, linux-s390, mhi, linux-arm-msm, linux-mtd,
	linux-sound, Yann Sionneau, Julian Vetter, Geert Uytterhoeven

Align the prototypes of the memcpy_{from,to}io and memset_io functions
with the new ones from iomap_copy.c and remove function declarations,
because they are now declared in asm-generic/io.h.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
Changes for v8:
- No changes
---
 arch/sh/include/asm/io.h | 3 ---
 arch/sh/kernel/io.c      | 6 +++---
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h
index cf5eab840d57..e5c780eb22d4 100644
--- a/arch/sh/include/asm/io.h
+++ b/arch/sh/include/asm/io.h
@@ -272,9 +272,6 @@ __BUILD_IOPORT_STRING(q, u64)
 #define memset_io memset_io
 #define memcpy_fromio memcpy_fromio
 #define memcpy_toio memcpy_toio
-void memcpy_fromio(void *, const volatile void __iomem *, unsigned long);
-void memcpy_toio(volatile void __iomem *, const void *, unsigned long);
-void memset_io(volatile void __iomem *, int, unsigned long);
 
 /* Quad-word real-mode I/O, don't ask.. */
 unsigned long long peek_real_address_q(unsigned long long addr);
diff --git a/arch/sh/kernel/io.c b/arch/sh/kernel/io.c
index da22f3b32d30..588771cf9b7e 100644
--- a/arch/sh/kernel/io.c
+++ b/arch/sh/kernel/io.c
@@ -13,7 +13,7 @@
 /*
  * Copy data from IO memory space to "real" memory space.
  */
-void memcpy_fromio(void *to, const volatile void __iomem *from, unsigned long count)
+void memcpy_fromio(void *to, const volatile void __iomem *from, size_t count)
 {
 	/*
 	 * Would it be worthwhile doing byte and long transfers first
@@ -76,7 +76,7 @@ EXPORT_SYMBOL(memcpy_fromio);
 /*
  * Copy data from "real" memory space to IO memory space.
  */
-void memcpy_toio(volatile void __iomem *to, const void *from, unsigned long count)
+void memcpy_toio(volatile void __iomem *to, const void *from, size_t count)
 {
 	if ((((u32)to | (u32)from) & 0x3) == 0) {
 		for ( ; count > 3; count -= 4) {
@@ -100,7 +100,7 @@ EXPORT_SYMBOL(memcpy_toio);
  * "memset" on IO memory space.
  * This needs to be optimized.
  */
-void memset_io(volatile void __iomem *dst, int c, unsigned long count)
+void memset_io(volatile void __iomem *dst, int c, size_t count)
 {
         while (count) {
                 count--;
-- 
2.34.1






^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v8 09/14] arm: Align prototype of IO memset
  2024-10-08  7:50 [PATCH v8 00/14] Consolidate IO memcpy functions Julian Vetter
                   ` (7 preceding siblings ...)
  2024-10-08  7:50 ` [PATCH v8 08/14] sh: " Julian Vetter
@ 2024-10-08  7:50 ` Julian Vetter
  2024-10-08  7:50 ` [PATCH v8 10/14] powerpc: Align prototypes of IO memcpy and memset Julian Vetter
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: Julian Vetter @ 2024-10-08  7:50 UTC (permalink / raw)
  To: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
	Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, James E . J . Bottomley, Helge Deller,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao,
	Madhavan Srinivasan, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Niklas Schnelle, Manivannan Sadhasivam, Miquel Raynal,
	Vignesh Raghavendra, Jaroslav Kysela, Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
	linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
	linuxppc-dev, linux-s390, mhi, linux-arm-msm, linux-mtd,
	linux-sound, Yann Sionneau, Julian Vetter, Geert Uytterhoeven

Align prototype of the memset_io function with the new one from
iomap_copy.c

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
Changes for v8:
- No changes
---
 arch/arm/include/asm/io.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 1815748f5d2a..5cff929c3e40 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -298,7 +298,7 @@ extern void _memset_io(volatile void __iomem *, int, size_t);
 #define writesl(p,d,l)		__raw_writesl(p,d,l)
 
 #ifndef __ARMBE__
-static inline void memset_io(volatile void __iomem *dst, unsigned c,
+static inline void memset_io(volatile void __iomem *dst, int c,
 	size_t count)
 {
 	extern void mmioset(void *, unsigned int, size_t);
-- 
2.34.1






^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v8 10/14] powerpc: Align prototypes of IO memcpy and memset
  2024-10-08  7:50 [PATCH v8 00/14] Consolidate IO memcpy functions Julian Vetter
                   ` (8 preceding siblings ...)
  2024-10-08  7:50 ` [PATCH v8 09/14] arm: Align prototype of IO memset Julian Vetter
@ 2024-10-08  7:50 ` Julian Vetter
  2024-10-08  7:50 ` [PATCH v8 11/14] s390: Add wrappers around zpci_memcpy/zpci_memset Julian Vetter
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 23+ messages in thread
From: Julian Vetter @ 2024-10-08  7:50 UTC (permalink / raw)
  To: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
	Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, James E . J . Bottomley, Helge Deller,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao,
	Madhavan Srinivasan, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Niklas Schnelle, Manivannan Sadhasivam, Miquel Raynal,
	Vignesh Raghavendra, Jaroslav Kysela, Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
	linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
	linuxppc-dev, linux-s390, mhi, linux-arm-msm, linux-mtd,
	linux-sound, Yann Sionneau, Julian Vetter

Align the prototypes of the memcpy_{from,to}io and memset_io functions
with the new ones from iomap_copy.c.

Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
Changes for v8:
- New patch
---
 arch/powerpc/include/asm/io-defs.h | 6 +++---
 arch/powerpc/include/asm/io.h      | 6 +++---
 arch/powerpc/kernel/io.c           | 6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/include/asm/io-defs.h b/arch/powerpc/include/asm/io-defs.h
index faf8617cc574..20c3f2671da2 100644
--- a/arch/powerpc/include/asm/io-defs.h
+++ b/arch/powerpc/include/asm/io-defs.h
@@ -53,9 +53,9 @@ DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c),
 DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c),
 		 (p, b, c), pio, p)
 
-DEF_PCI_AC_NORET(memset_io, (PCI_IO_ADDR a, int c, unsigned long n),
+DEF_PCI_AC_NORET(memset_io, (PCI_IO_ADDR a, int c, size_t n),
 		 (a, c, n), mem, a)
-DEF_PCI_AC_NORET(memcpy_fromio, (void *d, const PCI_IO_ADDR s, unsigned long n),
+DEF_PCI_AC_NORET(memcpy_fromio, (void *d, const PCI_IO_ADDR s, size_t n),
 		 (d, s, n), mem, s)
-DEF_PCI_AC_NORET(memcpy_toio, (PCI_IO_ADDR d, const void *s, unsigned long n),
+DEF_PCI_AC_NORET(memcpy_toio, (PCI_IO_ADDR d, const void *s, size_t n),
 		 (d, s, n), mem, d)
diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index 52e1b1d15ff6..b41799a1e2a3 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -246,11 +246,11 @@ extern void _outsl_ns(volatile u32 __iomem *addr, const void *buf, long count);
  * memset_io, memcpy_toio, memcpy_fromio base implementations are out of line
  */
 
-extern void _memset_io(volatile void __iomem *addr, int c, unsigned long n);
+extern void _memset_io(volatile void __iomem *addr, int c, size_t n);
 extern void _memcpy_fromio(void *dest, const volatile void __iomem *src,
-			   unsigned long n);
+			   size_t n);
 extern void _memcpy_toio(volatile void __iomem *dest, const void *src,
-			 unsigned long n);
+			 size_t n);
 
 /*
  *
diff --git a/arch/powerpc/kernel/io.c b/arch/powerpc/kernel/io.c
index 6af535905984..e1848184619b 100644
--- a/arch/powerpc/kernel/io.c
+++ b/arch/powerpc/kernel/io.c
@@ -120,7 +120,7 @@ EXPORT_SYMBOL(_outsl_ns);
 #define IO_CHECK_ALIGN(v,a) ((((unsigned long)(v)) & ((a) - 1)) == 0)
 
 notrace void
-_memset_io(volatile void __iomem *addr, int c, unsigned long n)
+_memset_io(volatile void __iomem *addr, int c, size_t n)
 {
 	void *p = (void __force *)addr;
 	u32 lc = c;
@@ -148,7 +148,7 @@ _memset_io(volatile void __iomem *addr, int c, unsigned long n)
 EXPORT_SYMBOL(_memset_io);
 
 void _memcpy_fromio(void *dest, const volatile void __iomem *src,
-		    unsigned long n)
+		    size_t n)
 {
 	void *vsrc = (void __force *) src;
 
@@ -178,7 +178,7 @@ void _memcpy_fromio(void *dest, const volatile void __iomem *src,
 }
 EXPORT_SYMBOL(_memcpy_fromio);
 
-void _memcpy_toio(volatile void __iomem *dest, const void *src, unsigned long n)
+void _memcpy_toio(volatile void __iomem *dest, const void *src, size_t n)
 {
 	void *vdest = (void __force *) dest;
 
-- 
2.34.1






^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v8 11/14] s390: Add wrappers around zpci_memcpy/zpci_memset
  2024-10-08  7:50 [PATCH v8 00/14] Consolidate IO memcpy functions Julian Vetter
                   ` (9 preceding siblings ...)
  2024-10-08  7:50 ` [PATCH v8 10/14] powerpc: Align prototypes of IO memcpy and memset Julian Vetter
@ 2024-10-08  7:50 ` Julian Vetter
  2024-10-08 13:42   ` Niklas Schnelle
  2024-10-08  7:50 ` [PATCH v8 12/14] bus: mhi: ep: Add HAS_IOMEM || INDIRECT_IOMEM dependency Julian Vetter
                   ` (2 subsequent siblings)
  13 siblings, 1 reply; 23+ messages in thread
From: Julian Vetter @ 2024-10-08  7:50 UTC (permalink / raw)
  To: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
	Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, James E . J . Bottomley, Helge Deller,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao,
	Madhavan Srinivasan, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Niklas Schnelle, Manivannan Sadhasivam, Miquel Raynal,
	Vignesh Raghavendra, Jaroslav Kysela, Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
	linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
	linuxppc-dev, linux-s390, mhi, linux-arm-msm, linux-mtd,
	linux-sound, Yann Sionneau, Julian Vetter

Add wrapper functions around zpci_memcpy_{from,to}io and zpci_memset_io,
which have aligned prototypes with the ones from iomap_copy.c. These
wrappers are necessary because the prototypes of the zpci_ functions
can't be changed. In s390 arch code they are directly being called and
the return value is checked, At the same time they serve as generic
memcpy_{from,to}io and memset_io functions, without a return value.

Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
Changes for v8:
- New patch
---
 arch/s390/include/asm/io.h     | 27 +++++++++++++++++++++++----
 arch/s390/include/asm/pci_io.h |  6 +++---
 2 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/arch/s390/include/asm/io.h b/arch/s390/include/asm/io.h
index 0fbc992d7a5e..f3ef6d4130b3 100644
--- a/arch/s390/include/asm/io.h
+++ b/arch/s390/include/asm/io.h
@@ -58,10 +58,6 @@ static inline void ioport_unmap(void __iomem *p)
 #define pci_iomap_wc pci_iomap_wc
 #define pci_iomap_wc_range pci_iomap_wc_range
 
-#define memcpy_fromio(dst, src, count)	zpci_memcpy_fromio(dst, src, count)
-#define memcpy_toio(dst, src, count)	zpci_memcpy_toio(dst, src, count)
-#define memset_io(dst, val, count)	zpci_memset_io(dst, val, count)
-
 #define mmiowb()	zpci_barrier()
 
 #define __raw_readb	zpci_read_u8
@@ -73,6 +69,10 @@ static inline void ioport_unmap(void __iomem *p)
 #define __raw_writel	zpci_write_u32
 #define __raw_writeq	zpci_write_u64
 
+#define memcpy_fromio memcpy_fromio
+#define memcpy_toio memcpy_toio
+#define memset_io memset_io
+
 /* combine single writes by using store-block insn */
 static inline void __iowrite32_copy(void __iomem *to, const void *from,
 				    size_t count)
@@ -88,6 +88,25 @@ static inline void __iowrite64_copy(void __iomem *to, const void *from,
 }
 #define __iowrite64_copy __iowrite64_copy
 
+static inline void memcpy_fromio(void *dst, const volatile void __iomem *src,
+			    size_t n)
+{
+	zpci_memcpy_fromio(dst, src, n);
+}
+
+static inline void memcpy_toio(volatile void __iomem *dst,
+			      const void *src, size_t n)
+{
+	zpci_memcpy_toio(dst, src, n);
+}
+
+static inline void memset_io(volatile void __iomem *dst,
+			    int val, size_t count)
+{
+	zpci_memset_io(dst, val, count);
+}
+
+
 #endif /* CONFIG_PCI */
 
 #include <asm-generic/io.h>
diff --git a/arch/s390/include/asm/pci_io.h b/arch/s390/include/asm/pci_io.h
index 2686bee800e3..43a5ea4ee20f 100644
--- a/arch/s390/include/asm/pci_io.h
+++ b/arch/s390/include/asm/pci_io.h
@@ -143,7 +143,7 @@ static inline int zpci_get_max_io_size(u64 src, u64 dst, int len, int max)
 
 static inline int zpci_memcpy_fromio(void *dst,
 				     const volatile void __iomem *src,
-				     unsigned long n)
+				     size_t n)
 {
 	int size, rc = 0;
 
@@ -162,7 +162,7 @@ static inline int zpci_memcpy_fromio(void *dst,
 }
 
 static inline int zpci_memcpy_toio(volatile void __iomem *dst,
-				   const void *src, unsigned long n)
+				   const void *src, size_t n)
 {
 	int size, rc = 0;
 
@@ -187,7 +187,7 @@ static inline int zpci_memcpy_toio(volatile void __iomem *dst,
 }
 
 static inline int zpci_memset_io(volatile void __iomem *dst,
-				 unsigned char val, size_t count)
+				 int val, size_t count)
 {
 	u8 *src = kmalloc(count, GFP_KERNEL);
 	int rc;
-- 
2.34.1






^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v8 12/14] bus: mhi: ep: Add HAS_IOMEM || INDIRECT_IOMEM dependency
  2024-10-08  7:50 [PATCH v8 00/14] Consolidate IO memcpy functions Julian Vetter
                   ` (10 preceding siblings ...)
  2024-10-08  7:50 ` [PATCH v8 11/14] s390: Add wrappers around zpci_memcpy/zpci_memset Julian Vetter
@ 2024-10-08  7:50 ` Julian Vetter
  2024-10-08  7:50 ` [PATCH v8 13/14] mtd: " Julian Vetter
  2024-10-08  7:50 ` [PATCH v8 14/14] sound: Make CONFIG_SND depend on INDIRECT_IOMEM instead of UML Julian Vetter
  13 siblings, 0 replies; 23+ messages in thread
From: Julian Vetter @ 2024-10-08  7:50 UTC (permalink / raw)
  To: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
	Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, James E . J . Bottomley, Helge Deller,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao,
	Madhavan Srinivasan, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Niklas Schnelle, Manivannan Sadhasivam, Miquel Raynal,
	Vignesh Raghavendra, Jaroslav Kysela, Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
	linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
	linuxppc-dev, linux-s390, mhi, linux-arm-msm, linux-mtd,
	linux-sound, Yann Sionneau, Julian Vetter

The symbol MHI_BUS_EP neither depends on HAS_IOMEM, nor on
INDIRECT_IOMEM. But, the function mhi_ep_ring_num_elems in
drivers/bus/mhi/ep/ring.c is using a IO memcpy operation. So, when
building for UM which doesn't have CONFIG_HAS_IOMEM=y, the build fails.

Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
Changes for v8:
- New patch
---
 drivers/bus/mhi/ep/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/bus/mhi/ep/Kconfig b/drivers/bus/mhi/ep/Kconfig
index 90ab3b040672..dba95fb95eeb 100644
--- a/drivers/bus/mhi/ep/Kconfig
+++ b/drivers/bus/mhi/ep/Kconfig
@@ -1,5 +1,6 @@
 config MHI_BUS_EP
 	tristate "Modem Host Interface (MHI) bus Endpoint implementation"
+	depends on HAS_IOMEM || INDIRECT_IOMEM
 	help
 	  Bus driver for MHI protocol. Modem Host Interface (MHI) is a
 	  communication protocol used by a host processor to control
-- 
2.34.1






^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v8 13/14] mtd: Add HAS_IOMEM || INDIRECT_IOMEM dependency
  2024-10-08  7:50 [PATCH v8 00/14] Consolidate IO memcpy functions Julian Vetter
                   ` (11 preceding siblings ...)
  2024-10-08  7:50 ` [PATCH v8 12/14] bus: mhi: ep: Add HAS_IOMEM || INDIRECT_IOMEM dependency Julian Vetter
@ 2024-10-08  7:50 ` Julian Vetter
  2024-10-08  8:33   ` Miquel Raynal
  2024-10-08  7:50 ` [PATCH v8 14/14] sound: Make CONFIG_SND depend on INDIRECT_IOMEM instead of UML Julian Vetter
  13 siblings, 1 reply; 23+ messages in thread
From: Julian Vetter @ 2024-10-08  7:50 UTC (permalink / raw)
  To: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
	Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, James E . J . Bottomley, Helge Deller,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao,
	Madhavan Srinivasan, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Niklas Schnelle, Manivannan Sadhasivam, Miquel Raynal,
	Vignesh Raghavendra, Jaroslav Kysela, Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
	linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
	linuxppc-dev, linux-s390, mhi, linux-arm-msm, linux-mtd,
	linux-sound, Yann Sionneau, Julian Vetter

The UM arch doesn't have HAS_IOMEM=y, so the build fails because the
functions memcpy_fromio and memcpy_toio are not defined anymore. These
functions are only build for targets which have HAS_IOMEM=y or
INDIRECT_IOMEM=y. So, depend on either of the two.

Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
Changes for v8:
- New patch
---
 drivers/mtd/chips/Kconfig | 4 ++++
 drivers/mtd/lpddr/Kconfig | 1 +
 2 files changed, 5 insertions(+)

diff --git a/drivers/mtd/chips/Kconfig b/drivers/mtd/chips/Kconfig
index 19726ebd973d..78afe7ccf005 100644
--- a/drivers/mtd/chips/Kconfig
+++ b/drivers/mtd/chips/Kconfig
@@ -4,6 +4,7 @@ menu "RAM/ROM/Flash chip drivers"
 
 config MTD_CFI
 	tristate "Detect flash chips by Common Flash Interface (CFI) probe"
+	depends on HAS_IOMEM || INDIRECT_IOMEM
 	select MTD_GEN_PROBE
 	select MTD_CFI_UTIL
 	help
@@ -16,6 +17,7 @@ config MTD_CFI
 
 config MTD_JEDECPROBE
 	tristate "Detect non-CFI AMD/JEDEC-compatible flash chips"
+	depends on HAS_IOMEM || INDIRECT_IOMEM
 	select MTD_GEN_PROBE
 	select MTD_CFI_UTIL
 	help
@@ -211,12 +213,14 @@ config MTD_CFI_UTIL
 
 config MTD_RAM
 	tristate "Support for RAM chips in bus mapping"
+	depends on HAS_IOMEM || INDIRECT_IOMEM
 	help
 	  This option enables basic support for RAM chips accessed through
 	  a bus mapping driver.
 
 config MTD_ROM
 	tristate "Support for ROM chips in bus mapping"
+	depends on HAS_IOMEM || INDIRECT_IOMEM
 	help
 	  This option enables basic support for ROM chips accessed through
 	  a bus mapping driver.
diff --git a/drivers/mtd/lpddr/Kconfig b/drivers/mtd/lpddr/Kconfig
index 0395aa6b68f1..f35dd8052abc 100644
--- a/drivers/mtd/lpddr/Kconfig
+++ b/drivers/mtd/lpddr/Kconfig
@@ -4,6 +4,7 @@ menu "LPDDR & LPDDR2 PCM memory drivers"
 
 config MTD_LPDDR
 	tristate "Support for LPDDR flash chips"
+	depends on HAS_IOMEM || INDIRECT_IOMEM
 	select MTD_QINFO_PROBE
 	help
 	  This option enables support of LPDDR (Low power double data rate)
-- 
2.34.1






^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH v8 14/14] sound: Make CONFIG_SND depend on INDIRECT_IOMEM instead of UML
  2024-10-08  7:50 [PATCH v8 00/14] Consolidate IO memcpy functions Julian Vetter
                   ` (12 preceding siblings ...)
  2024-10-08  7:50 ` [PATCH v8 13/14] mtd: " Julian Vetter
@ 2024-10-08  7:50 ` Julian Vetter
  2024-10-08  8:16   ` Takashi Iwai
  13 siblings, 1 reply; 23+ messages in thread
From: Julian Vetter @ 2024-10-08  7:50 UTC (permalink / raw)
  To: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
	Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, James E . J . Bottomley, Helge Deller,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao,
	Madhavan Srinivasan, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Niklas Schnelle, Manivannan Sadhasivam, Miquel Raynal,
	Vignesh Raghavendra, Jaroslav Kysela, Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
	linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
	linuxppc-dev, linux-s390, mhi, linux-arm-msm, linux-mtd,
	linux-sound, Yann Sionneau, Julian Vetter

When building for the UM arch and neither INDIRECT_IOMEM=y, nor
HAS_IOMEM=y is selected, the build fails because the memcpy_fromio and
memcpy_toio functions are not defined. Fix it here by depending on
HAS_IOMEM or INDIRECT_IOMEM.

Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
Changes for v8:
- New patch
---
 sound/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/Kconfig b/sound/Kconfig
index 4c036a9a420a..8b40205394fe 100644
--- a/sound/Kconfig
+++ b/sound/Kconfig
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 menuconfig SOUND
 	tristate "Sound card support"
-	depends on HAS_IOMEM || UML
+	depends on HAS_IOMEM || INDIRECT_IOMEM
 	help
 	  If you have a sound card in your computer, i.e. if it can say more
 	  than an occasional beep, say Y.
-- 
2.34.1






^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH v8 14/14] sound: Make CONFIG_SND depend on INDIRECT_IOMEM instead of UML
  2024-10-08  7:50 ` [PATCH v8 14/14] sound: Make CONFIG_SND depend on INDIRECT_IOMEM instead of UML Julian Vetter
@ 2024-10-08  8:16   ` Takashi Iwai
  0 siblings, 0 replies; 23+ messages in thread
From: Takashi Iwai @ 2024-10-08  8:16 UTC (permalink / raw)
  To: Julian Vetter
  Cc: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
	Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, James E . J . Bottomley, Helge Deller,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao,
	Madhavan Srinivasan, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Niklas Schnelle, Manivannan Sadhasivam, Miquel Raynal,
	Vignesh Raghavendra, Jaroslav Kysela, Takashi Iwai,
	linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
	linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
	linuxppc-dev, linux-s390, mhi, linux-arm-msm, linux-mtd,
	linux-sound, Yann Sionneau

On Tue, 08 Oct 2024 09:50:22 +0200,
Julian Vetter wrote:
> 
> When building for the UM arch and neither INDIRECT_IOMEM=y, nor
> HAS_IOMEM=y is selected, the build fails because the memcpy_fromio and
> memcpy_toio functions are not defined. Fix it here by depending on
> HAS_IOMEM or INDIRECT_IOMEM.
> 
> Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
> Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
> ---
> Changes for v8:
> - New patch
> ---
>  sound/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/Kconfig b/sound/Kconfig
> index 4c036a9a420a..8b40205394fe 100644
> --- a/sound/Kconfig
> +++ b/sound/Kconfig
> @@ -1,7 +1,7 @@
>  # SPDX-License-Identifier: GPL-2.0-only
>  menuconfig SOUND
>  	tristate "Sound card support"
> -	depends on HAS_IOMEM || UML
> +	depends on HAS_IOMEM || INDIRECT_IOMEM
>  	help
>  	  If you have a sound card in your computer, i.e. if it can say more
>  	  than an occasional beep, say Y.

Acked-by: Takashi Iwai <tiwai@suse.de>


thanks,

Takashi

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v8 13/14] mtd: Add HAS_IOMEM || INDIRECT_IOMEM dependency
  2024-10-08  7:50 ` [PATCH v8 13/14] mtd: " Julian Vetter
@ 2024-10-08  8:33   ` Miquel Raynal
  0 siblings, 0 replies; 23+ messages in thread
From: Miquel Raynal @ 2024-10-08  8:33 UTC (permalink / raw)
  To: Julian Vetter
  Cc: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
	Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, James E . J . Bottomley, Helge Deller,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao,
	Madhavan Srinivasan, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Niklas Schnelle, Manivannan Sadhasivam, Vignesh Raghavendra,
	Jaroslav Kysela, Takashi Iwai, linux-arm-kernel, linux-kernel,
	linux-csky, loongarch, linux-m68k, linux-alpha, linux-parisc,
	linux-sh, linux-um, linux-arch, linuxppc-dev, linux-s390, mhi,
	linux-arm-msm, linux-mtd, linux-sound, Yann Sionneau

Hi Julian,

jvetter@kalrayinc.com wrote on Tue,  8 Oct 2024 09:50:21 +0200:

> The UM arch doesn't have HAS_IOMEM=y, so the build fails because the
> functions memcpy_fromio and memcpy_toio are not defined anymore. These
> functions are only build for targets which have HAS_IOMEM=y or
> INDIRECT_IOMEM=y. So, depend on either of the two.

There are many mtd drivers using memcpy_fromio and memcpy_toio, I'm not
sure I get why only this subset of drivers would be impacted?

Also, from a general standpoint, I don't see with a good eye the
proliferation of the use of || INDIRECT_IOMEM just for the um
architecture:

$ git grep HAS_IOMEM | wc -l
611
$ git grep INDIRECT_IOMEM | wc -l
15

I believe the Kconfig symbol should adapt to reflect the fact that IO
operations are fine, regardless of their type ("direct" or "indirect")
rather than move the load on the individual drivers.

> Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
> Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
> ---
> Changes for v8:
> - New patch
> ---
>  drivers/mtd/chips/Kconfig | 4 ++++
>  drivers/mtd/lpddr/Kconfig | 1 +
>  2 files changed, 5 insertions(+)
> 
> diff --git a/drivers/mtd/chips/Kconfig b/drivers/mtd/chips/Kconfig
> index 19726ebd973d..78afe7ccf005 100644
> --- a/drivers/mtd/chips/Kconfig
> +++ b/drivers/mtd/chips/Kconfig
> @@ -4,6 +4,7 @@ menu "RAM/ROM/Flash chip drivers"
>  
>  config MTD_CFI
>  	tristate "Detect flash chips by Common Flash Interface (CFI) probe"
> +	depends on HAS_IOMEM || INDIRECT_IOMEM
>  	select MTD_GEN_PROBE
>  	select MTD_CFI_UTIL
>  	help
> @@ -16,6 +17,7 @@ config MTD_CFI
>  
>  config MTD_JEDECPROBE
>  	tristate "Detect non-CFI AMD/JEDEC-compatible flash chips"
> +	depends on HAS_IOMEM || INDIRECT_IOMEM
>  	select MTD_GEN_PROBE
>  	select MTD_CFI_UTIL
>  	help
> @@ -211,12 +213,14 @@ config MTD_CFI_UTIL
>  
>  config MTD_RAM
>  	tristate "Support for RAM chips in bus mapping"
> +	depends on HAS_IOMEM || INDIRECT_IOMEM
>  	help
>  	  This option enables basic support for RAM chips accessed through
>  	  a bus mapping driver.
>  
>  config MTD_ROM
>  	tristate "Support for ROM chips in bus mapping"
> +	depends on HAS_IOMEM || INDIRECT_IOMEM
>  	help
>  	  This option enables basic support for ROM chips accessed through
>  	  a bus mapping driver.
> diff --git a/drivers/mtd/lpddr/Kconfig b/drivers/mtd/lpddr/Kconfig
> index 0395aa6b68f1..f35dd8052abc 100644
> --- a/drivers/mtd/lpddr/Kconfig
> +++ b/drivers/mtd/lpddr/Kconfig
> @@ -4,6 +4,7 @@ menu "LPDDR & LPDDR2 PCM memory drivers"
>  
>  config MTD_LPDDR
>  	tristate "Support for LPDDR flash chips"
> +	depends on HAS_IOMEM || INDIRECT_IOMEM
>  	select MTD_QINFO_PROBE
>  	help
>  	  This option enables support of LPDDR (Low power double data rate)


Thanks,
Miquèl

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v8 01/14] Consolidate IO memcpy/memset into iomap_copy.c
  2024-10-08  7:50 ` [PATCH v8 01/14] Consolidate IO memcpy/memset into iomap_copy.c Julian Vetter
@ 2024-10-08  9:27   ` Arnd Bergmann
  2024-10-08  9:32     ` Christoph Hellwig
  2024-10-08 11:46   ` Christoph Hellwig
  1 sibling, 1 reply; 23+ messages in thread
From: Arnd Bergmann @ 2024-10-08  9:27 UTC (permalink / raw)
  To: Julian Vetter, Russell King, Catalin Marinas, Will Deacon, guoren,
	Huacai Chen, WANG Xuerui, Andrew Morton, Geert Uytterhoeven,
	Richard Henderson, Ivan Kokshaysky, Matt Turner,
	James E . J . Bottomley, Helge Deller, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Naveen N Rao, Madhavan Srinivasan,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Niklas Schnelle,
	Manivannan Sadhasivam, Miquel Raynal, Vignesh Raghavendra,
	Jaroslav Kysela, Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-csky@vger.kernel.org,
	loongarch, linux-m68k, linux-alpha, linux-parisc, linux-sh,
	linux-um, Linux-Arch, linuxppc-dev, linux-s390, mhi,
	linux-arm-msm, linux-mtd, linux-sound, Yann Sionneau

On Tue, Oct 8, 2024, at 07:50, Julian Vetter wrote:
> diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
> index 80de699bf6af..f14655ed4d9d 100644
> --- a/include/asm-generic/io.h
> +++ b/include/asm-generic/io.h
> @@ -102,6 +102,12 @@ static inline void log_post_read_mmio(u64 val, u8 
> width, const volatile void __i
> 
>  #endif /* CONFIG_TRACE_MMIO_ACCESS */
> 
> +extern void memcpy_fromio(void *to, const volatile void __iomem *from,
> +			  size_t count);
> +extern void memcpy_toio(volatile void __iomem *to, const void *from,
> +			size_t count);
> +extern void memset_io(volatile void __iomem *dst, int c, size_t count);
> +

I think having this globally visible is the reason you are running
into the mismatched prototypes. The patches to change the architecture
specific implementations are all good, but I would instead add
#ifdef checks around the prototypes the same way you do for the
implementation, to make the series bisectible and shorter.

 include/asm-generic/io.h |  58 ++----------------
 lib/iomap_copy.c         | 127 +++++++++++++++++++++++++++++++++++++++

Along the same lines, I would change lib/Makefile to build
this file unconditionally even on architectures that don't
set CONFIG_HAS_IOMEM. Again, strengthening the driver dependencies
is good, but it feels like a distraction here when we just need the
common implementation to be available.

       Arnd

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v8 01/14] Consolidate IO memcpy/memset into iomap_copy.c
  2024-10-08  9:27   ` Arnd Bergmann
@ 2024-10-08  9:32     ` Christoph Hellwig
  0 siblings, 0 replies; 23+ messages in thread
From: Christoph Hellwig @ 2024-10-08  9:32 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Julian Vetter, Russell King, Catalin Marinas, Will Deacon, guoren,
	Huacai Chen, WANG Xuerui, Andrew Morton, Geert Uytterhoeven,
	Richard Henderson, Ivan Kokshaysky, Matt Turner,
	James E . J . Bottomley, Helge Deller, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Naveen N Rao, Madhavan Srinivasan,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Niklas Schnelle,
	Manivannan Sadhasivam, Miquel Raynal, Vignesh Raghavendra,
	Jaroslav Kysela, Takashi Iwai, linux-arm-kernel, linux-kernel,
	linux-csky@vger.kernel.org, loongarch, linux-m68k, linux-alpha,
	linux-parisc, linux-sh, linux-um, Linux-Arch, linuxppc-dev,
	linux-s390, mhi, linux-arm-msm, linux-mtd, linux-sound,
	Yann Sionneau

On Tue, Oct 08, 2024 at 09:27:20AM +0000, Arnd Bergmann wrote:
> >  #endif /* CONFIG_TRACE_MMIO_ACCESS */
> > 
> > +extern void memcpy_fromio(void *to, const volatile void __iomem *from,
> > +			  size_t count);
> > +extern void memcpy_toio(volatile void __iomem *to, const void *from,
> > +			size_t count);
> > +extern void memset_io(volatile void __iomem *dst, int c, size_t count);
> > +
> 
> I think having this globally visible is the reason you are running
> into the mismatched prototypes.

Yes, especially as architectures sometimes actually implement this
as macro or inline function.

Please also drop the pointless externs while you're at it.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v8 01/14] Consolidate IO memcpy/memset into iomap_copy.c
  2024-10-08  7:50 ` [PATCH v8 01/14] Consolidate IO memcpy/memset into iomap_copy.c Julian Vetter
  2024-10-08  9:27   ` Arnd Bergmann
@ 2024-10-08 11:46   ` Christoph Hellwig
  2024-10-08 12:29     ` Arnd Bergmann
  1 sibling, 1 reply; 23+ messages in thread
From: Christoph Hellwig @ 2024-10-08 11:46 UTC (permalink / raw)
  To: Julian Vetter
  Cc: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
	Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, James E . J . Bottomley, Helge Deller,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao,
	Madhavan Srinivasan, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Niklas Schnelle, Manivannan Sadhasivam, Miquel Raynal,
	Vignesh Raghavendra, Jaroslav Kysela, Takashi Iwai,
	linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
	linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
	linuxppc-dev, linux-s390, mhi, linux-arm-msm, linux-mtd,
	linux-sound, Yann Sionneau

On Tue, Oct 08, 2024 at 09:50:09AM +0200, Julian Vetter wrote:
>  lib/iomap_copy.c         | 127 +++++++++++++++++++++++++++++++++++++++

On top of the previous comments:  this really should be iomem_copy.c
instead.


^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v8 01/14] Consolidate IO memcpy/memset into iomap_copy.c
  2024-10-08 11:46   ` Christoph Hellwig
@ 2024-10-08 12:29     ` Arnd Bergmann
  0 siblings, 0 replies; 23+ messages in thread
From: Arnd Bergmann @ 2024-10-08 12:29 UTC (permalink / raw)
  To: Christoph Hellwig, Julian Vetter
  Cc: Russell King, Catalin Marinas, Will Deacon, guoren, Huacai Chen,
	WANG Xuerui, Andrew Morton, Geert Uytterhoeven, Richard Henderson,
	Ivan Kokshaysky, Matt Turner, James E . J . Bottomley,
	Helge Deller, Yoshinori Sato, Rich Felker,
	John Paul Adrian Glaubitz, Richard Weinberger, Anton Ivanov,
	Johannes Berg, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Naveen N Rao, Madhavan Srinivasan,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Niklas Schnelle,
	Manivannan Sadhasivam, Miquel Raynal, Vignesh Raghavendra,
	Jaroslav Kysela, Takashi Iwai, linux-arm-kernel, linux-kernel,
	linux-csky@vger.kernel.org, loongarch, linux-m68k, linux-alpha,
	linux-parisc, linux-sh, linux-um, Linux-Arch, linuxppc-dev,
	linux-s390, mhi, linux-arm-msm, linux-mtd, linux-sound,
	Yann Sionneau

On Tue, Oct 8, 2024, at 11:46, Christoph Hellwig wrote:
> On Tue, Oct 08, 2024 at 09:50:09AM +0200, Julian Vetter wrote:
>>  lib/iomap_copy.c         | 127 +++++++++++++++++++++++++++++++++++++++
>
> On top of the previous comments:  this really should be iomem_copy.c
> instead.

Right, I suggested adding it to the existing file since the
functions are logically related, but the naming of that file
identifiers in it is unfortunate:

__iowrite32_copy/__iowrite64_copy/__ioread32_copy sound like
they are meant to work on both IORESOURCE_MEM and IORESOURCE_IO
mappings the same way that iowrite64/ioread64/ioread32 do,
but actually using them on x86 port I/O (from pci_iomap or
ioport_map) would lead to a NULL pointer dereference.

      Arnd

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v8 11/14] s390: Add wrappers around zpci_memcpy/zpci_memset
  2024-10-08  7:50 ` [PATCH v8 11/14] s390: Add wrappers around zpci_memcpy/zpci_memset Julian Vetter
@ 2024-10-08 13:42   ` Niklas Schnelle
  0 siblings, 0 replies; 23+ messages in thread
From: Niklas Schnelle @ 2024-10-08 13:42 UTC (permalink / raw)
  To: Julian Vetter, Arnd Bergmann, Russell King, Catalin Marinas,
	Will Deacon, Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, James E . J . Bottomley, Helge Deller,
	Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz,
	Richard Weinberger, Anton Ivanov, Johannes Berg, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy, Naveen N Rao,
	Madhavan Srinivasan, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Manivannan Sadhasivam, Miquel Raynal, Vignesh Raghavendra,
	Jaroslav Kysela, Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
	linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
	linuxppc-dev, linux-s390, mhi, linux-arm-msm, linux-mtd,
	linux-sound, Yann Sionneau

On Tue, 2024-10-08 at 09:50 +0200, Julian Vetter wrote:
> Add wrapper functions around zpci_memcpy_{from,to}io and zpci_memset_io,
> which have aligned prototypes with the ones from iomap_copy.c. These
> wrappers are necessary because the prototypes of the zpci_ functions
> can't be changed. In s390 arch code they are directly being called and
> the return value is checked, At the same time they serve as generic
> memcpy_{from,to}io and memset_io functions, without a return value.
> 
> Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
> Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
> ---
> Changes for v8:
> - New patch
> ---
>  arch/s390/include/asm/io.h     | 27 +++++++++++++++++++++++----
>  arch/s390/include/asm/pci_io.h |  6 +++---
>  2 files changed, 26 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/s390/include/asm/io.h b/arch/s390/include/asm/io.h
> index 0fbc992d7a5e..f3ef6d4130b3 100644
> --- a/arch/s390/include/asm/io.h
> +++ b/arch/s390/include/asm/io.h
> @@ -58,10 +58,6 @@ static inline void ioport_unmap(void __iomem *p)
>  #define pci_iomap_wc pci_iomap_wc
>  #define pci_iomap_wc_range pci_iomap_wc_range
>  
> -#define memcpy_fromio(dst, src, count)	zpci_memcpy_fromio(dst, src, count)
> -#define memcpy_toio(dst, src, count)	zpci_memcpy_toio(dst, src, count)
> -#define memset_io(dst, val, count)	zpci_memset_io(dst, val, count)
> -
>  #define mmiowb()	zpci_barrier()
>  
>  #define __raw_readb	zpci_read_u8
> @@ -73,6 +69,10 @@ static inline void ioport_unmap(void __iomem *p)
>  #define __raw_writel	zpci_write_u32
>  #define __raw_writeq	zpci_write_u64
>  
> +#define memcpy_fromio memcpy_fromio
> +#define memcpy_toio memcpy_toio
> +#define memset_io memset_io
> +
>  /* combine single writes by using store-block insn */
>  static inline void __iowrite32_copy(void __iomem *to, const void *from,
>  				    size_t count)
> @@ -88,6 +88,25 @@ static inline void __iowrite64_copy(void __iomem *to, const void *from,
>  }
>  #define __iowrite64_copy __iowrite64_copy
>  
> +static inline void memcpy_fromio(void *dst, const volatile void __iomem *src,
> +			    size_t n)
> +{
> +	zpci_memcpy_fromio(dst, src, n);
> +}
> +
> +static inline void memcpy_toio(volatile void __iomem *dst,
> +			      const void *src, size_t n)
> +{
> +	zpci_memcpy_toio(dst, src, n);
> +}
> +
> +static inline void memset_io(volatile void __iomem *dst,
> +			    int val, size_t count)
> +{
> +	zpci_memset_io(dst, val, count);
> +}
> +
> +
>  #endif /* CONFIG_PCI */
>  
>  #include <asm-generic/io.h>
> diff --git a/arch/s390/include/asm/pci_io.h b/arch/s390/include/asm/pci_io.h
> index 2686bee800e3..43a5ea4ee20f 100644
> --- a/arch/s390/include/asm/pci_io.h
> +++ b/arch/s390/include/asm/pci_io.h
> @@ -143,7 +143,7 @@ static inline int zpci_get_max_io_size(u64 src, u64 dst, int len, int max)
>  
>  static inline int zpci_memcpy_fromio(void *dst,
>  				     const volatile void __iomem *src,
> -				     unsigned long n)
> +				     size_t n)
>  {
>  	int size, rc = 0;
>  
> @@ -162,7 +162,7 @@ static inline int zpci_memcpy_fromio(void *dst,
>  }
>  
>  static inline int zpci_memcpy_toio(volatile void __iomem *dst,
> -				   const void *src, unsigned long n)
> +				   const void *src, size_t n)
>  {
>  	int size, rc = 0;
>  
> @@ -187,7 +187,7 @@ static inline int zpci_memcpy_toio(volatile void __iomem *dst,
>  }
>  
>  static inline int zpci_memset_io(volatile void __iomem *dst,
> -				 unsigned char val, size_t count)
> +				 int val, size_t count)
>  {
>  	u8 *src = kmalloc(count, GFP_KERNEL);
>  	int rc;

The code makes sense to me. If I understand Arnd's comment correctly
the wrappers may not be necessary if you don't have the global
prototypes though, right? In this case I think we might want to still
align the parameter types as this seems generally cleaner and the
internal callers already use size_t anyway.

Either way I gave the whole series a quick test on s390x with PCI
devices and all looks good. So feel free to add:

Acked-by: Niklas Schnelle <schnelle@linux.ibm.com>
Tested-by: Niklas Schnelle <schnelle@linux.ibm.com>

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH v8 06/14] alpha: Align prototypes of IO memcpy/memset
  2024-10-08  7:50 ` [PATCH v8 06/14] alpha: " Julian Vetter
@ 2024-10-08 14:54   ` Richard Henderson
  0 siblings, 0 replies; 23+ messages in thread
From: Richard Henderson @ 2024-10-08 14:54 UTC (permalink / raw)
  To: Julian Vetter, Arnd Bergmann, Russell King, Catalin Marinas,
	Will Deacon, Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
	Geert Uytterhoeven, Ivan Kokshaysky, Matt Turner,
	James E . J . Bottomley, Helge Deller, Yoshinori Sato,
	Rich Felker, John Paul Adrian Glaubitz, Richard Weinberger,
	Anton Ivanov, Johannes Berg, Michael Ellerman, Nicholas Piggin,
	Christophe Leroy, Naveen N Rao, Madhavan Srinivasan,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, Niklas Schnelle,
	Manivannan Sadhasivam, Miquel Raynal, Vignesh Raghavendra,
	Jaroslav Kysela, Takashi Iwai
  Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
	linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
	linuxppc-dev, linux-s390, mhi, linux-arm-msm, linux-mtd,
	linux-sound, Yann Sionneau

On 10/8/24 00:50, Julian Vetter wrote:
> Align the prototypes of the memcpy_{from,to}io and memset_io functions
> with the new ones from iomap_copy.c and remove function declarations,
> because they are now declared in asm-generic/io.h.
> 
> Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
> Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
> ---
> Changes for v8:
> - Mask the argument with 0xff because now it's an int and not a u8
>    anymore


Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
> ---
>   arch/alpha/include/asm/io.h | 6 ++----
>   arch/alpha/kernel/io.c      | 4 ++--
>   2 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/alpha/include/asm/io.h b/arch/alpha/include/asm/io.h
> index b191d87f89c4..e7d52c8159b0 100644
> --- a/arch/alpha/include/asm/io.h
> +++ b/arch/alpha/include/asm/io.h
> @@ -591,13 +591,11 @@ extern inline u64 readq_relaxed(const volatile void __iomem *addr)
>   /*
>    * String version of IO memory access ops:
>    */
> -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);
>   
> -static inline void memset_io(volatile void __iomem *addr, u8 c, long len)
> +static inline void memset_io(volatile void __iomem *dst, int c, size_t count)
>   {
> -	_memset_c_io(addr, 0x0101010101010101UL * c, len);
> +	_memset_c_io(dst, 0x0101010101010101UL * (c & 0xff), count);
>   }
>   
>   #define __HAVE_ARCH_MEMSETW_IO
> diff --git a/arch/alpha/kernel/io.c b/arch/alpha/kernel/io.c
> index c28035d6d1e6..69c06f1b158d 100644
> --- a/arch/alpha/kernel/io.c
> +++ b/arch/alpha/kernel/io.c
> @@ -481,7 +481,7 @@ EXPORT_SYMBOL(outsl);
>    * Copy data from IO memory space to "real" memory space.
>    * This needs to be optimized.
>    */
> -void memcpy_fromio(void *to, const volatile void __iomem *from, long count)
> +void memcpy_fromio(void *to, const volatile void __iomem *from, size_t count)
>   {
>   	/* Optimize co-aligned transfers.  Everything else gets handled
>   	   a byte at a time. */
> @@ -535,7 +535,7 @@ EXPORT_SYMBOL(memcpy_fromio);
>    * Copy data from "real" memory space to IO memory space.
>    * This needs to be optimized.
>    */
> -void memcpy_toio(volatile void __iomem *to, const void *from, long count)
> +void memcpy_toio(volatile void __iomem *to, const void *from, size_t count)
>   {
>   	/* Optimize co-aligned transfers.  Everything else gets handled
>   	   a byte at a time. */


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2024-10-08 14:54 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-08  7:50 [PATCH v8 00/14] Consolidate IO memcpy functions Julian Vetter
2024-10-08  7:50 ` [PATCH v8 01/14] Consolidate IO memcpy/memset into iomap_copy.c Julian Vetter
2024-10-08  9:27   ` Arnd Bergmann
2024-10-08  9:32     ` Christoph Hellwig
2024-10-08 11:46   ` Christoph Hellwig
2024-10-08 12:29     ` Arnd Bergmann
2024-10-08  7:50 ` [PATCH v8 02/14] arm64: Use generic IO memcpy/memset Julian Vetter
2024-10-08  7:50 ` [PATCH v8 03/14] csky: " Julian Vetter
2024-10-08  7:50 ` [PATCH v8 04/14] loongarch: " Julian Vetter
2024-10-08  7:50 ` [PATCH v8 05/14] m68k: Align prototypes of " Julian Vetter
2024-10-08  7:50 ` [PATCH v8 06/14] alpha: " Julian Vetter
2024-10-08 14:54   ` Richard Henderson
2024-10-08  7:50 ` [PATCH v8 07/14] parisc: " Julian Vetter
2024-10-08  7:50 ` [PATCH v8 08/14] sh: " Julian Vetter
2024-10-08  7:50 ` [PATCH v8 09/14] arm: Align prototype of IO memset Julian Vetter
2024-10-08  7:50 ` [PATCH v8 10/14] powerpc: Align prototypes of IO memcpy and memset Julian Vetter
2024-10-08  7:50 ` [PATCH v8 11/14] s390: Add wrappers around zpci_memcpy/zpci_memset Julian Vetter
2024-10-08 13:42   ` Niklas Schnelle
2024-10-08  7:50 ` [PATCH v8 12/14] bus: mhi: ep: Add HAS_IOMEM || INDIRECT_IOMEM dependency Julian Vetter
2024-10-08  7:50 ` [PATCH v8 13/14] mtd: " Julian Vetter
2024-10-08  8:33   ` Miquel Raynal
2024-10-08  7:50 ` [PATCH v8 14/14] sound: Make CONFIG_SND depend on INDIRECT_IOMEM instead of UML Julian Vetter
2024-10-08  8:16   ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).