summaryrefslogtreecommitdiff
path: root/lib/crc/x86/crc32.h
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@kernel.org>2025-07-19 15:49:37 -0700
committerEric Biggers <ebiggers@kernel.org>2025-07-20 20:52:28 -0700
commit110628e55a577468ef21f01e042e87c4257b2fd5 (patch)
treea5b9d5289ce5f367c9f22cb8245ac1e433ae8dec /lib/crc/x86/crc32.h
parent9b0236f4efb889869f7d4f3f084f508cc0433ec9 (diff)
lib/crc: x86: Reorganize crc-pclmul static_call initialization
Reorganize the crc-pclmul static_call initialization to place more of the logic in the *_mod_init_arch() functions instead of in the INIT_CRC_PCLMUL macro. This provides the flexibility to do more than a single static_call update for each CPU feature check. Right away, optimize crc64_mod_init_arch() to check the CPU features just once instead of twice, doing both the crc64_msb and crc64_lsb static_call updates together. A later commit will also use this to initialize an additional static_key when crc32_lsb_vpclmul_avx512() is enabled. Acked-by: Ard Biesheuvel <ardb@kernel.org> Link: https://lore.kernel.org/r/20250719224938.126512-2-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Diffstat (limited to 'lib/crc/x86/crc32.h')
-rw-r--r--lib/crc/x86/crc32.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/crc/x86/crc32.h b/lib/crc/x86/crc32.h
index 28451d5769c3..ba4dacf23340 100644
--- a/lib/crc/x86/crc32.h
+++ b/lib/crc/x86/crc32.h
@@ -77,7 +77,15 @@ static inline void crc32_mod_init_arch(void)
static_branch_enable(&have_crc32);
if (boot_cpu_has(X86_FEATURE_PCLMULQDQ)) {
static_branch_enable(&have_pclmulqdq);
- INIT_CRC_PCLMUL(crc32_lsb);
+ if (have_vpclmul()) {
+ if (have_avx512()) {
+ static_call_update(crc32_lsb_pclmul,
+ crc32_lsb_vpclmul_avx512);
+ } else {
+ static_call_update(crc32_lsb_pclmul,
+ crc32_lsb_vpclmul_avx2);
+ }
+ }
}
}