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>
---
arch/csky/Kconfig | 1 +
arch/csky/kernel/Makefile | 2 +-
arch/csky/kernel/io.c | 91 ---------------------------------------
3 files changed, 2 insertions(+), 92 deletions(-)
delete mode 100644 arch/csky/kernel/io.c
diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig
index 5479707eb5d1..59d4051b2a83 100644
--- a/arch/csky/Kconfig
+++ b/arch/csky/Kconfig
@@ -48,6 +48,7 @@ config CSKY
select DMA_DIRECT_REMAP
select IRQ_DOMAIN
select DW_APB_TIMER_OF
+ select GENERIC_IO_COPY
select GENERIC_IOREMAP
select GENERIC_LIB_ASHLDI3
select GENERIC_LIB_ASHRDI3
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
Hi Julian, kernel test robot noticed the following build errors: [auto build test ERROR on akpm-mm/mm-nonmm-unstable] [also build test ERROR on arm64/for-next/core soc/for-next linus/master v6.11-rc7 next-20240909] [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-a-single-lib/20240909-213659 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-nonmm-unstable patch link: https://lore.kernel.org/r/20240909133159.2024688-4-jvetter%40kalrayinc.com patch subject: [PATCH v2 3/4] Use generic io memcpy functions on the csky architecture config: csky-allnoconfig (https://download.01.org/0day-ci/archive/20240910/202409101549.CyV0mJ2S-lkp@intel.com/config) compiler: csky-linux-gcc (GCC) 14.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240910/202409101549.CyV0mJ2S-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/202409101549.CyV0mJ2S-lkp@intel.com/ All error/warnings (new ones prefixed by >>): In file included from ./arch/csky/include/generated/asm/unaligned.h:1, from lib/io_copy.c:9: lib/io_copy.c: In function '__memcpy_fromio': >> lib/io_copy.c:28:39: error: implicit declaration of function '__raw_readq'; did you mean '__raw_readl'? [-Wimplicit-function-declaration] 28 | put_unaligned(__raw_readq(from), (uintptr_t *)to); | ^~~~~~~~~~~ include/asm-generic/unaligned.h:19:22: note: in definition of macro '__put_unaligned_t' 19 | __pptr->x = (val); \ | ^~~ lib/io_copy.c:28:25: note: in expansion of macro 'put_unaligned' 28 | put_unaligned(__raw_readq(from), (uintptr_t *)to); | ^~~~~~~~~~~~~ lib/io_copy.c: In function '__memcpy_toio': >> lib/io_copy.c:57:25: error: implicit declaration of function '__raw_writeq'; did you mean '__raw_writel'? [-Wimplicit-function-declaration] 57 | __raw_writeq(get_unaligned((uintptr_t *)from), to); | ^~~~~~~~~~~~ | __raw_writel lib/io_copy.c: In function '__memset_io': >> lib/io_copy.c:83:26: warning: left shift count >= width of type [-Wshift-count-overflow] 83 | qc |= qc << 32; | ^~ vim +28 lib/io_copy.c 6a9bfa83709a84e Julian Vetter 2024-09-09 16 6a9bfa83709a84e Julian Vetter 2024-09-09 17 void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count) 6a9bfa83709a84e Julian Vetter 2024-09-09 18 { 6a9bfa83709a84e Julian Vetter 2024-09-09 19 while (count && !IS_ALIGNED((unsigned long)from, NATIVE_STORE_SIZE)) { 6a9bfa83709a84e Julian Vetter 2024-09-09 20 *(u8 *)to = __raw_readb(from); 6a9bfa83709a84e Julian Vetter 2024-09-09 21 from++; 6a9bfa83709a84e Julian Vetter 2024-09-09 22 to++; 6a9bfa83709a84e Julian Vetter 2024-09-09 23 count--; 6a9bfa83709a84e Julian Vetter 2024-09-09 24 } 6a9bfa83709a84e Julian Vetter 2024-09-09 25 6a9bfa83709a84e Julian Vetter 2024-09-09 26 while (count >= NATIVE_STORE_SIZE) { 6a9bfa83709a84e Julian Vetter 2024-09-09 27 if (IS_ENABLED(CONFIG_64BIT)) 6a9bfa83709a84e Julian Vetter 2024-09-09 @28 put_unaligned(__raw_readq(from), (uintptr_t *)to); 6a9bfa83709a84e Julian Vetter 2024-09-09 29 else 6a9bfa83709a84e Julian Vetter 2024-09-09 30 put_unaligned(__raw_readl(from), (uintptr_t *)to); 6a9bfa83709a84e Julian Vetter 2024-09-09 31 6a9bfa83709a84e Julian Vetter 2024-09-09 32 from += NATIVE_STORE_SIZE; 6a9bfa83709a84e Julian Vetter 2024-09-09 33 to += NATIVE_STORE_SIZE; 6a9bfa83709a84e Julian Vetter 2024-09-09 34 count -= NATIVE_STORE_SIZE; 6a9bfa83709a84e Julian Vetter 2024-09-09 35 } 6a9bfa83709a84e Julian Vetter 2024-09-09 36 6a9bfa83709a84e Julian Vetter 2024-09-09 37 while (count) { 6a9bfa83709a84e Julian Vetter 2024-09-09 38 *(u8 *)to = __raw_readb(from); 6a9bfa83709a84e Julian Vetter 2024-09-09 39 from++; 6a9bfa83709a84e Julian Vetter 2024-09-09 40 to++; 6a9bfa83709a84e Julian Vetter 2024-09-09 41 count--; 6a9bfa83709a84e Julian Vetter 2024-09-09 42 } 6a9bfa83709a84e Julian Vetter 2024-09-09 43 } 6a9bfa83709a84e Julian Vetter 2024-09-09 44 EXPORT_SYMBOL(__memcpy_fromio); 6a9bfa83709a84e Julian Vetter 2024-09-09 45 6a9bfa83709a84e Julian Vetter 2024-09-09 46 void __memcpy_toio(volatile void __iomem *to, const void *from, size_t count) 6a9bfa83709a84e Julian Vetter 2024-09-09 47 { 6a9bfa83709a84e Julian Vetter 2024-09-09 48 while (count && !IS_ALIGNED((unsigned long)to, NATIVE_STORE_SIZE)) { 6a9bfa83709a84e Julian Vetter 2024-09-09 49 __raw_writeb(*(u8 *)from, to); 6a9bfa83709a84e Julian Vetter 2024-09-09 50 from++; 6a9bfa83709a84e Julian Vetter 2024-09-09 51 to++; 6a9bfa83709a84e Julian Vetter 2024-09-09 52 count--; 6a9bfa83709a84e Julian Vetter 2024-09-09 53 } 6a9bfa83709a84e Julian Vetter 2024-09-09 54 6a9bfa83709a84e Julian Vetter 2024-09-09 55 while (count >= NATIVE_STORE_SIZE) { 6a9bfa83709a84e Julian Vetter 2024-09-09 56 if (IS_ENABLED(CONFIG_64BIT)) 6a9bfa83709a84e Julian Vetter 2024-09-09 @57 __raw_writeq(get_unaligned((uintptr_t *)from), to); 6a9bfa83709a84e Julian Vetter 2024-09-09 58 else 6a9bfa83709a84e Julian Vetter 2024-09-09 59 __raw_writel(get_unaligned((uintptr_t *)from), to); 6a9bfa83709a84e Julian Vetter 2024-09-09 60 6a9bfa83709a84e Julian Vetter 2024-09-09 61 from += NATIVE_STORE_SIZE; 6a9bfa83709a84e Julian Vetter 2024-09-09 62 to += NATIVE_STORE_SIZE; 6a9bfa83709a84e Julian Vetter 2024-09-09 63 count -= NATIVE_STORE_SIZE; 6a9bfa83709a84e Julian Vetter 2024-09-09 64 } 6a9bfa83709a84e Julian Vetter 2024-09-09 65 6a9bfa83709a84e Julian Vetter 2024-09-09 66 while (count) { 6a9bfa83709a84e Julian Vetter 2024-09-09 67 __raw_writeb(*(u8 *)from, to); 6a9bfa83709a84e Julian Vetter 2024-09-09 68 from++; 6a9bfa83709a84e Julian Vetter 2024-09-09 69 to++; 6a9bfa83709a84e Julian Vetter 2024-09-09 70 count--; 6a9bfa83709a84e Julian Vetter 2024-09-09 71 } 6a9bfa83709a84e Julian Vetter 2024-09-09 72 } 6a9bfa83709a84e Julian Vetter 2024-09-09 73 EXPORT_SYMBOL(__memcpy_toio); 6a9bfa83709a84e Julian Vetter 2024-09-09 74 6a9bfa83709a84e Julian Vetter 2024-09-09 75 void __memset_io(volatile void __iomem *dst, int c, size_t count) 6a9bfa83709a84e Julian Vetter 2024-09-09 76 { 6a9bfa83709a84e Julian Vetter 2024-09-09 77 uintptr_t qc = (u8)c; 6a9bfa83709a84e Julian Vetter 2024-09-09 78 6a9bfa83709a84e Julian Vetter 2024-09-09 79 qc |= qc << 8; 6a9bfa83709a84e Julian Vetter 2024-09-09 80 qc |= qc << 16; 6a9bfa83709a84e Julian Vetter 2024-09-09 81 6a9bfa83709a84e Julian Vetter 2024-09-09 82 if (IS_ENABLED(CONFIG_64BIT)) 6a9bfa83709a84e Julian Vetter 2024-09-09 @83 qc |= qc << 32; -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
On Tue, Sep 10, 2024, at 07:27, kernel test robot wrote: > 6a9bfa83709a84e Julian Vetter 2024-09-09 55 while (count >= > NATIVE_STORE_SIZE) { > 6a9bfa83709a84e Julian Vetter 2024-09-09 56 if > (IS_ENABLED(CONFIG_64BIT)) > 6a9bfa83709a84e Julian Vetter 2024-09-09 @57 > __raw_writeq(get_unaligned((uintptr_t *)from), to); > 6a9bfa83709a84e Julian Vetter 2024-09-09 58 else Right, this one actually has to be a preprocessor conditional because __raw_writeq is not defined. Arnd
On Tue, Sep 10, 2024 at 5:16 PM Arnd Bergmann <arnd@arndb.de> wrote: > > On Tue, Sep 10, 2024, at 07:27, kernel test robot wrote: > > > 6a9bfa83709a84e Julian Vetter 2024-09-09 55 while (count >= > > NATIVE_STORE_SIZE) { > > 6a9bfa83709a84e Julian Vetter 2024-09-09 56 if > > (IS_ENABLED(CONFIG_64BIT)) > > 6a9bfa83709a84e Julian Vetter 2024-09-09 @57 > > __raw_writeq(get_unaligned((uintptr_t *)from), to); > > 6a9bfa83709a84e Julian Vetter 2024-09-09 58 else > > Right, this one actually has to be a preprocessor conditional > because __raw_writeq is not defined. All 32-bit ISAs didn't support __raw_writeq. e.g.: include/asm-generic/io.h #ifdef CONFIG_64BIT #ifndef __raw_writeq #define __raw_writeq __raw_writeq static inline void __raw_writeq(u64 value, volatile void __iomem *addr) { *(volatile u64 __force *)addr = value; } #endif #endif /* CONFIG_64BIT */ e.g.: arch/riscv/include/asm/mmio.h #ifdef CONFIG_64BIT #define __raw_writeq __raw_writeq static inline void __raw_writeq(u64 val, volatile void __iomem *addr) { asm volatile("sd %0, 0(%1)" : : "r" (val), "r" (addr)); } #endif > > Arnd -- Best Regards Guo Ren
© 2016 - 2024 Red Hat, Inc.