Skip to content

Commit 93b988c

Browse files
hcahcaebiggers
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected]/ Signed-off-by: Eric Biggers <[email protected]>
1 parent 7ef377c commit 93b988c

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

arch/s390/lib/crc32-glue.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#define VX_ALIGNMENT 16L
1919
#define VX_ALIGN_MASK (VX_ALIGNMENT - 1)
2020

21-
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_vxrs);
22-
2321
/*
2422
* DEFINE_CRC32_VX() - Define a CRC-32 function using the vector extension
2523
*
@@ -34,8 +32,7 @@ static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_vxrs);
3432
unsigned long prealign, aligned, remaining; \
3533
DECLARE_KERNEL_FPU_ONSTACK16(vxstate); \
3634
\
37-
if (datalen < VX_MIN_LEN + VX_ALIGN_MASK || \
38-
!static_branch_likely(&have_vxrs)) \
35+
if (datalen < VX_MIN_LEN + VX_ALIGN_MASK || !cpu_has_vx()) \
3936
return ___crc32_sw(crc, data, datalen); \
4037
\
4138
if ((unsigned long)data & VX_ALIGN_MASK) { \
@@ -66,8 +63,6 @@ DEFINE_CRC32_VX(crc32c_arch, crc32c_le_vgfm_16, crc32c_base)
6663

6764
static int __init crc32_s390_init(void)
6865
{
69-
if (cpu_have_feature(S390_CPU_FEATURE_VXRS))
70-
static_branch_enable(&have_vxrs);
7166
return 0;
7267
}
7368
arch_initcall(crc32_s390_init);
@@ -79,10 +74,11 @@ module_exit(crc32_s390_exit);
7974

8075
u32 crc32_optimizations(void)
8176
{
82-
if (static_key_enabled(&have_vxrs))
77+
if (cpu_has_vx()) {
8378
return CRC32_LE_OPTIMIZATION |
8479
CRC32_BE_OPTIMIZATION |
8580
CRC32C_OPTIMIZATION;
81+
}
8682
return 0;
8783
}
8884
EXPORT_SYMBOL(crc32_optimizations);

0 commit comments

Comments
 (0)