xref: /linux/lib/raid/xor/s390/xor.c (revision 440d6635b20037bc9ad46b20817d7b61cef0fc1b)
195c104ccSChristoph Hellwig // SPDX-License-Identifier: GPL-2.0
295c104ccSChristoph Hellwig /*
395c104ccSChristoph Hellwig  * Optimized xor_block operation for RAID4/5
495c104ccSChristoph Hellwig  *
595c104ccSChristoph Hellwig  * Copyright IBM Corp. 2016
695c104ccSChristoph Hellwig  * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
795c104ccSChristoph Hellwig  */
895c104ccSChristoph Hellwig 
995c104ccSChristoph Hellwig #include <linux/types.h>
10e20043b4SChristoph Hellwig #include "xor_impl.h"
11e20043b4SChristoph Hellwig #include "xor_arch.h"
1295c104ccSChristoph Hellwig 
1395c104ccSChristoph Hellwig static void xor_xc_2(unsigned long bytes, unsigned long * __restrict p1,
1495c104ccSChristoph Hellwig 		     const unsigned long * __restrict p2)
1595c104ccSChristoph Hellwig {
1695c104ccSChristoph Hellwig 	asm volatile(
1795c104ccSChristoph Hellwig 		"	aghi	%0,-1\n"
1895c104ccSChristoph Hellwig 		"	jm	3f\n"
1995c104ccSChristoph Hellwig 		"	srlg	0,%0,8\n"
2095c104ccSChristoph Hellwig 		"	ltgr	0,0\n"
2195c104ccSChristoph Hellwig 		"	jz	1f\n"
2295c104ccSChristoph Hellwig 		"0:	xc	0(256,%1),0(%2)\n"
2395c104ccSChristoph Hellwig 		"	la	%1,256(%1)\n"
2495c104ccSChristoph Hellwig 		"	la	%2,256(%2)\n"
2595c104ccSChristoph Hellwig 		"	brctg	0,0b\n"
2695c104ccSChristoph Hellwig 		"1:	exrl	%0,2f\n"
2795c104ccSChristoph Hellwig 		"	j	3f\n"
2895c104ccSChristoph Hellwig 		"2:	xc	0(1,%1),0(%2)\n"
2995c104ccSChristoph Hellwig 		"3:"
3095c104ccSChristoph Hellwig 		: "+a" (bytes), "+a" (p1), "+a" (p2)
3195c104ccSChristoph Hellwig 		: : "0", "cc", "memory");
3295c104ccSChristoph Hellwig }
3395c104ccSChristoph Hellwig 
3495c104ccSChristoph Hellwig static void xor_xc_3(unsigned long bytes, unsigned long * __restrict p1,
3595c104ccSChristoph Hellwig 		     const unsigned long * __restrict p2,
3695c104ccSChristoph Hellwig 		     const unsigned long * __restrict p3)
3795c104ccSChristoph Hellwig {
3895c104ccSChristoph Hellwig 	asm volatile(
3995c104ccSChristoph Hellwig 		"	aghi	%0,-1\n"
4095c104ccSChristoph Hellwig 		"	jm	4f\n"
4195c104ccSChristoph Hellwig 		"	srlg	0,%0,8\n"
4295c104ccSChristoph Hellwig 		"	ltgr	0,0\n"
4395c104ccSChristoph Hellwig 		"	jz	1f\n"
4495c104ccSChristoph Hellwig 		"0:	xc	0(256,%1),0(%2)\n"
4595c104ccSChristoph Hellwig 		"	xc	0(256,%1),0(%3)\n"
4695c104ccSChristoph Hellwig 		"	la	%1,256(%1)\n"
4795c104ccSChristoph Hellwig 		"	la	%2,256(%2)\n"
4895c104ccSChristoph Hellwig 		"	la	%3,256(%3)\n"
4995c104ccSChristoph Hellwig 		"	brctg	0,0b\n"
5095c104ccSChristoph Hellwig 		"1:	exrl	%0,2f\n"
5195c104ccSChristoph Hellwig 		"	exrl	%0,3f\n"
5295c104ccSChristoph Hellwig 		"	j	4f\n"
5395c104ccSChristoph Hellwig 		"2:	xc	0(1,%1),0(%2)\n"
5495c104ccSChristoph Hellwig 		"3:	xc	0(1,%1),0(%3)\n"
5595c104ccSChristoph Hellwig 		"4:"
5695c104ccSChristoph Hellwig 		: "+a" (bytes), "+a" (p1), "+a" (p2), "+a" (p3)
5795c104ccSChristoph Hellwig 		: : "0", "cc", "memory");
5895c104ccSChristoph Hellwig }
5995c104ccSChristoph Hellwig 
6095c104ccSChristoph Hellwig static void xor_xc_4(unsigned long bytes, unsigned long * __restrict p1,
6195c104ccSChristoph Hellwig 		     const unsigned long * __restrict p2,
6295c104ccSChristoph Hellwig 		     const unsigned long * __restrict p3,
6395c104ccSChristoph Hellwig 		     const unsigned long * __restrict p4)
6495c104ccSChristoph Hellwig {
6595c104ccSChristoph Hellwig 	asm volatile(
6695c104ccSChristoph Hellwig 		"	aghi	%0,-1\n"
6795c104ccSChristoph Hellwig 		"	jm	5f\n"
6895c104ccSChristoph Hellwig 		"	srlg	0,%0,8\n"
6995c104ccSChristoph Hellwig 		"	ltgr	0,0\n"
7095c104ccSChristoph Hellwig 		"	jz	1f\n"
7195c104ccSChristoph Hellwig 		"0:	xc	0(256,%1),0(%2)\n"
7295c104ccSChristoph Hellwig 		"	xc	0(256,%1),0(%3)\n"
7395c104ccSChristoph Hellwig 		"	xc	0(256,%1),0(%4)\n"
7495c104ccSChristoph Hellwig 		"	la	%1,256(%1)\n"
7595c104ccSChristoph Hellwig 		"	la	%2,256(%2)\n"
7695c104ccSChristoph Hellwig 		"	la	%3,256(%3)\n"
7795c104ccSChristoph Hellwig 		"	la	%4,256(%4)\n"
7895c104ccSChristoph Hellwig 		"	brctg	0,0b\n"
7995c104ccSChristoph Hellwig 		"1:	exrl	%0,2f\n"
8095c104ccSChristoph Hellwig 		"	exrl	%0,3f\n"
8195c104ccSChristoph Hellwig 		"	exrl	%0,4f\n"
8295c104ccSChristoph Hellwig 		"	j	5f\n"
8395c104ccSChristoph Hellwig 		"2:	xc	0(1,%1),0(%2)\n"
8495c104ccSChristoph Hellwig 		"3:	xc	0(1,%1),0(%3)\n"
8595c104ccSChristoph Hellwig 		"4:	xc	0(1,%1),0(%4)\n"
8695c104ccSChristoph Hellwig 		"5:"
8795c104ccSChristoph Hellwig 		: "+a" (bytes), "+a" (p1), "+a" (p2), "+a" (p3), "+a" (p4)
8895c104ccSChristoph Hellwig 		: : "0", "cc", "memory");
8995c104ccSChristoph Hellwig }
9095c104ccSChristoph Hellwig 
9195c104ccSChristoph Hellwig static void xor_xc_5(unsigned long bytes, unsigned long * __restrict p1,
9295c104ccSChristoph Hellwig 		     const unsigned long * __restrict p2,
9395c104ccSChristoph Hellwig 		     const unsigned long * __restrict p3,
9495c104ccSChristoph Hellwig 		     const unsigned long * __restrict p4,
9595c104ccSChristoph Hellwig 		     const unsigned long * __restrict p5)
9695c104ccSChristoph Hellwig {
9795c104ccSChristoph Hellwig 	asm volatile(
9895c104ccSChristoph Hellwig 		"	aghi	%0,-1\n"
9995c104ccSChristoph Hellwig 		"	jm	6f\n"
10095c104ccSChristoph Hellwig 		"	srlg	0,%0,8\n"
10195c104ccSChristoph Hellwig 		"	ltgr	0,0\n"
10295c104ccSChristoph Hellwig 		"	jz	1f\n"
10395c104ccSChristoph Hellwig 		"0:	xc	0(256,%1),0(%2)\n"
10495c104ccSChristoph Hellwig 		"	xc	0(256,%1),0(%3)\n"
10595c104ccSChristoph Hellwig 		"	xc	0(256,%1),0(%4)\n"
10695c104ccSChristoph Hellwig 		"	xc	0(256,%1),0(%5)\n"
10795c104ccSChristoph Hellwig 		"	la	%1,256(%1)\n"
10895c104ccSChristoph Hellwig 		"	la	%2,256(%2)\n"
10995c104ccSChristoph Hellwig 		"	la	%3,256(%3)\n"
11095c104ccSChristoph Hellwig 		"	la	%4,256(%4)\n"
11195c104ccSChristoph Hellwig 		"	la	%5,256(%5)\n"
11295c104ccSChristoph Hellwig 		"	brctg	0,0b\n"
11395c104ccSChristoph Hellwig 		"1:	exrl	%0,2f\n"
11495c104ccSChristoph Hellwig 		"	exrl	%0,3f\n"
11595c104ccSChristoph Hellwig 		"	exrl	%0,4f\n"
11695c104ccSChristoph Hellwig 		"	exrl	%0,5f\n"
11795c104ccSChristoph Hellwig 		"	j	6f\n"
11895c104ccSChristoph Hellwig 		"2:	xc	0(1,%1),0(%2)\n"
11995c104ccSChristoph Hellwig 		"3:	xc	0(1,%1),0(%3)\n"
12095c104ccSChristoph Hellwig 		"4:	xc	0(1,%1),0(%4)\n"
12195c104ccSChristoph Hellwig 		"5:	xc	0(1,%1),0(%5)\n"
12295c104ccSChristoph Hellwig 		"6:"
12395c104ccSChristoph Hellwig 		: "+a" (bytes), "+a" (p1), "+a" (p2), "+a" (p3), "+a" (p4),
12495c104ccSChristoph Hellwig 		  "+a" (p5)
12595c104ccSChristoph Hellwig 		: : "0", "cc", "memory");
12695c104ccSChristoph Hellwig }
12795c104ccSChristoph Hellwig 
128*80dcf0a7SChristoph Hellwig DO_XOR_BLOCKS(xc, xor_xc_2, xor_xc_3, xor_xc_4, xor_xc_5);
129*80dcf0a7SChristoph Hellwig 
13095c104ccSChristoph Hellwig struct xor_block_template xor_block_xc = {
13195c104ccSChristoph Hellwig 	.name		= "xc",
132*80dcf0a7SChristoph Hellwig 	.xor_gen	= xor_gen_xc,
13395c104ccSChristoph Hellwig };
134