xref: /linux/lib/raid/xor/loongarch/xor_simd_glue.c (revision 440d6635b20037bc9ad46b20817d7b61cef0fc1b)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * LoongArch SIMD XOR operations
4  *
5  * Copyright (C) 2023 WANG Xuerui <git@xen0n.name>
6  */
7 
8 #include <linux/sched.h>
9 #include <asm/fpu.h>
10 #include "xor_impl.h"
11 #include "xor_arch.h"
12 #include "xor_simd.h"
13 
14 #define MAKE_XOR_GLUES(flavor)							\
15 DO_XOR_BLOCKS(flavor##_inner, __xor_##flavor##_2, __xor_##flavor##_3,		\
16 		__xor_##flavor##_4, __xor_##flavor##_5);			\
17 										\
18 static void xor_gen_##flavor(void *dest, void **srcs, unsigned int src_cnt,	\
19 		unsigned int bytes)						\
20 {										\
21 	kernel_fpu_begin();							\
22 	xor_gen_##flavor##_inner(dest, srcs, src_cnt, bytes);			\
23 	kernel_fpu_end();							\
24 }										\
25 										\
26 struct xor_block_template xor_block_##flavor = {				\
27 	.name		= __stringify(flavor),					\
28 	.xor_gen	= xor_gen_##flavor					\
29 }
30 
31 #ifdef CONFIG_CPU_HAS_LSX
32 MAKE_XOR_GLUES(lsx);
33 #endif /* CONFIG_CPU_HAS_LSX */
34 
35 #ifdef CONFIG_CPU_HAS_LASX
36 MAKE_XOR_GLUES(lasx);
37 #endif /* CONFIG_CPU_HAS_LASX */
38