summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeiko Carstens <hca@linux.ibm.com>2025-04-17 14:30:56 +0200
committerEric Biggers <ebiggers@google.com>2025-04-28 09:07:19 -0700
commit93b988cf8e4c68b823e70a02e4c7c39eaa0053be (patch)
treed629b01c145a1492ca931e8392018f0f604d9d1c
parent7ef377c4d4abb7a2a74fc319dc1bce46f2449af7 (diff)
s390/crc32: Remove have_vxrs static key
Replace the have_vxrs static key with a cpu_has_vx() call. cpu_has_vx() resolves into a compile time constant (true) if the kernel is compiled for z13 or newer. Otherwise it generates an unconditional one instruction branch, which is patched based on CPU alternatives. In any case the generated code is at least as good as before and avoids static key handling. Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Link: https://lore.kernel.org/r/20250417125318.12521F12-hca@linux.ibm.com/ Signed-off-by: Eric Biggers <ebiggers@google.com>
-rw-r--r--arch/s390/lib/crc32-glue.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/arch/s390/lib/crc32-glue.c b/arch/s390/lib/crc32-glue.c
index 8f20a8e595c3..649ed7e8b99c 100644
--- a/arch/s390/lib/crc32-glue.c
+++ b/arch/s390/lib/crc32-glue.c
@@ -18,8 +18,6 @@
#define VX_ALIGNMENT 16L
#define VX_ALIGN_MASK (VX_ALIGNMENT - 1)
-static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_vxrs);
-
/*
* DEFINE_CRC32_VX() - Define a CRC-32 function using the vector extension
*
@@ -34,8 +32,7 @@ static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_vxrs);
unsigned long prealign, aligned, remaining; \
DECLARE_KERNEL_FPU_ONSTACK16(vxstate); \
\
- if (datalen < VX_MIN_LEN + VX_ALIGN_MASK || \
- !static_branch_likely(&have_vxrs)) \
+ if (datalen < VX_MIN_LEN + VX_ALIGN_MASK || !cpu_has_vx()) \
return ___crc32_sw(crc, data, datalen); \
\
if ((unsigned long)data & VX_ALIGN_MASK) { \
@@ -66,8 +63,6 @@ DEFINE_CRC32_VX(crc32c_arch, crc32c_le_vgfm_16, crc32c_base)
static int __init crc32_s390_init(void)
{
- if (cpu_have_feature(S390_CPU_FEATURE_VXRS))
- static_branch_enable(&have_vxrs);
return 0;
}
arch_initcall(crc32_s390_init);
@@ -79,10 +74,11 @@ module_exit(crc32_s390_exit);
u32 crc32_optimizations(void)
{
- if (static_key_enabled(&have_vxrs))
+ if (cpu_has_vx()) {
return CRC32_LE_OPTIMIZATION |
CRC32_BE_OPTIMIZATION |
CRC32C_OPTIMIZATION;
+ }
return 0;
}
EXPORT_SYMBOL(crc32_optimizations);