]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
loongarch: move the XOR code to lib/raid/
authorChristoph Hellwig <hch@lst.de>
Fri, 27 Mar 2026 06:16:46 +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 xor.ko instead
of always building it into the main kernel image.

Link: https://lkml.kernel.org/r/20260327061704.3707577-15-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/loongarch/include/asm/xor.h
arch/loongarch/include/asm/xor_simd.h [deleted file]
arch/loongarch/lib/Makefile
lib/raid/xor/Makefile
lib/raid/xor/loongarch/xor_simd.c [moved from arch/loongarch/lib/xor_simd.c with 100% similarity]
lib/raid/xor/loongarch/xor_simd.h [moved from arch/loongarch/lib/xor_simd.h with 100% similarity]
lib/raid/xor/loongarch/xor_simd_glue.c [moved from arch/loongarch/lib/xor_simd_glue.c with 64% similarity]
lib/raid/xor/loongarch/xor_template.c [moved from arch/loongarch/lib/xor_template.c with 100% similarity]

index d17c0e3b047f13b1f53447e72cbcad0f9e49064f..7e32f72f8b036d5a70e0e0fd168fcac40d5075f6 100644 (file)
@@ -6,27 +6,6 @@
 #define _ASM_LOONGARCH_XOR_H
 
 #include <asm/cpu-features.h>
-#include <asm/xor_simd.h>
-
-#ifdef CONFIG_CPU_HAS_LSX
-static struct xor_block_template xor_block_lsx = {
-       .name = "lsx",
-       .do_2 = xor_lsx_2,
-       .do_3 = xor_lsx_3,
-       .do_4 = xor_lsx_4,
-       .do_5 = xor_lsx_5,
-};
-#endif /* CONFIG_CPU_HAS_LSX */
-
-#ifdef CONFIG_CPU_HAS_LASX
-static struct xor_block_template xor_block_lasx = {
-       .name = "lasx",
-       .do_2 = xor_lasx_2,
-       .do_3 = xor_lasx_3,
-       .do_4 = xor_lasx_4,
-       .do_5 = xor_lasx_5,
-};
-#endif /* CONFIG_CPU_HAS_LASX */
 
 /*
  * For grins, also test the generic routines.
@@ -38,6 +17,9 @@ static struct xor_block_template xor_block_lasx = {
  */
 #include <asm-generic/xor.h>
 
+extern struct xor_block_template xor_block_lsx;
+extern struct xor_block_template xor_block_lasx;
+
 #define arch_xor_init arch_xor_init
 static __always_inline void __init arch_xor_init(void)
 {
diff --git a/arch/loongarch/include/asm/xor_simd.h b/arch/loongarch/include/asm/xor_simd.h
deleted file mode 100644 (file)
index 471b963..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2023 WANG Xuerui <git@xen0n.name>
- */
-#ifndef _ASM_LOONGARCH_XOR_SIMD_H
-#define _ASM_LOONGARCH_XOR_SIMD_H
-
-#ifdef CONFIG_CPU_HAS_LSX
-void xor_lsx_2(unsigned long bytes, unsigned long * __restrict p1,
-              const unsigned long * __restrict p2);
-void xor_lsx_3(unsigned long bytes, unsigned long * __restrict p1,
-              const unsigned long * __restrict p2, const unsigned long * __restrict p3);
-void xor_lsx_4(unsigned long bytes, unsigned long * __restrict p1,
-              const unsigned long * __restrict p2, const unsigned long * __restrict p3,
-              const unsigned long * __restrict p4);
-void xor_lsx_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);
-#endif /* CONFIG_CPU_HAS_LSX */
-
-#ifdef CONFIG_CPU_HAS_LASX
-void xor_lasx_2(unsigned long bytes, unsigned long * __restrict p1,
-               const unsigned long * __restrict p2);
-void xor_lasx_3(unsigned long bytes, unsigned long * __restrict p1,
-               const unsigned long * __restrict p2, const unsigned long * __restrict p3);
-void xor_lasx_4(unsigned long bytes, unsigned long * __restrict p1,
-               const unsigned long * __restrict p2, const unsigned long * __restrict p3,
-               const unsigned long * __restrict p4);
-void xor_lasx_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);
-#endif /* CONFIG_CPU_HAS_LASX */
-
-#endif /* _ASM_LOONGARCH_XOR_SIMD_H */
index ccea3bbd4353134fb115fc547f742f9f5e420204..827a88529a425c58826e395050502b012322bd72 100644 (file)
@@ -8,6 +8,4 @@ lib-y   += delay.o memset.o memcpy.o memmove.o \
 
 obj-$(CONFIG_ARCH_SUPPORTS_INT128) += tishift.o
 
-obj-$(CONFIG_CPU_HAS_LSX) += xor_simd.o xor_simd_glue.o
-
 obj-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
index 4ab0e7411ff76966363d0dcfb2343ccfcd2562e6..e8868f5fc39642acf260a3a80c460df16103a3e5 100644 (file)
@@ -14,6 +14,8 @@ 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
+xor-$(CONFIG_CPU_HAS_LSX)      += loongarch/xor_simd.o
+xor-$(CONFIG_CPU_HAS_LSX)      += loongarch/xor_simd_glue.o
 
 
 CFLAGS_arm/xor-neon.o          += $(CC_FLAGS_FPU)
similarity index 64%
rename from arch/loongarch/lib/xor_simd_glue.c
rename to lib/raid/xor/loongarch/xor_simd_glue.c
index 393f689dbcf67827a034e07f4c2b4ce43b44b721..11fa3b47ba83a3af796da061e7d669f33563b67c 100644 (file)
@@ -5,24 +5,23 @@
  * Copyright (C) 2023 WANG Xuerui <git@xen0n.name>
  */
 
-#include <linux/export.h>
 #include <linux/sched.h>
+#include <linux/raid/xor_impl.h>
 #include <asm/fpu.h>
-#include <asm/xor_simd.h>
+#include <asm/xor.h>
 #include "xor_simd.h"
 
 #define MAKE_XOR_GLUE_2(flavor)                                                        \
-void xor_##flavor##_2(unsigned long bytes, unsigned long * __restrict p1,      \
+static void xor_##flavor##_2(unsigned long bytes, unsigned long * __restrict p1,\
                      const unsigned long * __restrict p2)                      \
 {                                                                              \
        kernel_fpu_begin();                                                     \
        __xor_##flavor##_2(bytes, p1, p2);                                      \
        kernel_fpu_end();                                                       \
 }                                                                              \
-EXPORT_SYMBOL_GPL(xor_##flavor##_2)
 
 #define MAKE_XOR_GLUE_3(flavor)                                                        \
-void xor_##flavor##_3(unsigned long bytes, unsigned long * __restrict p1,      \
+static void xor_##flavor##_3(unsigned long bytes, unsigned long * __restrict p1,\
                      const unsigned long * __restrict p2,                      \
                      const unsigned long * __restrict p3)                      \
 {                                                                              \
@@ -30,10 +29,9 @@ void xor_##flavor##_3(unsigned long bytes, unsigned long * __restrict p1,    \
        __xor_##flavor##_3(bytes, p1, p2, p3);                                  \
        kernel_fpu_end();                                                       \
 }                                                                              \
-EXPORT_SYMBOL_GPL(xor_##flavor##_3)
 
 #define MAKE_XOR_GLUE_4(flavor)                                                        \
-void xor_##flavor##_4(unsigned long bytes, unsigned long * __restrict p1,      \
+static void xor_##flavor##_4(unsigned long bytes, unsigned long * __restrict p1,\
                      const unsigned long * __restrict p2,                      \
                      const unsigned long * __restrict p3,                      \
                      const unsigned long * __restrict p4)                      \
@@ -42,10 +40,9 @@ void xor_##flavor##_4(unsigned long bytes, unsigned long * __restrict p1,    \
        __xor_##flavor##_4(bytes, p1, p2, p3, p4);                              \
        kernel_fpu_end();                                                       \
 }                                                                              \
-EXPORT_SYMBOL_GPL(xor_##flavor##_4)
 
 #define MAKE_XOR_GLUE_5(flavor)                                                        \
-void xor_##flavor##_5(unsigned long bytes, unsigned long * __restrict p1,      \
+static void xor_##flavor##_5(unsigned long bytes, unsigned long * __restrict p1,\
                      const unsigned long * __restrict p2,                      \
                      const unsigned long * __restrict p3,                      \
                      const unsigned long * __restrict p4,                      \
@@ -55,18 +52,26 @@ void xor_##flavor##_5(unsigned long bytes, unsigned long * __restrict p1,   \
        __xor_##flavor##_5(bytes, p1, p2, p3, p4, p5);                          \
        kernel_fpu_end();                                                       \
 }                                                                              \
-EXPORT_SYMBOL_GPL(xor_##flavor##_5)
 
-#define MAKE_XOR_GLUES(flavor)         \
-       MAKE_XOR_GLUE_2(flavor);        \
-       MAKE_XOR_GLUE_3(flavor);        \
-       MAKE_XOR_GLUE_4(flavor);        \
-       MAKE_XOR_GLUE_5(flavor)
+#define MAKE_XOR_GLUES(flavor)                         \
+       MAKE_XOR_GLUE_2(flavor);                        \
+       MAKE_XOR_GLUE_3(flavor);                        \
+       MAKE_XOR_GLUE_4(flavor);                        \
+       MAKE_XOR_GLUE_5(flavor);                        \
+                                                       \
+struct xor_block_template xor_block_##flavor = {       \
+       .name = __stringify(flavor),                    \
+       .do_2 = xor_##flavor##_2,                       \
+       .do_3 = xor_##flavor##_3,                       \
+       .do_4 = xor_##flavor##_4,                       \
+       .do_5 = xor_##flavor##_5,                       \
+}
+
 
 #ifdef CONFIG_CPU_HAS_LSX
 MAKE_XOR_GLUES(lsx);
-#endif
+#endif /* CONFIG_CPU_HAS_LSX */
 
 #ifdef CONFIG_CPU_HAS_LASX
 MAKE_XOR_GLUES(lasx);
-#endif
+#endif /* CONFIG_CPU_HAS_LASX */