recov_neon.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (C) 2012 Intel Corporation
  3. * Copyright (C) 2017 Linaro Ltd. <ard.biesheuvel@linaro.org>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; version 2
  8. * of the License.
  9. */
  10. #include <linux/raid/pq.h>
  11. #ifdef __KERNEL__
  12. #include <asm/neon.h>
  13. #else
  14. #define kernel_neon_begin()
  15. #define kernel_neon_end()
  16. #define cpu_has_neon() (1)
  17. #endif
  18. static int raid6_has_neon(void)
  19. {
  20. return cpu_has_neon();
  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. void __raid6_datap_recov_neon(int bytes, uint8_t *p, uint8_t *q, uint8_t *dq,
  26. const uint8_t *qmul);
  27. static void raid6_2data_recov_neon(int disks, size_t bytes, int faila,
  28. int failb, void **ptrs)
  29. {
  30. u8 *p, *q, *dp, *dq;
  31. const u8 *pbmul; /* P multiplier table for B data */
  32. const u8 *qmul; /* Q multiplier table (for both) */
  33. p = (u8 *)ptrs[disks - 2];
  34. q = (u8 *)ptrs[disks - 1];
  35. /*
  36. * Compute syndrome with zero for the missing data pages
  37. * Use the dead data pages as temporary storage for
  38. * delta p and delta q
  39. */
  40. dp = (u8 *)ptrs[faila];
  41. ptrs[faila] = (void *)raid6_empty_zero_page;
  42. ptrs[disks - 2] = dp;
  43. dq = (u8 *)ptrs[failb];
  44. ptrs[failb] = (void *)raid6_empty_zero_page;
  45. ptrs[disks - 1] = dq;
  46. raid6_call.gen_syndrome(disks, bytes, ptrs);
  47. /* Restore pointer table */
  48. ptrs[faila] = dp;
  49. ptrs[failb] = dq;
  50. ptrs[disks - 2] = p;
  51. ptrs[disks - 1] = q;
  52. /* Now, pick the proper data tables */
  53. pbmul = raid6_vgfmul[raid6_gfexi[failb-faila]];
  54. qmul = raid6_vgfmul[raid6_gfinv[raid6_gfexp[faila] ^
  55. raid6_gfexp[failb]]];
  56. kernel_neon_begin();
  57. __raid6_2data_recov_neon(bytes, p, q, dp, dq, pbmul, qmul);
  58. kernel_neon_end();
  59. }
  60. static void raid6_datap_recov_neon(int disks, size_t bytes, int faila,
  61. void **ptrs)
  62. {
  63. u8 *p, *q, *dq;
  64. const u8 *qmul; /* Q multiplier table */
  65. p = (u8 *)ptrs[disks - 2];
  66. q = (u8 *)ptrs[disks - 1];
  67. /*
  68. * Compute syndrome with zero for the missing data page
  69. * Use the dead data page as temporary storage for delta q
  70. */
  71. dq = (u8 *)ptrs[faila];
  72. ptrs[faila] = (void *)raid6_empty_zero_page;
  73. ptrs[disks - 1] = dq;
  74. raid6_call.gen_syndrome(disks, bytes, ptrs);
  75. /* Restore pointer table */
  76. ptrs[faila] = dq;
  77. ptrs[disks - 1] = q;
  78. /* Now, pick the proper data tables */
  79. qmul = raid6_vgfmul[raid6_gfinv[raid6_gfexp[faila]]];
  80. kernel_neon_begin();
  81. __raid6_datap_recov_neon(bytes, p, q, dq, qmul);
  82. kernel_neon_end();
  83. }
  84. const struct raid6_recov_calls raid6_recov_neon = {
  85. .data2 = raid6_2data_recov_neon,
  86. .datap = raid6_datap_recov_neon,
  87. .valid = raid6_has_neon,
  88. .name = "neon",
  89. .priority = 10,
  90. };