]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
arm64: move the XOR code to lib/raid/
authorChristoph Hellwig <hch@lst.de>
Fri, 27 Mar 2026 06:16:45 +0000 (07:16 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 3 Apr 2026 06:36:18 +0000 (23:36 -0700)
Move the optimized XOR into lib/raid and include it it in the main xor.ko
instead of building a separate module for it.

Note that this drops the CONFIG_KERNEL_MODE_NEON dependency, as that is
always set for arm64.

Link: https://lkml.kernel.org/r/20260327061704.3707577-14-hch@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Tested-by: Eric Biggers <ebiggers@kernel.org>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: "Borislav Petkov (AMD)" <bp@alien8.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Chris Mason <clm@fb.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: David Sterba <dsterba@suse.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jason A. Donenfeld <jason@zx2c4.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Li Nan <linan122@huawei.com>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
Cc: Magnus Lindholm <linmag7@gmail.com>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Song Liu <song@kernel.org>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Ted Ts'o <tytso@mit.edu>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: WANG Xuerui <kernel@xen0n.name>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
arch/arm64/include/asm/xor.h
arch/arm64/lib/Makefile
lib/raid/xor/Makefile
lib/raid/xor/arm64/xor-neon-glue.c [new file with mode: 0644]
lib/raid/xor/arm64/xor-neon.c [moved from arch/arm64/lib/xor-neon.c with 95% similarity]

index 3cee1eb86371b23030244941dcf0eabbb214cc43..81718f010761d861a8fe6ee74dfc56b6686a7371 100644 (file)
@@ -1,73 +1,21 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
- * arch/arm64/include/asm/xor.h
- *
  * Authors: Jackie Liu <liuyun01@kylinos.cn>
  * Copyright (C) 2018,Tianjin KYLIN Information Technology Co., Ltd.
  */
 
-#include <linux/hardirq.h>
 #include <asm-generic/xor.h>
-#include <asm/hwcap.h>
 #include <asm/simd.h>
 
-#ifdef CONFIG_KERNEL_MODE_NEON
-
-extern struct xor_block_template xor_block_inner_neon __ro_after_init;
-
-static void
-xor_neon_2(unsigned long bytes, unsigned long * __restrict p1,
-          const unsigned long * __restrict p2)
-{
-       scoped_ksimd()
-               xor_block_inner_neon.do_2(bytes, p1, p2);
-}
-
-static void
-xor_neon_3(unsigned long bytes, unsigned long * __restrict p1,
-          const unsigned long * __restrict p2,
-          const unsigned long * __restrict p3)
-{
-       scoped_ksimd()
-               xor_block_inner_neon.do_3(bytes, p1, p2, p3);
-}
-
-static void
-xor_neon_4(unsigned long bytes, unsigned long * __restrict p1,
-          const unsigned long * __restrict p2,
-          const unsigned long * __restrict p3,
-          const unsigned long * __restrict p4)
-{
-       scoped_ksimd()
-               xor_block_inner_neon.do_4(bytes, p1, p2, p3, p4);
-}
-
-static void
-xor_neon_5(unsigned long bytes, unsigned long * __restrict p1,
-          const unsigned long * __restrict p2,
-          const unsigned long * __restrict p3,
-          const unsigned long * __restrict p4,
-          const unsigned long * __restrict p5)
-{
-       scoped_ksimd()
-               xor_block_inner_neon.do_5(bytes, p1, p2, p3, p4, p5);
-}
-
-static struct xor_block_template xor_block_arm64 = {
-       .name   = "arm64_neon",
-       .do_2   = xor_neon_2,
-       .do_3   = xor_neon_3,
-       .do_4   = xor_neon_4,
-       .do_5   = xor_neon_5
-};
+extern struct xor_block_template xor_block_arm64;
+void __init xor_neon_init(void);
 
 #define arch_xor_init arch_xor_init
 static __always_inline void __init arch_xor_init(void)
 {
+       xor_neon_init();
        xor_register(&xor_block_8regs);
        xor_register(&xor_block_32regs);
        if (cpu_has_neon())
                xor_register(&xor_block_arm64);
 }
-
-#endif /* ! CONFIG_KERNEL_MODE_NEON */
index 633e5223d944d73cf0ac65367e060282b3dad7c3..448c917494f3055f4c08580c7a7d8f45c6a383f3 100644 (file)
@@ -5,12 +5,6 @@ lib-y          := clear_user.o delay.o copy_from_user.o                \
                   memset.o memcmp.o strcmp.o strncmp.o strlen.o        \
                   strnlen.o strchr.o strrchr.o tishift.o
 
-ifeq ($(CONFIG_KERNEL_MODE_NEON), y)
-obj-$(CONFIG_XOR_BLOCKS)       += xor-neon.o
-CFLAGS_xor-neon.o              += $(CC_FLAGS_FPU)
-CFLAGS_REMOVE_xor-neon.o       += $(CC_FLAGS_NO_FPU)
-endif
-
 lib-$(CONFIG_ARCH_HAS_UACCESS_FLUSHCACHE) += uaccess_flushcache.o
 
 obj-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
index fb760edae54b5ca72d7edf699132d94a2ffdfd6a..4ab0e7411ff76966363d0dcfb2343ccfcd2562e6 100644 (file)
@@ -13,7 +13,11 @@ xor-$(CONFIG_ARM)            += arm/xor.o
 ifeq ($(CONFIG_ARM),y)
 xor-$(CONFIG_KERNEL_MODE_NEON) += arm/xor-neon.o arm/xor-neon-glue.o
 endif
+xor-$(CONFIG_ARM64)            += arm64/xor-neon.o arm64/xor-neon-glue.o
 
 
 CFLAGS_arm/xor-neon.o          += $(CC_FLAGS_FPU)
 CFLAGS_REMOVE_arm/xor-neon.o   += $(CC_FLAGS_NO_FPU)
+
+CFLAGS_arm64/xor-neon.o                += $(CC_FLAGS_FPU)
+CFLAGS_REMOVE_arm64/xor-neon.o += $(CC_FLAGS_NO_FPU)
diff --git a/lib/raid/xor/arm64/xor-neon-glue.c b/lib/raid/xor/arm64/xor-neon-glue.c
new file mode 100644 (file)
index 0000000..067a209
--- /dev/null
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Authors: Jackie Liu <liuyun01@kylinos.cn>
+ * Copyright (C) 2018,Tianjin KYLIN Information Technology Co., Ltd.
+ */
+
+#include <linux/raid/xor_impl.h>
+#include <asm/simd.h>
+#include <asm/xor.h>
+
+extern struct xor_block_template const xor_block_inner_neon;
+
+static void
+xor_neon_2(unsigned long bytes, unsigned long * __restrict p1,
+          const unsigned long * __restrict p2)
+{
+       scoped_ksimd()
+               xor_block_inner_neon.do_2(bytes, p1, p2);
+}
+
+static void
+xor_neon_3(unsigned long bytes, unsigned long * __restrict p1,
+          const unsigned long * __restrict p2,
+          const unsigned long * __restrict p3)
+{
+       scoped_ksimd()
+               xor_block_inner_neon.do_3(bytes, p1, p2, p3);
+}
+
+static void
+xor_neon_4(unsigned long bytes, unsigned long * __restrict p1,
+          const unsigned long * __restrict p2,
+          const unsigned long * __restrict p3,
+          const unsigned long * __restrict p4)
+{
+       scoped_ksimd()
+               xor_block_inner_neon.do_4(bytes, p1, p2, p3, p4);
+}
+
+static void
+xor_neon_5(unsigned long bytes, unsigned long * __restrict p1,
+          const unsigned long * __restrict p2,
+          const unsigned long * __restrict p3,
+          const unsigned long * __restrict p4,
+          const unsigned long * __restrict p5)
+{
+       scoped_ksimd()
+               xor_block_inner_neon.do_5(bytes, p1, p2, p3, p4, p5);
+}
+
+struct xor_block_template xor_block_arm64 = {
+       .name   = "arm64_neon",
+       .do_2   = xor_neon_2,
+       .do_3   = xor_neon_3,
+       .do_4   = xor_neon_4,
+       .do_5   = xor_neon_5
+};
similarity index 95%
rename from arch/arm64/lib/xor-neon.c
rename to lib/raid/xor/arm64/xor-neon.c
index 351aba92d9324ce9d1b27595a93ef480b69cf4f8..8d2d185090db76ce0df5fd936bd1f9b3324a48c5 100644 (file)
@@ -1,15 +1,13 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * arch/arm64/lib/xor-neon.c
- *
  * Authors: Jackie Liu <liuyun01@kylinos.cn>
  * Copyright (C) 2018,Tianjin KYLIN Information Technology Co., Ltd.
  */
 
-#include <linux/raid/xor.h>
 #include <linux/raid/xor_impl.h>
-#include <linux/module.h>
+#include <linux/cache.h>
 #include <asm/neon-intrinsics.h>
+#include <asm/xor.h>
 
 static void xor_arm64_neon_2(unsigned long bytes, unsigned long * __restrict p1,
        const unsigned long * __restrict p2)
@@ -180,7 +178,6 @@ struct xor_block_template xor_block_inner_neon __ro_after_init = {
        .do_4   = xor_arm64_neon_4,
        .do_5   = xor_arm64_neon_5,
 };
-EXPORT_SYMBOL(xor_block_inner_neon);
 
 static inline uint64x2_t eor3(uint64x2_t p, uint64x2_t q, uint64x2_t r)
 {
@@ -318,22 +315,11 @@ static void xor_arm64_eor3_5(unsigned long bytes,
        } while (--lines > 0);
 }
 
-static int __init xor_neon_init(void)
+void __init xor_neon_init(void)
 {
        if (cpu_have_named_feature(SHA3)) {
                xor_block_inner_neon.do_3 = xor_arm64_eor3_3;
                xor_block_inner_neon.do_4 = xor_arm64_eor3_4;
                xor_block_inner_neon.do_5 = xor_arm64_eor3_5;
        }
-       return 0;
 }
-module_init(xor_neon_init);
-
-static void __exit xor_neon_exit(void)
-{
-}
-module_exit(xor_neon_exit);
-
-MODULE_AUTHOR("Jackie Liu <liuyun01@kylinos.cn>");
-MODULE_DESCRIPTION("ARMv8 XOR Extensions");
-MODULE_LICENSE("GPL");