Skip to contentSkip to conversation

lib/crc: Use uint64_t for the new NEON crc64 fold constants

PATCH In review Sasha Levin 3 participants 3 messages Nov 22 – Nov 23

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/crc: Use uint64_t for the new NEON crc64 fold constants

Commit ff049836f05f ("lib/crc: Don't include <linux/types.h> in NEON intrinsics code") in mainline switched the arrays passed to vld1q_u64() to uint64_t, since u64 and the uint64_t that vld1q_u64() takes are different types on arm64 once <linux/types.h> is gone. The two arrays added by commit ef4102757fdd ("lib/crc:
Add 4-way folding in NEON crc64_nvme implementation") still use u64, so the combination fails to build with clang:

lib/crc/crc64-neon.c:66:40: error: incompatible pointer types assigning to 'const unsigned long *' from 'const u64 *' (aka 'const unsigned long long *') [-Werror,-Wincompatible-pointer-types]

Use uint64_t for them too. This builds with and without ff049836f05f.

Fixes ef4102757fdd ("lib/crc: Add 4-way folding in NEON crc64_nvme implementation")

---

crc-next is based on v7.4-rc2 and ff049836f05f went into mainline after rc3, so linux-next will hit this once it merges the two. all-next hit it already.

Tested on arm64: lib/crc/crc64-neon.o builds with clang and gcc on crc-next, and with clang on crc-next merged with mainline 4843f6873f7c. Without this patch the merged tree fails as above.

 lib/crc/crc64-neon.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/crc/crc64-neon.c +4 -4
index 03b46d0abcc41..f36389789fe65 100644
@@ -11,11 +11,11 @@
 u64 crc64_nvme_neon(u64 crc, const u8 *p, size_t len);
 
 /* x^575 mod G, x^511 mod G */
-static const u64 fold_consts_4x_val[2] = { 0x0c32cdb31e18a84aULL,
-					   0x62242240ace5045aULL };
+static const uint64_t fold_consts_4x_val[2] = { 0x0c32cdb31e18a84aULL,
+						0x62242240ace5045aULL };
 /* x^319 mod G, x^255 mod G */
-static const u64 fold_consts_2x_val[2] = { 0xb0bc2e589204f500ULL,
-					   0xe1e0bb9d45d7a44cULL };
+static const uint64_t fold_consts_2x_val[2] = { 0xb0bc2e589204f500ULL,
+						0xe1e0bb9d45d7a44cULL };
 /* x^191 mod G, x^127 mod G */
 static const u64 fold_consts_val[2] = { 0xeadc41fd2ba3d420ULL,
 					0x21e9761e252621acULL };

base-commit: ef4102757fdd84b0b6189260780ac5faf132edc7

Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 38 lines · Sasha Levin

Commit ff049836f05f ("lib/crc: Don't include <linux/types.h> in NEON intrinsics code") in mainline switched the arrays passed to vld1q_u64() to uint64_t, since u64 and the uint64_t that vld1q_u64() takes are different types on arm64 once <linux/types.h> is gone. The two arrays added by commit ef4102757fdd ("lib/crc:
Add 4-way folding in NEON crc64_nvme implementation") still use u64, so the combination fails to build with clang:

lib/crc/crc64-neon.c:66:40: error: incompatible pointer types assigning to 'const unsigned long *' from 'const u64 *' (aka 'const unsigned long long *') [-Werror,-Wincompatible-pointer-types]

Use uint64_t for them too. This builds with and without ff049836f05f.

Fixes ef4102757fdd ("lib/crc: Add 4-way folding in NEON crc64_nvme implementation")

---

crc-next is based on v7.4-rc2 and ff049836f05f went into mainline after rc3, so linux-next will hit this once it merges the two. all-next hit it already.

Tested on arm64: lib/crc/crc64-neon.o builds with clang and gcc on crc-next, and with clang on crc-next merged with mainline 4843f6873f7c. Without this patch the merged tree fails as above.

 lib/crc/crc64-neon.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/crc/crc64-neon.c +0 -2
index 03b46d0abcc41..f36389789fe65 100644
@@ -11,11 +11,11 @@
 u64 crc64_nvme_neon(u64 crc, const u8 *p, size_t len);
 
 /* x^575 mod G, x^511 mod G */
-static const u64 fold_consts_4x_val[2] = { 0x0c32cdb31e18a84aULL,
-					   0x62242240ace5045aULL };

lib/crc/crc64-neon.c line 21

Quoted 10 lines
lib/crc/crc64-neon.c +4 -2
+static const uint64_t fold_consts_4x_val[2] = { 0x0c32cdb31e18a84aULL,
+						0x62242240ace5045aULL };
 /* x^319 mod G, x^255 mod G */
-static const u64 fold_consts_2x_val[2] = { 0xb0bc2e589204f500ULL,
-					   0xe1e0bb9d45d7a44cULL };
+static const uint64_t fold_consts_2x_val[2] = { 0xb0bc2e589204f500ULL,
+						0xe1e0bb9d45d7a44cULL };
 /* x^191 mod G, x^127 mod G */
 static const u64 fold_consts_val[2] = { 0xeadc41fd2ba3d420ULL,
 					0x21e9761e252621acULL };

Thanks Sasha.

I've dropped "lib/crc: Add 4-way folding in NEON crc64_nvme implementation" from crc-next temporarily.

Shreesh, could you send a new patch that folds together that patch with the two fixups for it? Then we'd get one clean patch.

lib/crc: Add 4-way folding in NEON crc64_nvme implementation lib/crc: arm: Support partial blocks in NEON crc64_nvme lib/crc: Use uint64_t for the new NEON crc64 fold constants

Thanks!

- Eric

#2 lore raw

Hi Eric,

Quoted 56 lines · Eric Biggers
Quoted 38 lines · Sasha Levin

Commit ff049836f05f ("lib/crc: Don't include <linux/types.h> in NEON intrinsics code") in mainline switched the arrays passed to vld1q_u64() to uint64_t, since u64 and the uint64_t that vld1q_u64() takes are different types on arm64 once <linux/types.h> is gone. The two arrays added by commit ef4102757fdd ("lib/crc:
Add 4-way folding in NEON crc64_nvme implementation") still use u64, so the combination fails to build with clang:

lib/crc/crc64-neon.c:66:40: error: incompatible pointer types assigning to 'const unsigned long *' from 'const u64 *' (aka 'const unsigned long long *') [-Werror,-Wincompatible-pointer-types]

Use uint64_t for them too. This builds with and without ff049836f05f.

Fixes ef4102757fdd ("lib/crc: Add 4-way folding in NEON crc64_nvme implementation")

---

crc-next is based on v7.4-rc2 and ff049836f05f went into mainline after rc3, so linux-next will hit this once it merges the two. all-next hit it already.

Tested on arm64: lib/crc/crc64-neon.o builds with clang and gcc on crc-next, and with clang on crc-next merged with mainline 4843f6873f7c. Without this patch the merged tree fails as above.

 lib/crc/crc64-neon.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/crc/crc64-neon.c +0 -2
index 03b46d0abcc41..f36389789fe65 100644
@@ -11,11 +11,11 @@
 u64 crc64_nvme_neon(u64 crc, const u8 *p, size_t len);
 
 /* x^575 mod G, x^511 mod G */
-static const u64 fold_consts_4x_val[2] = { 0x0c32cdb31e18a84aULL,
-                                        0x62242240ace5045aULL };

lib/crc/crc64-neon.c line 21

Quoted 10 lines
lib/crc/crc64-neon.c +4 -2
+static const uint64_t fold_consts_4x_val[2] = { 0x0c32cdb31e18a84aULL,
+                                             0x62242240ace5045aULL };
 /* x^319 mod G, x^255 mod G */
-static const u64 fold_consts_2x_val[2] = { 0xb0bc2e589204f500ULL,
-                                        0xe1e0bb9d45d7a44cULL };
+static const uint64_t fold_consts_2x_val[2] = { 0xb0bc2e589204f500ULL,
+                                             0xe1e0bb9d45d7a44cULL };
 /* x^191 mod G, x^127 mod G */
 static const u64 fold_consts_val[2] = { 0xeadc41fd2ba3d420ULL,
                                      0x21e9761e252621acULL };

Thanks Sasha.

I've dropped "lib/crc: Add 4-way folding in NEON crc64_nvme implementation" from crc-next temporarily.

Quoted 6 lines

Shreesh, could you send a new patch that folds together that patch with the two fixups for it? Then we'd get one clean patch.

lib/crc: Add 4-way folding in NEON crc64_nvme implementation lib/crc: arm: Support partial blocks in NEON crc64_nvme lib/crc: Use uint64_t for the new NEON crc64 fold constants

I've submitted v2 for "lib/crc: Add 4-way folding in NEON crc64_nvme implementation" which essentially contains those three listed commits (I also changed u8 to uint8_t used by vld1q_u8() in fold_partial_block for consistency).
There are some checkpatch CHECK printed about usage of uint64_t and uint8_t and to prefer the u64/u8 though, hopefully that can be tweaked to allow for neon code?
I've rebased the patch on top of 7.4-rc4 latest master so hopefully it should be sufficient here. Kindly review the v2 recently submitted and let me know if any additional changes are necessary.

Thanks,
Shreesh