* [PATCH v7 00/10] Consolidate IO memcpy functions
@ 2024-09-30 13:23 Julian Vetter
2024-09-30 13:23 ` [PATCH v7 01/10] Consolidate IO memcpy/memset into iomap_copy.c Julian Vetter
` (10 more replies)
0 siblings, 11 replies; 23+ messages in thread
From: Julian Vetter @ 2024-09-30 13:23 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
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
Yann Sionneau, Julian Vetter
Thank you all for your remarks. I have addressed your feedback. I have
also added the full history of the patchset, because it now targets
additional architectures.
Arnd: Unfortunately when adding the prototypes as 'extern ..' into
asm-generic/io.h they conflict with some individual implementations
(namely m68k, alpha, parisc, and sh). So, I have aligned these functions
to match the prototypes in asm-generic/io.h.
For the um problem, unfortunately there are A LOT of drivers that use
these IO memcpy functions, so I went a bit the lazy route and added
dummy functions to um's io.h.
David: Thank you for your remarks. I have replaced the mix of long,
uintptr_t, etc. all by long + sizeof(long). I have also split the
read/write operation from the put/get_unaligned into two lines for
better readability.
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
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 (10):
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
um: Add dummy implementation for IO memcpy/memset
arm: Align prototype of IO memset
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 | 6 +-
arch/sh/include/asm/io.h | 3 -
arch/sh/kernel/io.c | 6 +-
arch/um/include/asm/io.h | 17 ++++
include/asm-generic/io.h | 58 ++------------
lib/iomap_copy.c | 133 ++++++++++++++++++++++++++++++++
19 files changed, 173 insertions(+), 381 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 v7 01/10] Consolidate IO memcpy/memset into iomap_copy.c
2024-09-30 13:23 [PATCH v7 00/10] Consolidate IO memcpy functions Julian Vetter
@ 2024-09-30 13:23 ` Julian Vetter
2024-10-03 4:23 ` kernel test robot
2024-10-03 16:46 ` Richard Henderson
2024-09-30 13:23 ` [PATCH v7 02/10] arm64: Use generic IO memcpy/memset Julian Vetter
` (9 subsequent siblings)
10 siblings, 2 replies; 23+ messages in thread
From: Julian Vetter @ 2024-09-30 13:23 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
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
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 v7:
- Addressed reviewer comments from David:
- Replaced NATIVE_STORE_TYPE and uintptr_t by long
- Split the read/write and the {get,put}_unaligned into two different
lines for readability
- Addressed reviewer comments from Arnd:
- Placed "extern" definitions in asm-generic/io.h
- Renamed functions from __memcpy_{to,from}io and __memset_io
to memcpy_{to,from}io and memset_io
- Removed the guarding '#ifndef __memcpy_fromio', etc.
---
include/asm-generic/io.h | 58 ++---------------
lib/iomap_copy.c | 133 +++++++++++++++++++++++++++++++++++++++
2 files changed, 139 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..5567bf8db8bc 100644
--- a/lib/iomap_copy.c
+++ b/lib/iomap_copy.c
@@ -3,7 +3,11 @@
* Copyright 2006 PathScale, Inc. All Rights Reserved.
*/
+#include <asm/unaligned.h>
+
+#include <linux/align.h>
#include <linux/export.h>
+#include <linux/types.h>
#include <linux/io.h>
/**
@@ -76,3 +80,132 @@ 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)
+{
+ uintptr_t qc = (u8)c;
+
+ qc |= qc << 8;
+ qc |= qc << 16;
+
+#ifdef CONFIG_64BIT
+ qc |= qc << 32;
+#endif
+
+ 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 v7 02/10] arm64: Use generic IO memcpy/memset
2024-09-30 13:23 [PATCH v7 00/10] Consolidate IO memcpy functions Julian Vetter
2024-09-30 13:23 ` [PATCH v7 01/10] Consolidate IO memcpy/memset into iomap_copy.c Julian Vetter
@ 2024-09-30 13:23 ` Julian Vetter
2024-09-30 13:23 ` [PATCH v7 03/10] csky: " Julian Vetter
` (8 subsequent siblings)
10 siblings, 0 replies; 23+ messages in thread
From: Julian Vetter @ 2024-09-30 13:23 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
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
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 v7:
- 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 41fd90895dfc..9a5d4387e694 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 v7 03/10] csky: Use generic IO memcpy/memset
2024-09-30 13:23 [PATCH v7 00/10] Consolidate IO memcpy functions Julian Vetter
2024-09-30 13:23 ` [PATCH v7 01/10] Consolidate IO memcpy/memset into iomap_copy.c Julian Vetter
2024-09-30 13:23 ` [PATCH v7 02/10] arm64: Use generic IO memcpy/memset Julian Vetter
@ 2024-09-30 13:23 ` Julian Vetter
2024-09-30 13:23 ` [PATCH v7 04/10] loongarch: " Julian Vetter
` (7 subsequent siblings)
10 siblings, 0 replies; 23+ messages in thread
From: Julian Vetter @ 2024-09-30 13:23 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
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
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 v7:
- 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 v7 04/10] loongarch: Use generic IO memcpy/memset
2024-09-30 13:23 [PATCH v7 00/10] Consolidate IO memcpy functions Julian Vetter
` (2 preceding siblings ...)
2024-09-30 13:23 ` [PATCH v7 03/10] csky: " Julian Vetter
@ 2024-09-30 13:23 ` Julian Vetter
2024-09-30 13:23 ` [PATCH v7 05/10] m68k: Align prototypes of " Julian Vetter
` (6 subsequent siblings)
10 siblings, 0 replies; 23+ messages in thread
From: Julian Vetter @ 2024-09-30 13:23 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
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
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 v7:
- 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 v7 05/10] m68k: Align prototypes of IO memcpy/memset
2024-09-30 13:23 [PATCH v7 00/10] Consolidate IO memcpy functions Julian Vetter
` (3 preceding siblings ...)
2024-09-30 13:23 ` [PATCH v7 04/10] loongarch: " Julian Vetter
@ 2024-09-30 13:23 ` Julian Vetter
2024-09-30 17:46 ` Geert Uytterhoeven
2024-09-30 13:23 ` [PATCH v7 06/10] alpha: " Julian Vetter
` (5 subsequent siblings)
10 siblings, 1 reply; 23+ messages in thread
From: Julian Vetter @ 2024-09-30 13:23 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
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
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 v7:
- New patch
---
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 v7 06/10] alpha: Align prototypes of IO memcpy/memset
2024-09-30 13:23 [PATCH v7 00/10] Consolidate IO memcpy functions Julian Vetter
` (4 preceding siblings ...)
2024-09-30 13:23 ` [PATCH v7 05/10] m68k: Align prototypes of " Julian Vetter
@ 2024-09-30 13:23 ` Julian Vetter
2024-10-03 14:46 ` Richard Henderson
2024-09-30 13:23 ` [PATCH v7 07/10] parisc: " Julian Vetter
` (4 subsequent siblings)
10 siblings, 1 reply; 23+ messages in thread
From: Julian Vetter @ 2024-09-30 13:23 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
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
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 v7:
- New patch
---
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..db3a9f41447e 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, 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 v7 07/10] parisc: Align prototypes of IO memcpy/memset
2024-09-30 13:23 [PATCH v7 00/10] Consolidate IO memcpy functions Julian Vetter
` (5 preceding siblings ...)
2024-09-30 13:23 ` [PATCH v7 06/10] alpha: " Julian Vetter
@ 2024-09-30 13:23 ` Julian Vetter
2024-10-03 14:49 ` Richard Henderson
2024-09-30 13:23 ` [PATCH v7 08/10] sh: " Julian Vetter
` (3 subsequent siblings)
10 siblings, 1 reply; 23+ messages in thread
From: Julian Vetter @ 2024-09-30 13:23 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
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
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 v7:
- New patch
---
arch/parisc/include/asm/io.h | 3 ---
arch/parisc/lib/io.c | 6 +++---
2 files changed, 3 insertions(+), 6 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..1e63112ba9c9 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,7 +103,7 @@ 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;
while ((unsigned long)addr & 3) {
--
2.34.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v7 08/10] sh: Align prototypes of IO memcpy/memset
2024-09-30 13:23 [PATCH v7 00/10] Consolidate IO memcpy functions Julian Vetter
` (6 preceding siblings ...)
2024-09-30 13:23 ` [PATCH v7 07/10] parisc: " Julian Vetter
@ 2024-09-30 13:23 ` Julian Vetter
2024-09-30 17:52 ` Geert Uytterhoeven
2024-09-30 13:23 ` [PATCH v7 09/10] um: Add dummy implementation for " Julian Vetter
` (2 subsequent siblings)
10 siblings, 1 reply; 23+ messages in thread
From: Julian Vetter @ 2024-09-30 13:23 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
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
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 v7:
- New patch
---
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 v7 09/10] um: Add dummy implementation for IO memcpy/memset
2024-09-30 13:23 [PATCH v7 00/10] Consolidate IO memcpy functions Julian Vetter
` (7 preceding siblings ...)
2024-09-30 13:23 ` [PATCH v7 08/10] sh: " Julian Vetter
@ 2024-09-30 13:23 ` Julian Vetter
2024-10-01 12:53 ` Johannes Berg
2024-09-30 13:23 ` [PATCH v7 10/10] arm: Align prototype of IO memset Julian Vetter
2024-10-01 12:46 ` [PATCH v7 00/10] Consolidate IO memcpy functions Niklas Schnelle
10 siblings, 1 reply; 23+ messages in thread
From: Julian Vetter @ 2024-09-30 13:23 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
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
Yann Sionneau, Julian Vetter
The um arch is the only architecture that sets the config 'NO_IOMEM',
yet drivers that use IO memory can be selected. In order to make these
drivers happy we add a dummy implementation for memcpy_{from,to}io and
memset_io functions.
Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
Changes for v7:
- New patch
---
arch/um/include/asm/io.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/arch/um/include/asm/io.h b/arch/um/include/asm/io.h
index 9ea42cc746d9..f02f40609798 100644
--- a/arch/um/include/asm/io.h
+++ b/arch/um/include/asm/io.h
@@ -21,6 +21,23 @@ static inline void iounmap(void __iomem *addr)
}
#endif /* iounmap */
+static inline void memset_io(volatile void __iomem *dst, int c, size_t count)
+{
+ memset((void *)dst, c, count);
+}
+
+static inline void memcpy_toio(volatile void __iomem *to, const void *from,
+ size_t count)
+{
+ memcpy((void *)to, from, count);
+}
+
+static inline void memcpy_fromio(void *to, const volatile void __iomem *from,
+ size_t count)
+{
+ memcpy(to, (void *)from, count);
+}
+
#include <asm-generic/io.h>
#endif
--
2.34.1
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v7 10/10] arm: Align prototype of IO memset
2024-09-30 13:23 [PATCH v7 00/10] Consolidate IO memcpy functions Julian Vetter
` (8 preceding siblings ...)
2024-09-30 13:23 ` [PATCH v7 09/10] um: Add dummy implementation for " Julian Vetter
@ 2024-09-30 13:23 ` Julian Vetter
2024-09-30 17:50 ` Geert Uytterhoeven
2024-10-01 12:46 ` [PATCH v7 00/10] Consolidate IO memcpy functions Niklas Schnelle
10 siblings, 1 reply; 23+ messages in thread
From: Julian Vetter @ 2024-09-30 13:23 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
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
Yann Sionneau, Julian Vetter
Align prototype of the memset_io function with the new one from
iomap_copy.c
Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
Changes for v7:
- New patch
---
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
* Re: [PATCH v7 05/10] m68k: Align prototypes of IO memcpy/memset
2024-09-30 13:23 ` [PATCH v7 05/10] m68k: Align prototypes of " Julian Vetter
@ 2024-09-30 17:46 ` Geert Uytterhoeven
0 siblings, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2024-09-30 17:46 UTC (permalink / raw)
To: Julian Vetter
Cc: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
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, linux-arm-kernel, linux-kernel,
linux-csky, loongarch, linux-m68k, linux-alpha, linux-parisc,
linux-sh, linux-um, linux-arch, Yann Sionneau
On Mon, Sep 30, 2024 at 3:25 PM Julian Vetter <jvetter@kalrayinc.com> wrote:
> 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 v7:
> - New patch
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 10/10] arm: Align prototype of IO memset
2024-09-30 13:23 ` [PATCH v7 10/10] arm: Align prototype of IO memset Julian Vetter
@ 2024-09-30 17:50 ` Geert Uytterhoeven
0 siblings, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2024-09-30 17:50 UTC (permalink / raw)
To: Julian Vetter
Cc: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
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, linux-arm-kernel, linux-kernel,
linux-csky, loongarch, linux-m68k, linux-alpha, linux-parisc,
linux-sh, linux-um, linux-arch, Yann Sionneau
On Mon, Sep 30, 2024 at 3:25 PM Julian Vetter <jvetter@kalrayinc.com> wrote:
> Align prototype of the memset_io function with the new one from
> iomap_copy.c
>
> Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
> Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
> ---
> Changes for v7:
> - New patch
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 08/10] sh: Align prototypes of IO memcpy/memset
2024-09-30 13:23 ` [PATCH v7 08/10] sh: " Julian Vetter
@ 2024-09-30 17:52 ` Geert Uytterhoeven
0 siblings, 0 replies; 23+ messages in thread
From: Geert Uytterhoeven @ 2024-09-30 17:52 UTC (permalink / raw)
To: Julian Vetter
Cc: Arnd Bergmann, Russell King, Catalin Marinas, Will Deacon,
Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton,
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, linux-arm-kernel, linux-kernel,
linux-csky, loongarch, linux-m68k, linux-alpha, linux-parisc,
linux-sh, linux-um, linux-arch, Yann Sionneau
On Mon, Sep 30, 2024 at 3:25 PM Julian Vetter <jvetter@kalrayinc.com> 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 v7:
> - New patch
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 00/10] Consolidate IO memcpy functions
2024-09-30 13:23 [PATCH v7 00/10] Consolidate IO memcpy functions Julian Vetter
` (9 preceding siblings ...)
2024-09-30 13:23 ` [PATCH v7 10/10] arm: Align prototype of IO memset Julian Vetter
@ 2024-10-01 12:46 ` Niklas Schnelle
10 siblings, 0 replies; 23+ messages in thread
From: Niklas Schnelle @ 2024-10-01 12:46 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
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
Yann Sionneau
On Mon, 2024-09-30 at 15:23 +0200, Julian Vetter wrote:
> Thank you all for your remarks. I have addressed your feedback. I have
> also added the full history of the patchset, because it now targets
> additional architectures.
>
> Arnd: Unfortunately when adding the prototypes as 'extern ..' into
> asm-generic/io.h they conflict with some individual implementations
> (namely m68k, alpha, parisc, and sh). So, I have aligned these functions
> to match the prototypes in asm-generic/io.h.
> For the um problem, unfortunately there are A LOT of drivers that use
> these IO memcpy functions, so I went a bit the lazy route and added
> dummy functions to um's io.h.
>
> David: Thank you for your remarks. I have replaced the mix of long,
> uintptr_t, etc. all by long + sizeof(long). I have also split the
> read/write operation from the put/get_unaligned into two lines for
> better readability.
>
> Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
> ---
>
Hi Julian,
It seems you missed the memcpy_toio()/memcpy_fromio() in
arch/s390/include/asm/io.h, probably because these are macros
and minimal configs might not build s390x with PCI enabled.
One snippet from the error output is:
In file included from arch/s390/kernel/asm-offsets.c:11:
In file included from ./include/linux/kvm_host.h:19:
In file included from ./include/linux/msi.h:24:
In file included from ./include/linux/irq.h:20:
In file included from ./include/linux/io.h:14:
In file included from ./arch/s390/include/asm/io.h:93:
./include/asm-generic/io.h:105:13: error: conflicting types for 'zpci_memcpy_fromio'
105 | extern void memcpy_fromio(void *to, const volatile void __iomem *from,
| ^
./arch/s390/include/asm/io.h:61:40: note: expanded from macro 'memcpy_fromio'
61 | #define memcpy_fromio(dst, src, count) zpci_memcpy_fromio(dst, src, count)
| ^
./arch/s390/include/asm/pci_io.h:144:19: note: previous definition is here
144 | static inline int zpci_memcpy_fromio(void *dst,
| ^
I think the best course of action might be to change the
zpci_memcpy_…() functions to match the generic signatures. While the
generic implementation might work it would be very inefficient for us
as we really need to use the PCI Store Block instructions.
Thanks,
Niklas
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 09/10] um: Add dummy implementation for IO memcpy/memset
2024-09-30 13:23 ` [PATCH v7 09/10] um: Add dummy implementation for " Julian Vetter
@ 2024-10-01 12:53 ` Johannes Berg
2024-10-07 7:49 ` Julian Vetter
0 siblings, 1 reply; 23+ messages in thread
From: Johannes Berg @ 2024-10-01 12:53 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
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
Yann Sionneau
On Mon, 2024-09-30 at 15:23 +0200, Julian Vetter wrote:
> The um arch is the only architecture that sets the config 'NO_IOMEM',
> yet drivers that use IO memory can be selected. In order to make these
> drivers happy we add a dummy implementation for memcpy_{from,to}io and
> memset_io functions.
Maybe I'm just not understanding this series, but how does this work
with lib/logic_iomem.c?
You're adding these inlines unconditionally, so if this included
logic_io.h, you should get symbol conflicts?
Also not sure these functions should/need to do anything at all, there's
no IO memory on ARCH=um in case of not having logic_io.h. Maybe even
BUG_ON() or something? It can't be reachable (under correct drivers)
since ioremap() always returns NULL (without logic_iomem).
I think Arnd also said that other architectures might want to use
logic_iomem, though I don't see any now.
johannes
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 01/10] Consolidate IO memcpy/memset into iomap_copy.c
2024-09-30 13:23 ` [PATCH v7 01/10] Consolidate IO memcpy/memset into iomap_copy.c Julian Vetter
@ 2024-10-03 4:23 ` kernel test robot
2024-10-03 16:46 ` Richard Henderson
1 sibling, 0 replies; 23+ messages in thread
From: kernel test robot @ 2024-10-03 4:23 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
Cc: oe-kbuild-all, Linux Memory Management List, linux-arm-kernel,
linux-kernel, linux-csky, loongarch, linux-m68k, linux-alpha,
linux-parisc, linux-sh, linux-um
Hi Julian,
kernel test robot noticed the following build errors:
[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on deller-parisc/for-next linus/master arm/for-next arm/fixes v6.12-rc1 next-20241002]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Julian-Vetter/Consolidate-IO-memcpy-memset-into-iomap_copy-c/20240930-213742
base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
patch link: https://lore.kernel.org/r/20240930132321.2785718-2-jvetter%40kalrayinc.com
patch subject: [PATCH v7 01/10] Consolidate IO memcpy/memset into iomap_copy.c
config: powerpc-allnoconfig (https://download.01.org/0day-ci/archive/20241003/202410031104.2bzZJyNF-lkp@intel.com/config)
compiler: powerpc-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241003/202410031104.2bzZJyNF-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410031104.2bzZJyNF-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from include/linux/io.h:14,
from include/linux/irq.h:20,
from arch/powerpc/include/asm/hardirq.h:6,
from include/linux/hardirq.h:11,
from include/linux/interrupt.h:11,
from include/linux/kernel_stat.h:8,
from include/linux/cgroup.h:25,
from include/linux/memcontrol.h:13,
from include/linux/swap.h:9,
from include/linux/suspend.h:5,
from arch/powerpc/kernel/asm-offsets.c:21:
>> arch/powerpc/include/asm/io.h:709:23: error: conflicting types for 'memcpy_fromio'; have 'void(void *, const volatile void *, size_t)' {aka 'void(void *, const volatile void *, unsigned int)'}
709 | #define memcpy_fromio memcpy_fromio
| ^~~~~~~~~~~~~
include/asm-generic/io.h:105:13: note: in expansion of macro 'memcpy_fromio'
105 | extern void memcpy_fromio(void *to, const volatile void __iomem *from,
| ^~~~~~~~~~~~~
arch/powerpc/include/asm/io-defs.h:58:18: note: previous definition of 'memcpy_fromio' with type 'void(void *, const volatile void *, long unsigned int)'
58 | DEF_PCI_AC_NORET(memcpy_fromio, (void *d, const PCI_IO_ADDR s, unsigned long n),
| ^~~~~~~~~~~~~
arch/powerpc/include/asm/io.h:664:20: note: in definition of macro 'DEF_PCI_AC_NORET'
664 | static inline void name at \
| ^~~~
>> arch/powerpc/include/asm/io.h:710:21: error: conflicting types for 'memcpy_toio'; have 'void(volatile void *, const void *, size_t)' {aka 'void(volatile void *, const void *, unsigned int)'}
710 | #define memcpy_toio memcpy_toio
| ^~~~~~~~~~~
include/asm-generic/io.h:107:13: note: in expansion of macro 'memcpy_toio'
107 | extern void memcpy_toio(volatile void __iomem *to, const void *from,
| ^~~~~~~~~~~
arch/powerpc/include/asm/io-defs.h:60:18: note: previous definition of 'memcpy_toio' with type 'void(volatile void *, const void *, long unsigned int)'
60 | DEF_PCI_AC_NORET(memcpy_toio, (PCI_IO_ADDR d, const void *s, unsigned long n),
| ^~~~~~~~~~~
arch/powerpc/include/asm/io.h:664:20: note: in definition of macro 'DEF_PCI_AC_NORET'
664 | static inline void name at \
| ^~~~
>> arch/powerpc/include/asm/io.h:708:19: error: conflicting types for 'memset_io'; have 'void(volatile void *, int, size_t)' {aka 'void(volatile void *, int, unsigned int)'}
708 | #define memset_io memset_io
| ^~~~~~~~~
include/asm-generic/io.h:109:13: note: in expansion of macro 'memset_io'
109 | extern void memset_io(volatile void __iomem *dst, int c, size_t count);
| ^~~~~~~~~
arch/powerpc/include/asm/io-defs.h:56:18: note: previous definition of 'memset_io' with type 'void(volatile void *, int, long unsigned int)'
56 | DEF_PCI_AC_NORET(memset_io, (PCI_IO_ADDR a, int c, unsigned long n),
| ^~~~~~~~~
arch/powerpc/include/asm/io.h:664:20: note: in definition of macro 'DEF_PCI_AC_NORET'
664 | static inline void name at \
| ^~~~
make[3]: *** [scripts/Makefile.build:117: arch/powerpc/kernel/asm-offsets.s] Error 1
make[3]: Target 'prepare' not remade because of errors.
make[2]: *** [Makefile:1193: prepare0] Error 2
make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [Makefile:224: __sub-make] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:224: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.
vim +709 arch/powerpc/include/asm/io.h
4cb3cee03d558f include/asm-powerpc/io.h Benjamin Herrenschmidt 2006-11-11 676
4cb3cee03d558f include/asm-powerpc/io.h Benjamin Herrenschmidt 2006-11-11 677 /* Some drivers check for the presence of readq & writeq with
4cb3cee03d558f include/asm-powerpc/io.h Benjamin Herrenschmidt 2006-11-11 678 * a #ifdef, so we make them happy here.
4cb3cee03d558f include/asm-powerpc/io.h Benjamin Herrenschmidt 2006-11-11 679 */
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 680 #define readb readb
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 681 #define readw readw
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 682 #define readl readl
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 683 #define writeb writeb
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 684 #define writew writew
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 685 #define writel writel
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 686 #define readsb readsb
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 687 #define readsw readsw
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 688 #define readsl readsl
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 689 #define writesb writesb
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 690 #define writesw writesw
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 691 #define writesl writesl
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 692 #define inb inb
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 693 #define inw inw
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 694 #define inl inl
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 695 #define outb outb
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 696 #define outw outw
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 697 #define outl outl
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 698 #define insb insb
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 699 #define insw insw
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 700 #define insl insl
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 701 #define outsb outsb
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 702 #define outsw outsw
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 703 #define outsl outsl
68a64357d15ae4 include/asm-powerpc/io.h Benjamin Herrenschmidt 2006-11-13 704 #ifdef __powerpc64__
4cb3cee03d558f include/asm-powerpc/io.h Benjamin Herrenschmidt 2006-11-11 705 #define readq readq
4cb3cee03d558f include/asm-powerpc/io.h Benjamin Herrenschmidt 2006-11-11 706 #define writeq writeq
68a64357d15ae4 include/asm-powerpc/io.h Benjamin Herrenschmidt 2006-11-13 707 #endif
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 @708 #define memset_io memset_io
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 @709 #define memcpy_fromio memcpy_fromio
894fa235eb4ca0 arch/powerpc/include/asm/io.h Christophe Leroy 2020-11-21 @710 #define memcpy_toio memcpy_toio
68a64357d15ae4 include/asm-powerpc/io.h Benjamin Herrenschmidt 2006-11-13 711
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 06/10] alpha: Align prototypes of IO memcpy/memset
2024-09-30 13:23 ` [PATCH v7 06/10] alpha: " Julian Vetter
@ 2024-10-03 14:46 ` Richard Henderson
0 siblings, 0 replies; 23+ messages in thread
From: Richard Henderson @ 2024-10-03 14:46 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
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
Yann Sionneau
On 9/30/24 06:23, 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 v7:
> - New patch
> ---
> 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..db3a9f41447e 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, count);
By changing c from 'u8' to 'int', you need to mask before the multiplication.
r~
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 07/10] parisc: Align prototypes of IO memcpy/memset
2024-09-30 13:23 ` [PATCH v7 07/10] parisc: " Julian Vetter
@ 2024-10-03 14:49 ` Richard Henderson
0 siblings, 0 replies; 23+ messages in thread
From: Richard Henderson @ 2024-10-03 14:49 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
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
Yann Sionneau
On 9/30/24 06:23, Julian Vetter wrote:
> -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;
Mask of val now required.
r~
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 01/10] Consolidate IO memcpy/memset into iomap_copy.c
2024-09-30 13:23 ` [PATCH v7 01/10] Consolidate IO memcpy/memset into iomap_copy.c Julian Vetter
2024-10-03 4:23 ` kernel test robot
@ 2024-10-03 16:46 ` Richard Henderson
2024-10-06 18:50 ` David Laight
1 sibling, 1 reply; 23+ messages in thread
From: Richard Henderson @ 2024-10-03 16:46 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
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
Yann Sionneau
On 9/30/24 06:23, Julian Vetter wrote:
> +void memset_io(volatile void __iomem *dst, int c, size_t count)
> +{
> + uintptr_t qc = (u8)c;
Missed one change to 'long'
> +
> + qc |= qc << 8;
> + qc |= qc << 16;
> +
> +#ifdef CONFIG_64BIT
> + qc |= qc << 32;
> +#endif
Could be 'qc *= -1ul / 0xff;'
r~
^ permalink raw reply [flat|nested] 23+ messages in thread
* RE: [PATCH v7 01/10] Consolidate IO memcpy/memset into iomap_copy.c
2024-10-03 16:46 ` Richard Henderson
@ 2024-10-06 18:50 ` David Laight
0 siblings, 0 replies; 23+ messages in thread
From: David Laight @ 2024-10-06 18:50 UTC (permalink / raw)
To: 'Richard Henderson', 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
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-csky@vger.kernel.org,
loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org,
linux-alpha@vger.kernel.org, linux-parisc@vger.kernel.org,
linux-sh@vger.kernel.org, linux-um@lists.infradead.org,
linux-arch@vger.kernel.org, Yann Sionneau
From: Richard Henderson
> Sent: 03 October 2024 17:47
>
> On 9/30/24 06:23, Julian Vetter wrote:
> > +void memset_io(volatile void __iomem *dst, int c, size_t count)
> > +{
> > + uintptr_t qc = (u8)c;
>
> Missed one change to 'long'
>
> > +
> > + qc |= qc << 8;
> > + qc |= qc << 16;
> > +
> > +#ifdef CONFIG_64BIT
> > + qc |= qc << 32;
> > +#endif
>
> Could be 'qc *= -1ul / 0xff;'
qc *= ~0ul / 0xff;
would be slightly better.
David
>
>
> r~
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 09/10] um: Add dummy implementation for IO memcpy/memset
2024-10-01 12:53 ` Johannes Berg
@ 2024-10-07 7:49 ` Julian Vetter
2024-10-07 8:06 ` Johannes Berg
0 siblings, 1 reply; 23+ messages in thread
From: Julian Vetter @ 2024-10-07 7:49 UTC (permalink / raw)
To: Johannes Berg, 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
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
Yann Sionneau
On 10/1/24 14:53, Johannes Berg wrote:
> On Mon, 2024-09-30 at 15:23 +0200, Julian Vetter wrote:
>> The um arch is the only architecture that sets the config 'NO_IOMEM',
>> yet drivers that use IO memory can be selected. In order to make these
>> drivers happy we add a dummy implementation for memcpy_{from,to}io and
>> memset_io functions.
>
> Maybe I'm just not understanding this series, but how does this work
> with lib/logic_iomem.c?
>
No, I think you're understanding the series correctly. It doesn't work.
I will revert this.
> You're adding these inlines unconditionally, so if this included
> logic_io.h, you should get symbol conflicts?
>
> Also not sure these functions should/need to do anything at all, there's
> no IO memory on ARCH=um in case of not having logic_io.h. Maybe even
> BUG_ON() or something? It can't be reachable (under correct drivers)
> since ioremap() always returns NULL (without logic_iomem).
>
Thanks. You're right. I added this patch because there was a build robot
on some mailinglist building a random config with 'ARCH=um' and with
some MTD drivers that actually use memcpy_fromio or memcpy_toio. These
drivers are not guarded by a 'depends on HAS_IOMEM'. I thought I could
simply fix it by adding stub functions to the um arch. Because I saw
there are A LOT of drivers that use IO functions without being guarded
by 'depends on HAS_IOMEM'. Not sure though, how to handle this case.
> I think Arnd also said that other architectures might want to use
> logic_iomem, though I don't see any now.
>
> johannes
>
>
>
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v7 09/10] um: Add dummy implementation for IO memcpy/memset
2024-10-07 7:49 ` Julian Vetter
@ 2024-10-07 8:06 ` Johannes Berg
0 siblings, 0 replies; 23+ messages in thread
From: Johannes Berg @ 2024-10-07 8:06 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
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch, linux-m68k,
linux-alpha, linux-parisc, linux-sh, linux-um, linux-arch,
Yann Sionneau
On Mon, 2024-10-07 at 09:49 +0200, Julian Vetter wrote:
>
> > > The um arch is the only architecture that sets the config 'NO_IOMEM',
(you did note this, for the comment below)
> No, I think you're understanding the series correctly. It doesn't work.
> I will revert this.
OK.
> > You're adding these inlines unconditionally, so if this included
> > logic_io.h, you should get symbol conflicts?
> >
> > Also not sure these functions should/need to do anything at all, there's
> > no IO memory on ARCH=um in case of not having logic_io.h. Maybe even
> > BUG_ON() or something? It can't be reachable (under correct drivers)
> > since ioremap() always returns NULL (without logic_iomem).
> Thanks. You're right. I added this patch because there was a build robot
> on some mailinglist building a random config with 'ARCH=um' and with
> some MTD drivers that actually use memcpy_fromio or memcpy_toio. These
> drivers are not guarded by a 'depends on HAS_IOMEM'. I thought I could
> simply fix it by adding stub functions to the um arch. Because I saw
> there are A LOT of drivers that use IO functions without being guarded
> by 'depends on HAS_IOMEM'. Not sure though, how to handle this case.
Right, well, as you noted above ARCH=um is the only architecture that
has NO_IOMEM, so I suppose drivers are just broken. But e.g.
kernel/iomem.c is also only ever built if you have HAS_IOMEM, so devm_*
functions related to this are not available.
So I don't know. On the one hand, it feels correct to have NO_IOMEM and
HAS_IOMEM, on the other hand that's a bit of a fight against windmills?
What happens now though? Seems it should _already_ not build with
ARCH=um and memcpy_*io() being used? No, I guess it picked up the asm-
generic version?
Hm. I'm almost thinking we should let such drivers not build, and then
see that they add appropriate HAS_IOMEM dependencies, but ... windmills?
johannes
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2024-10-07 8:06 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-30 13:23 [PATCH v7 00/10] Consolidate IO memcpy functions Julian Vetter
2024-09-30 13:23 ` [PATCH v7 01/10] Consolidate IO memcpy/memset into iomap_copy.c Julian Vetter
2024-10-03 4:23 ` kernel test robot
2024-10-03 16:46 ` Richard Henderson
2024-10-06 18:50 ` David Laight
2024-09-30 13:23 ` [PATCH v7 02/10] arm64: Use generic IO memcpy/memset Julian Vetter
2024-09-30 13:23 ` [PATCH v7 03/10] csky: " Julian Vetter
2024-09-30 13:23 ` [PATCH v7 04/10] loongarch: " Julian Vetter
2024-09-30 13:23 ` [PATCH v7 05/10] m68k: Align prototypes of " Julian Vetter
2024-09-30 17:46 ` Geert Uytterhoeven
2024-09-30 13:23 ` [PATCH v7 06/10] alpha: " Julian Vetter
2024-10-03 14:46 ` Richard Henderson
2024-09-30 13:23 ` [PATCH v7 07/10] parisc: " Julian Vetter
2024-10-03 14:49 ` Richard Henderson
2024-09-30 13:23 ` [PATCH v7 08/10] sh: " Julian Vetter
2024-09-30 17:52 ` Geert Uytterhoeven
2024-09-30 13:23 ` [PATCH v7 09/10] um: Add dummy implementation for " Julian Vetter
2024-10-01 12:53 ` Johannes Berg
2024-10-07 7:49 ` Julian Vetter
2024-10-07 8:06 ` Johannes Berg
2024-09-30 13:23 ` [PATCH v7 10/10] arm: Align prototype of IO memset Julian Vetter
2024-09-30 17:50 ` Geert Uytterhoeven
2024-10-01 12:46 ` [PATCH v7 00/10] Consolidate IO memcpy functions Niklas Schnelle
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).