* [PATCH v5 0/5] Consolidate IO memcpy functions
@ 2024-09-24 12:14 Julian Vetter
2024-09-24 12:14 ` [PATCH v5 1/5] Consolidate __memcpy_{to,from}io and __memset_io into iomap_copy.c Julian Vetter
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Julian Vetter @ 2024-09-24 12:14 UTC (permalink / raw)
To: Arnd Bergmann, Catalin Marinas, Will Deacon, Guo Ren, Huacai Chen,
WANG Xuerui, Andrew Morton
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch,
Yann Sionneau, Julian Vetter
Sorry for spaming the mailinglist with new patches. But please forget my
previous patchset. It was broken. I didn't fully understand your
previous comments/feedback. Now, I added the new functions to
iomap_copy.c (as you proposed before already). I guard all of them with
an '#ifndef __memcpy_toio', etc. So, if an architecture already has its
own implementation it will use it. If not, it will either call the new
'__memcpy_{to,from}io' and '__memset_io functions' from 'iomap_copy.c'
or directly the 'memcpy_{to,from}io' and 'memset_io' functions from
'asm-generic/io.h' which are just a wrappers around the __xxx functions.
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
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
---
Julian Vetter (5):
Consolidate __memcpy_{to,from}io and __memset_io into iomap_copy.c
Replace generic memcpy and memset by IO memcpy functions
Use generic io memcpy functions on the arm64 architecture
Use generic io memcpy functions on the csky architecture
Use generic io memcpy functions on the loongarch architecture
arch/arm64/kernel/io.c | 87 ---------------------------
arch/csky/kernel/Makefile | 2 +-
arch/csky/kernel/io.c | 91 ----------------------------
arch/loongarch/kernel/Makefile | 2 +-
arch/loongarch/kernel/io.c | 94 -----------------------------
include/asm-generic/io.h | 18 +++++-
lib/iomap_copy.c | 107 +++++++++++++++++++++++++++++++++
7 files changed, 124 insertions(+), 277 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] 10+ messages in thread
* [PATCH v5 1/5] Consolidate __memcpy_{to,from}io and __memset_io into iomap_copy.c
2024-09-24 12:14 [PATCH v5 0/5] Consolidate IO memcpy functions Julian Vetter
@ 2024-09-24 12:14 ` Julian Vetter
2024-09-24 21:36 ` kernel test robot
` (2 more replies)
2024-09-24 12:14 ` [PATCH v5 2/5] Replace generic memcpy and memset by IO memcpy functions Julian Vetter
` (3 subsequent siblings)
4 siblings, 3 replies; 10+ messages in thread
From: Julian Vetter @ 2024-09-24 12:14 UTC (permalink / raw)
To: Arnd Bergmann, Catalin Marinas, Will Deacon, Guo Ren, Huacai Chen,
WANG Xuerui, Andrew Morton
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch,
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 v5:
- Add function prototypes to asm-generic/io.h
- Instead of having yet another file, we add the functions to
iomap_copy.c as proposed by Arndt
---
include/asm-generic/io.h | 12 +++++
lib/iomap_copy.c | 107 +++++++++++++++++++++++++++++++++++++++
2 files changed, 119 insertions(+)
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 80de699bf6af..9b8e0449da28 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -102,6 +102,18 @@ static inline void log_post_read_mmio(u64 val, u8 width, const volatile void __i
#endif /* CONFIG_TRACE_MMIO_ACCESS */
+#ifndef __memcpy_fromio
+void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count);
+#endif
+
+#ifndef __memcpy_toio
+void __memcpy_toio(volatile void __iomem *to, const void *from, size_t count);
+#endif
+
+#ifndef __memset_io
+void __memset_io(volatile void __iomem *dst, int c, size_t count);
+#endif
+
/*
* __raw_{read,write}{b,w,l,q}() access memory in native endianness.
*
diff --git a/lib/iomap_copy.c b/lib/iomap_copy.c
index 2fd5712fb7c0..fabcc1e95668 100644
--- a/lib/iomap_copy.c
+++ b/lib/iomap_copy.c
@@ -3,9 +3,14 @@
* Copyright 2006 PathScale, Inc. All Rights Reserved.
*/
+#include <asm/unaligned.h>
+
#include <linux/export.h>
+#include <linux/types.h>
#include <linux/io.h>
+#define NATIVE_STORE_SIZE (BITS_PER_LONG/8)
+
/**
* __iowrite32_copy - copy data to MMIO space, in 32-bit units
* @to: destination, in MMIO space (must be 32-bit aligned)
@@ -76,3 +81,105 @@ void __iowrite64_copy(void __iomem *to, const void *from, size_t count)
}
EXPORT_SYMBOL_GPL(__iowrite64_copy);
#endif
+
+
+#ifndef __memcpy_fromio
+void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count)
+{
+ while (count && !IS_ALIGNED((unsigned long)from, NATIVE_STORE_SIZE)) {
+ *(u8 *)to = __raw_readb(from);
+ from++;
+ to++;
+ count--;
+ }
+
+ while (count >= NATIVE_STORE_SIZE) {
+#ifdef CONFIG_64BIT
+ put_unaligned(__raw_readq(from), (uintptr_t *)to);
+#else
+ put_unaligned(__raw_readl(from), (uintptr_t *)to);
+#endif
+
+ from += NATIVE_STORE_SIZE;
+ to += NATIVE_STORE_SIZE;
+ count -= NATIVE_STORE_SIZE;
+ }
+
+ while (count) {
+ *(u8 *)to = __raw_readb(from);
+ from++;
+ to++;
+ count--;
+ }
+}
+EXPORT_SYMBOL(__memcpy_fromio);
+#endif
+
+#ifndef __memcpy_toio
+void __memcpy_toio(volatile void __iomem *to, const void *from, size_t count)
+{
+ while (count && !IS_ALIGNED((unsigned long)to, NATIVE_STORE_SIZE)) {
+ __raw_writeb(*(u8 *)from, to);
+ from++;
+ to++;
+ count--;
+ }
+
+ while (count >= NATIVE_STORE_SIZE) {
+#ifdef CONFIG_64BIT
+ __raw_writeq(get_unaligned((uintptr_t *)from), to);
+#else
+ __raw_writel(get_unaligned((uintptr_t *)from), to);
+#endif
+
+ from += NATIVE_STORE_SIZE;
+ to += NATIVE_STORE_SIZE;
+ count -= NATIVE_STORE_SIZE;
+ }
+
+ while (count) {
+ __raw_writeb(*(u8 *)from, to);
+ from++;
+ to++;
+ count--;
+ }
+}
+EXPORT_SYMBOL(__memcpy_toio);
+#endif
+
+#ifndef __memset_io
+void __memset_io(volatile void __iomem *dst, int c, size_t count)
+{
+ uintptr_t qc = (u8)c;
+
+ qc |= qc << 8;
+ qc |= qc << 16;
+
+ if (IS_ENABLED(CONFIG_64BIT))
+ qc |= qc << 32;
+
+ while (count && !IS_ALIGNED((unsigned long)dst, NATIVE_STORE_SIZE)) {
+ __raw_writeb(c, dst);
+ dst++;
+ count--;
+ }
+
+ while (count >= NATIVE_STORE_SIZE) {
+#ifdef CONFIG_64BIT
+ __raw_writeq(qc, dst);
+#else
+ __raw_writel(qc, dst);
+#endif
+
+ dst += NATIVE_STORE_SIZE;
+ count -= NATIVE_STORE_SIZE;
+ }
+
+ while (count) {
+ __raw_writeb(c, dst);
+ dst++;
+ count--;
+ }
+}
+EXPORT_SYMBOL(__memset_io);
+#endif
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 2/5] Replace generic memcpy and memset by IO memcpy functions
2024-09-24 12:14 [PATCH v5 0/5] Consolidate IO memcpy functions Julian Vetter
2024-09-24 12:14 ` [PATCH v5 1/5] Consolidate __memcpy_{to,from}io and __memset_io into iomap_copy.c Julian Vetter
@ 2024-09-24 12:14 ` Julian Vetter
2024-09-24 12:14 ` [PATCH v5 3/5] Use generic io memcpy functions on the arm64 architecture Julian Vetter
` (2 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Julian Vetter @ 2024-09-24 12:14 UTC (permalink / raw)
To: Arnd Bergmann, Catalin Marinas, Will Deacon, Guo Ren, Huacai Chen,
WANG Xuerui, Andrew Morton
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch,
Yann Sionneau, Julian Vetter
Some architectures implement their own memcpy_{to,from}io and memset_io
functions, because the generic memcpy_{to,from}io and memset_io just use
memcpy/memset.This commit replaces the generic memcpy/memset functions
by IO memcpy/memset functions that respect the given architectures
alignment constraints. So, later we can get rid of the individual
implementations and use the generic ones.
Reviewed-by: Yann Sionneau <ysionneau@kalrayinc.com>
Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
Changes for v5
- New patch which replaces the "generic" memcpy/memset by our new
__memset_io/__memcpy_{to,from}io in asm-generic/io.h
---
include/asm-generic/io.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 9b8e0449da28..3b7deb724a2c 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -1175,7 +1175,7 @@ static inline void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr)
static inline void memset_io(volatile void __iomem *addr, int value,
size_t size)
{
- memset(__io_virt(addr), value, size);
+ __memset_io(__io_virt(addr), value, size);
}
#endif
@@ -1193,7 +1193,7 @@ static inline void memcpy_fromio(void *buffer,
const volatile void __iomem *addr,
size_t size)
{
- memcpy(buffer, __io_virt(addr), size);
+ __memcpy_fromio(buffer, __io_virt(addr), size);
}
#endif
@@ -1210,7 +1210,7 @@ static inline void memcpy_fromio(void *buffer,
static inline void memcpy_toio(volatile void __iomem *addr, const void *buffer,
size_t size)
{
- memcpy(__io_virt(addr), buffer, size);
+ __memcpy_toio(__io_virt(addr), buffer, size);
}
#endif
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 3/5] Use generic io memcpy functions on the arm64 architecture
2024-09-24 12:14 [PATCH v5 0/5] Consolidate IO memcpy functions Julian Vetter
2024-09-24 12:14 ` [PATCH v5 1/5] Consolidate __memcpy_{to,from}io and __memset_io into iomap_copy.c Julian Vetter
2024-09-24 12:14 ` [PATCH v5 2/5] Replace generic memcpy and memset by IO memcpy functions Julian Vetter
@ 2024-09-24 12:14 ` Julian Vetter
2024-09-24 15:40 ` Catalin Marinas
2024-09-24 12:14 ` [PATCH v5 4/5] Use generic io memcpy functions on the csky architecture Julian Vetter
2024-09-24 12:14 ` [PATCH v5 5/5] Use generic io memcpy functions on the loongarch architecture Julian Vetter
4 siblings, 1 reply; 10+ messages in thread
From: Julian Vetter @ 2024-09-24 12:14 UTC (permalink / raw)
To: Arnd Bergmann, Catalin Marinas, Will Deacon, Guo Ren, Huacai Chen,
WANG Xuerui, Andrew Morton
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch,
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 v5:
- Remove 'select GENERIC_IO_COPY'
---
arch/arm64/kernel/io.c | 87 ------------------------------------------
1 file changed, 87 deletions(-)
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] 10+ messages in thread
* [PATCH v5 4/5] Use generic io memcpy functions on the csky architecture
2024-09-24 12:14 [PATCH v5 0/5] Consolidate IO memcpy functions Julian Vetter
` (2 preceding siblings ...)
2024-09-24 12:14 ` [PATCH v5 3/5] Use generic io memcpy functions on the arm64 architecture Julian Vetter
@ 2024-09-24 12:14 ` Julian Vetter
2024-09-24 12:14 ` [PATCH v5 5/5] Use generic io memcpy functions on the loongarch architecture Julian Vetter
4 siblings, 0 replies; 10+ messages in thread
From: Julian Vetter @ 2024-09-24 12:14 UTC (permalink / raw)
To: Arnd Bergmann, Catalin Marinas, Will Deacon, Guo Ren, Huacai Chen,
WANG Xuerui, Andrew Morton
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch,
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 v5:
- Remove 'select GENERIC_IO_COPY'
---
arch/csky/kernel/Makefile | 2 +-
arch/csky/kernel/io.c | 91 ---------------------------------------
2 files changed, 1 insertion(+), 92 deletions(-)
delete mode 100644 arch/csky/kernel/io.c
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] 10+ messages in thread
* [PATCH v5 5/5] Use generic io memcpy functions on the loongarch architecture
2024-09-24 12:14 [PATCH v5 0/5] Consolidate IO memcpy functions Julian Vetter
` (3 preceding siblings ...)
2024-09-24 12:14 ` [PATCH v5 4/5] Use generic io memcpy functions on the csky architecture Julian Vetter
@ 2024-09-24 12:14 ` Julian Vetter
4 siblings, 0 replies; 10+ messages in thread
From: Julian Vetter @ 2024-09-24 12:14 UTC (permalink / raw)
To: Arnd Bergmann, Catalin Marinas, Will Deacon, Guo Ren, Huacai Chen,
WANG Xuerui, Andrew Morton
Cc: linux-arm-kernel, linux-kernel, linux-csky, loongarch,
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 v5:
- Remove 'select GENERIC_IO_COPY'
---
arch/loongarch/kernel/Makefile | 2 +-
arch/loongarch/kernel/io.c | 94 ----------------------------------
2 files changed, 1 insertion(+), 95 deletions(-)
delete mode 100644 arch/loongarch/kernel/io.c
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] 10+ messages in thread
* Re: [PATCH v5 3/5] Use generic io memcpy functions on the arm64 architecture
2024-09-24 12:14 ` [PATCH v5 3/5] Use generic io memcpy functions on the arm64 architecture Julian Vetter
@ 2024-09-24 15:40 ` Catalin Marinas
0 siblings, 0 replies; 10+ messages in thread
From: Catalin Marinas @ 2024-09-24 15:40 UTC (permalink / raw)
To: Julian Vetter
Cc: Arnd Bergmann, Will Deacon, Guo Ren, Huacai Chen, WANG Xuerui,
Andrew Morton, linux-arm-kernel, linux-kernel, linux-csky,
loongarch, Yann Sionneau
On Tue, Sep 24, 2024 at 02:14:30PM +0200, Julian Vetter wrote:
> 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>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
And a nitpick if you respin: we tend to write the subject as arch name,
colon followed by the actual text. E.g.:
arm64: Use generic io memcpy functions
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v5 1/5] Consolidate __memcpy_{to,from}io and __memset_io into iomap_copy.c
2024-09-24 12:14 ` [PATCH v5 1/5] Consolidate __memcpy_{to,from}io and __memset_io into iomap_copy.c Julian Vetter
@ 2024-09-24 21:36 ` kernel test robot
2024-09-24 22:48 ` kernel test robot
2024-09-25 1:01 ` kernel test robot
2 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2024-09-24 21:36 UTC (permalink / raw)
To: Julian Vetter, Arnd Bergmann, Catalin Marinas, Will Deacon,
Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton
Cc: oe-kbuild-all, Linux Memory Management List, linux-arm-kernel,
linux-kernel, linux-csky, loongarch, Yann Sionneau, Julian Vetter
Hi Julian,
kernel test robot noticed the following build errors:
[auto build test ERROR on arnd-asm-generic/master]
[also build test ERROR on soc/for-next akpm-mm/mm-nonmm-unstable arm64/for-next/core linus/master v6.11 next-20240924]
[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-__memcpy_-to-from-io-and-__memset_io-into-iomap_copy-c/20240924-202154
base: https://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic.git master
patch link: https://lore.kernel.org/r/20240924121432.798655-2-jvetter%40kalrayinc.com
patch subject: [PATCH v5 1/5] Consolidate __memcpy_{to,from}io and __memset_io into iomap_copy.c
config: arm-am200epdkit_defconfig (https://download.01.org/0day-ci/archive/20240925/202409250555.Ey0vV3Df-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240925/202409250555.Ey0vV3Df-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/202409250555.Ey0vV3Df-lkp@intel.com/
All error/warnings (new ones prefixed by >>):
lib/iomap_copy.c: In function '__memcpy_fromio':
>> lib/iomap_copy.c:89:26: error: implicit declaration of function 'IS_ALIGNED' [-Wimplicit-function-declaration]
89 | while (count && !IS_ALIGNED((unsigned long)from, NATIVE_STORE_SIZE)) {
| ^~~~~~~~~~
lib/iomap_copy.c: In function '__memset_io':
>> lib/iomap_copy.c:159:26: warning: left shift count >= width of type [-Wshift-count-overflow]
159 | qc |= qc << 32;
| ^~
vim +/IS_ALIGNED +89 lib/iomap_copy.c
84
85
86 #ifndef __memcpy_fromio
87 void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count)
88 {
> 89 while (count && !IS_ALIGNED((unsigned long)from, NATIVE_STORE_SIZE)) {
90 *(u8 *)to = __raw_readb(from);
91 from++;
92 to++;
93 count--;
94 }
95
96 while (count >= NATIVE_STORE_SIZE) {
97 #ifdef CONFIG_64BIT
98 put_unaligned(__raw_readq(from), (uintptr_t *)to);
99 #else
100 put_unaligned(__raw_readl(from), (uintptr_t *)to);
101 #endif
102
103 from += NATIVE_STORE_SIZE;
104 to += NATIVE_STORE_SIZE;
105 count -= NATIVE_STORE_SIZE;
106 }
107
108 while (count) {
109 *(u8 *)to = __raw_readb(from);
110 from++;
111 to++;
112 count--;
113 }
114 }
115 EXPORT_SYMBOL(__memcpy_fromio);
116 #endif
117
118 #ifndef __memcpy_toio
119 void __memcpy_toio(volatile void __iomem *to, const void *from, size_t count)
120 {
121 while (count && !IS_ALIGNED((unsigned long)to, NATIVE_STORE_SIZE)) {
122 __raw_writeb(*(u8 *)from, to);
123 from++;
124 to++;
125 count--;
126 }
127
128 while (count >= NATIVE_STORE_SIZE) {
129 #ifdef CONFIG_64BIT
130 __raw_writeq(get_unaligned((uintptr_t *)from), to);
131 #else
132 __raw_writel(get_unaligned((uintptr_t *)from), to);
133 #endif
134
135 from += NATIVE_STORE_SIZE;
136 to += NATIVE_STORE_SIZE;
137 count -= NATIVE_STORE_SIZE;
138 }
139
140 while (count) {
141 __raw_writeb(*(u8 *)from, to);
142 from++;
143 to++;
144 count--;
145 }
146 }
147 EXPORT_SYMBOL(__memcpy_toio);
148 #endif
149
150 #ifndef __memset_io
151 void __memset_io(volatile void __iomem *dst, int c, size_t count)
152 {
153 uintptr_t qc = (u8)c;
154
155 qc |= qc << 8;
156 qc |= qc << 16;
157
158 if (IS_ENABLED(CONFIG_64BIT))
> 159 qc |= qc << 32;
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v5 1/5] Consolidate __memcpy_{to,from}io and __memset_io into iomap_copy.c
2024-09-24 12:14 ` [PATCH v5 1/5] Consolidate __memcpy_{to,from}io and __memset_io into iomap_copy.c Julian Vetter
2024-09-24 21:36 ` kernel test robot
@ 2024-09-24 22:48 ` kernel test robot
2024-09-25 1:01 ` kernel test robot
2 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2024-09-24 22:48 UTC (permalink / raw)
To: Julian Vetter, Arnd Bergmann, Catalin Marinas, Will Deacon,
Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton
Cc: llvm, oe-kbuild-all, Linux Memory Management List,
linux-arm-kernel, linux-kernel, linux-csky, loongarch,
Yann Sionneau, Julian Vetter
Hi Julian,
kernel test robot noticed the following build warnings:
[auto build test WARNING on arnd-asm-generic/master]
[also build test WARNING on soc/for-next akpm-mm/mm-nonmm-unstable arm64/for-next/core linus/master v6.11 next-20240924]
[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-__memcpy_-to-from-io-and-__memset_io-into-iomap_copy-c/20240924-202154
base: https://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic.git master
patch link: https://lore.kernel.org/r/20240924121432.798655-2-jvetter%40kalrayinc.com
patch subject: [PATCH v5 1/5] Consolidate __memcpy_{to,from}io and __memset_io into iomap_copy.c
config: arm-mxs_defconfig (https://download.01.org/0day-ci/archive/20240925/202409250603.okc57309-lkp@intel.com/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 7773243d9916f98ba0ffce0c3a960e4aa9f03e81)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240925/202409250603.okc57309-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/202409250603.okc57309-lkp@intel.com/
All warnings (new ones prefixed by >>):
lib/iomap_copy.c:89:19: error: call to undeclared function 'IS_ALIGNED'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
89 | while (count && !IS_ALIGNED((unsigned long)from, NATIVE_STORE_SIZE)) {
| ^
lib/iomap_copy.c:121:19: error: call to undeclared function 'IS_ALIGNED'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
121 | while (count && !IS_ALIGNED((unsigned long)to, NATIVE_STORE_SIZE)) {
| ^
lib/iomap_copy.c:161:19: error: call to undeclared function 'IS_ALIGNED'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
161 | while (count && !IS_ALIGNED((unsigned long)dst, NATIVE_STORE_SIZE)) {
| ^
>> lib/iomap_copy.c:159:12: warning: shift count >= width of type [-Wshift-count-overflow]
159 | qc |= qc << 32;
| ^ ~~
1 warning and 3 errors generated.
vim +159 lib/iomap_copy.c
84
85
86 #ifndef __memcpy_fromio
87 void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count)
88 {
> 89 while (count && !IS_ALIGNED((unsigned long)from, NATIVE_STORE_SIZE)) {
90 *(u8 *)to = __raw_readb(from);
91 from++;
92 to++;
93 count--;
94 }
95
96 while (count >= NATIVE_STORE_SIZE) {
97 #ifdef CONFIG_64BIT
98 put_unaligned(__raw_readq(from), (uintptr_t *)to);
99 #else
100 put_unaligned(__raw_readl(from), (uintptr_t *)to);
101 #endif
102
103 from += NATIVE_STORE_SIZE;
104 to += NATIVE_STORE_SIZE;
105 count -= NATIVE_STORE_SIZE;
106 }
107
108 while (count) {
109 *(u8 *)to = __raw_readb(from);
110 from++;
111 to++;
112 count--;
113 }
114 }
115 EXPORT_SYMBOL(__memcpy_fromio);
116 #endif
117
118 #ifndef __memcpy_toio
119 void __memcpy_toio(volatile void __iomem *to, const void *from, size_t count)
120 {
121 while (count && !IS_ALIGNED((unsigned long)to, NATIVE_STORE_SIZE)) {
122 __raw_writeb(*(u8 *)from, to);
123 from++;
124 to++;
125 count--;
126 }
127
128 while (count >= NATIVE_STORE_SIZE) {
129 #ifdef CONFIG_64BIT
130 __raw_writeq(get_unaligned((uintptr_t *)from), to);
131 #else
132 __raw_writel(get_unaligned((uintptr_t *)from), to);
133 #endif
134
135 from += NATIVE_STORE_SIZE;
136 to += NATIVE_STORE_SIZE;
137 count -= NATIVE_STORE_SIZE;
138 }
139
140 while (count) {
141 __raw_writeb(*(u8 *)from, to);
142 from++;
143 to++;
144 count--;
145 }
146 }
147 EXPORT_SYMBOL(__memcpy_toio);
148 #endif
149
150 #ifndef __memset_io
151 void __memset_io(volatile void __iomem *dst, int c, size_t count)
152 {
153 uintptr_t qc = (u8)c;
154
155 qc |= qc << 8;
156 qc |= qc << 16;
157
158 if (IS_ENABLED(CONFIG_64BIT))
> 159 qc |= qc << 32;
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v5 1/5] Consolidate __memcpy_{to,from}io and __memset_io into iomap_copy.c
2024-09-24 12:14 ` [PATCH v5 1/5] Consolidate __memcpy_{to,from}io and __memset_io into iomap_copy.c Julian Vetter
2024-09-24 21:36 ` kernel test robot
2024-09-24 22:48 ` kernel test robot
@ 2024-09-25 1:01 ` kernel test robot
2 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2024-09-25 1:01 UTC (permalink / raw)
To: Julian Vetter, Arnd Bergmann, Catalin Marinas, Will Deacon,
Guo Ren, Huacai Chen, WANG Xuerui, Andrew Morton
Cc: llvm, oe-kbuild-all, Linux Memory Management List,
linux-arm-kernel, linux-kernel, linux-csky, loongarch,
Yann Sionneau, Julian Vetter
Hi Julian,
kernel test robot noticed the following build errors:
[auto build test ERROR on arnd-asm-generic/master]
[also build test ERROR on soc/for-next akpm-mm/mm-nonmm-unstable arm64/for-next/core linus/master v6.11 next-20240924]
[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-__memcpy_-to-from-io-and-__memset_io-into-iomap_copy-c/20240924-202154
base: https://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic.git master
patch link: https://lore.kernel.org/r/20240924121432.798655-2-jvetter%40kalrayinc.com
patch subject: [PATCH v5 1/5] Consolidate __memcpy_{to,from}io and __memset_io into iomap_copy.c
config: arm-defconfig (https://download.01.org/0day-ci/archive/20240925/202409250806.Lq8C7QZr-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240925/202409250806.Lq8C7QZr-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/202409250806.Lq8C7QZr-lkp@intel.com/
All errors (new ones prefixed by >>):
>> lib/iomap_copy.c:89:19: error: implicit declaration of function 'IS_ALIGNED' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
while (count && !IS_ALIGNED((unsigned long)from, NATIVE_STORE_SIZE)) {
^
lib/iomap_copy.c:121:19: error: implicit declaration of function 'IS_ALIGNED' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
while (count && !IS_ALIGNED((unsigned long)to, NATIVE_STORE_SIZE)) {
^
lib/iomap_copy.c:161:19: error: implicit declaration of function 'IS_ALIGNED' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
while (count && !IS_ALIGNED((unsigned long)dst, NATIVE_STORE_SIZE)) {
^
3 errors generated.
vim +/IS_ALIGNED +89 lib/iomap_copy.c
84
85
86 #ifndef __memcpy_fromio
87 void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count)
88 {
> 89 while (count && !IS_ALIGNED((unsigned long)from, NATIVE_STORE_SIZE)) {
90 *(u8 *)to = __raw_readb(from);
91 from++;
92 to++;
93 count--;
94 }
95
96 while (count >= NATIVE_STORE_SIZE) {
97 #ifdef CONFIG_64BIT
98 put_unaligned(__raw_readq(from), (uintptr_t *)to);
99 #else
100 put_unaligned(__raw_readl(from), (uintptr_t *)to);
101 #endif
102
103 from += NATIVE_STORE_SIZE;
104 to += NATIVE_STORE_SIZE;
105 count -= NATIVE_STORE_SIZE;
106 }
107
108 while (count) {
109 *(u8 *)to = __raw_readb(from);
110 from++;
111 to++;
112 count--;
113 }
114 }
115 EXPORT_SYMBOL(__memcpy_fromio);
116 #endif
117
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-09-25 1:01 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-24 12:14 [PATCH v5 0/5] Consolidate IO memcpy functions Julian Vetter
2024-09-24 12:14 ` [PATCH v5 1/5] Consolidate __memcpy_{to,from}io and __memset_io into iomap_copy.c Julian Vetter
2024-09-24 21:36 ` kernel test robot
2024-09-24 22:48 ` kernel test robot
2024-09-25 1:01 ` kernel test robot
2024-09-24 12:14 ` [PATCH v5 2/5] Replace generic memcpy and memset by IO memcpy functions Julian Vetter
2024-09-24 12:14 ` [PATCH v5 3/5] Use generic io memcpy functions on the arm64 architecture Julian Vetter
2024-09-24 15:40 ` Catalin Marinas
2024-09-24 12:14 ` [PATCH v5 4/5] Use generic io memcpy functions on the csky architecture Julian Vetter
2024-09-24 12:14 ` [PATCH v5 5/5] Use generic io memcpy functions on the loongarch architecture Julian Vetter
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).