1 // SPDX-License-Identifier: GPL-2.0-only 1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 2 /* 3 * Copyright (C) 2012 Intel Corporation 3 * Copyright (C) 2012 Intel Corporation 4 * Copyright (C) 2017 Linaro Ltd. <ard.biesheu 4 * Copyright (C) 2017 Linaro Ltd. <ard.biesheuvel@linaro.org> 5 */ 5 */ 6 6 7 #include <linux/raid/pq.h> 7 #include <linux/raid/pq.h> 8 8 9 #ifdef __KERNEL__ 9 #ifdef __KERNEL__ 10 #include <asm/neon.h> 10 #include <asm/neon.h> 11 #include "neon.h" << 12 #else 11 #else 13 #define kernel_neon_begin() 12 #define kernel_neon_begin() 14 #define kernel_neon_end() 13 #define kernel_neon_end() 15 #define cpu_has_neon() (1) 14 #define cpu_has_neon() (1) 16 #endif 15 #endif 17 16 18 static int raid6_has_neon(void) 17 static int raid6_has_neon(void) 19 { 18 { 20 return cpu_has_neon(); 19 return cpu_has_neon(); 21 } 20 } >> 21 >> 22 void __raid6_2data_recov_neon(int bytes, uint8_t *p, uint8_t *q, uint8_t *dp, >> 23 uint8_t *dq, const uint8_t *pbmul, >> 24 const uint8_t *qmul); >> 25 >> 26 void __raid6_datap_recov_neon(int bytes, uint8_t *p, uint8_t *q, uint8_t *dq, >> 27 const uint8_t *qmul); 22 28 23 static void raid6_2data_recov_neon(int disks, 29 static void raid6_2data_recov_neon(int disks, size_t bytes, int faila, 24 int failb, void **ptrs) 30 int failb, void **ptrs) 25 { 31 { 26 u8 *p, *q, *dp, *dq; 32 u8 *p, *q, *dp, *dq; 27 const u8 *pbmul; /* P multiplie 33 const u8 *pbmul; /* P multiplier table for B data */ 28 const u8 *qmul; /* Q multiplie 34 const u8 *qmul; /* Q multiplier table (for both) */ 29 35 30 p = (u8 *)ptrs[disks - 2]; 36 p = (u8 *)ptrs[disks - 2]; 31 q = (u8 *)ptrs[disks - 1]; 37 q = (u8 *)ptrs[disks - 1]; 32 38 33 /* 39 /* 34 * Compute syndrome with zero for the 40 * Compute syndrome with zero for the missing data pages 35 * Use the dead data pages as temporar 41 * Use the dead data pages as temporary storage for 36 * delta p and delta q 42 * delta p and delta q 37 */ 43 */ 38 dp = (u8 *)ptrs[faila]; 44 dp = (u8 *)ptrs[faila]; 39 ptrs[faila] = (void *)raid6_empty_zero 45 ptrs[faila] = (void *)raid6_empty_zero_page; 40 ptrs[disks - 2] = dp; 46 ptrs[disks - 2] = dp; 41 dq = (u8 *)ptrs[failb]; 47 dq = (u8 *)ptrs[failb]; 42 ptrs[failb] = (void *)raid6_empty_zero 48 ptrs[failb] = (void *)raid6_empty_zero_page; 43 ptrs[disks - 1] = dq; 49 ptrs[disks - 1] = dq; 44 50 45 raid6_call.gen_syndrome(disks, bytes, 51 raid6_call.gen_syndrome(disks, bytes, ptrs); 46 52 47 /* Restore pointer table */ 53 /* Restore pointer table */ 48 ptrs[faila] = dp; 54 ptrs[faila] = dp; 49 ptrs[failb] = dq; 55 ptrs[failb] = dq; 50 ptrs[disks - 2] = p; 56 ptrs[disks - 2] = p; 51 ptrs[disks - 1] = q; 57 ptrs[disks - 1] = q; 52 58 53 /* Now, pick the proper data tables */ 59 /* Now, pick the proper data tables */ 54 pbmul = raid6_vgfmul[raid6_gfexi[failb 60 pbmul = raid6_vgfmul[raid6_gfexi[failb-faila]]; 55 qmul = raid6_vgfmul[raid6_gfinv[raid6 61 qmul = raid6_vgfmul[raid6_gfinv[raid6_gfexp[faila] ^ 56 raid6 62 raid6_gfexp[failb]]]; 57 63 58 kernel_neon_begin(); 64 kernel_neon_begin(); 59 __raid6_2data_recov_neon(bytes, p, q, 65 __raid6_2data_recov_neon(bytes, p, q, dp, dq, pbmul, qmul); 60 kernel_neon_end(); 66 kernel_neon_end(); 61 } 67 } 62 68 63 static void raid6_datap_recov_neon(int disks, 69 static void raid6_datap_recov_neon(int disks, size_t bytes, int faila, 64 void **ptrs) 70 void **ptrs) 65 { 71 { 66 u8 *p, *q, *dq; 72 u8 *p, *q, *dq; 67 const u8 *qmul; /* Q multiplie 73 const u8 *qmul; /* Q multiplier table */ 68 74 69 p = (u8 *)ptrs[disks - 2]; 75 p = (u8 *)ptrs[disks - 2]; 70 q = (u8 *)ptrs[disks - 1]; 76 q = (u8 *)ptrs[disks - 1]; 71 77 72 /* 78 /* 73 * Compute syndrome with zero for the 79 * Compute syndrome with zero for the missing data page 74 * Use the dead data page as temporary 80 * Use the dead data page as temporary storage for delta q 75 */ 81 */ 76 dq = (u8 *)ptrs[faila]; 82 dq = (u8 *)ptrs[faila]; 77 ptrs[faila] = (void *)raid6_empty_zero 83 ptrs[faila] = (void *)raid6_empty_zero_page; 78 ptrs[disks - 1] = dq; 84 ptrs[disks - 1] = dq; 79 85 80 raid6_call.gen_syndrome(disks, bytes, 86 raid6_call.gen_syndrome(disks, bytes, ptrs); 81 87 82 /* Restore pointer table */ 88 /* Restore pointer table */ 83 ptrs[faila] = dq; 89 ptrs[faila] = dq; 84 ptrs[disks - 1] = q; 90 ptrs[disks - 1] = q; 85 91 86 /* Now, pick the proper data tables */ 92 /* Now, pick the proper data tables */ 87 qmul = raid6_vgfmul[raid6_gfinv[raid6_ 93 qmul = raid6_vgfmul[raid6_gfinv[raid6_gfexp[faila]]]; 88 94 89 kernel_neon_begin(); 95 kernel_neon_begin(); 90 __raid6_datap_recov_neon(bytes, p, q, 96 __raid6_datap_recov_neon(bytes, p, q, dq, qmul); 91 kernel_neon_end(); 97 kernel_neon_end(); 92 } 98 } 93 99 94 const struct raid6_recov_calls raid6_recov_neo 100 const struct raid6_recov_calls raid6_recov_neon = { 95 .data2 = raid6_2data_recov_ne 101 .data2 = raid6_2data_recov_neon, 96 .datap = raid6_datap_recov_ne 102 .datap = raid6_datap_recov_neon, 97 .valid = raid6_has_neon, 103 .valid = raid6_has_neon, 98 .name = "neon", 104 .name = "neon", 99 .priority = 10, 105 .priority = 10, 100 }; 106 }; 101 107
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.