Skip to content

Commit 2374bf2

Browse files
author
Eric Biggers
committed
lib/crc: s390: Migrate optimized CRC code into lib/crc/
Move the s390-optimized CRC code from arch/s390/lib/crc* into its new location in lib/crc/s390/, and wire it up in the new way. This new way of organizing the CRC code eliminates the need to artificially split the code for each CRC variant into separate arch and generic modules, enabling better inlining and dead code elimination. For more details, see "lib/crc: Prepare for arch-optimized code in subdirs of lib/crc/". Reviewed-by: "Martin K. Petersen" <martin.petersen@oracle.com> Acked-by: Ingo Molnar <mingo@kernel.org> Acked-by: "Jason A. Donenfeld" <Jason@zx2c4.com> Link: https://lore.kernel.org/r/20250607200454.73587-10-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org>
1 parent b594381 commit 2374bf2

8 files changed

Lines changed: 5 additions & 17 deletions

File tree

arch/s390/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ config S390
7575
select ARCH_ENABLE_MEMORY_HOTREMOVE
7676
select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
7777
select ARCH_HAS_CPU_FINALIZE_INIT
78-
select ARCH_HAS_CRC32
7978
select ARCH_HAS_CURRENT_STACK_POINTER
8079
select ARCH_HAS_DEBUG_VIRTUAL
8180
select ARCH_HAS_DEBUG_VM_PGTABLE

arch/s390/lib/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,3 @@ obj-$(CONFIG_S390_MODULES_SANITY_TEST_HELPERS) += test_modules_helpers.o
2525
lib-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
2626

2727
obj-$(CONFIG_EXPOLINE_EXTERN) += expoline.o
28-
29-
obj-$(CONFIG_CRC32_ARCH) += crc32-s390.o
30-
crc32-s390-y := crc32.o crc32le-vx.o crc32be-vx.o

lib/crc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ config CRC32_ARCH
7474
default y if MIPS && CPU_MIPSR6
7575
default y if PPC64 && ALTIVEC
7676
default y if RISCV && RISCV_ISA_ZBC
77+
default y if S390
7778

7879
config CRC64
7980
tristate

lib/crc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ crc32-$(CONFIG_ARM) += arm/crc32-core.o
2727
crc32-$(CONFIG_ARM64) += arm64/crc32-core.o
2828
crc32-$(CONFIG_PPC) += powerpc/crc32c-vpmsum_asm.o
2929
crc32-$(CONFIG_RISCV) += riscv/crc32_lsb.o riscv/crc32_msb.o
30+
crc32-$(CONFIG_S390) += s390/crc32le-vx.o s390/crc32be-vx.o
3031
endif
3132

3233
obj-$(CONFIG_CRC64) += crc64.o
Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@
55
* Copyright IBM Corp. 2015
66
* Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
77
*/
8-
#define KMSG_COMPONENT "crc32-vx"
9-
#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
108

11-
#include <linux/module.h>
129
#include <linux/cpufeature.h>
13-
#include <linux/crc32.h>
1410
#include <asm/fpu.h>
1511
#include "crc32-vx.h"
1612

@@ -27,7 +23,7 @@
2723
* operations of VECTOR LOAD MULTIPLE instructions.
2824
*/
2925
#define DEFINE_CRC32_VX(___fname, ___crc32_vx, ___crc32_sw) \
30-
u32 ___fname(u32 crc, const u8 *data, size_t datalen) \
26+
static inline u32 ___fname(u32 crc, const u8 *data, size_t datalen) \
3127
{ \
3228
unsigned long prealign, aligned, remaining; \
3329
DECLARE_KERNEL_FPU_ONSTACK16(vxstate); \
@@ -54,14 +50,13 @@
5450
crc = ___crc32_sw(crc, data + aligned, remaining); \
5551
\
5652
return crc; \
57-
} \
58-
EXPORT_SYMBOL(___fname);
53+
}
5954

6055
DEFINE_CRC32_VX(crc32_le_arch, crc32_le_vgfm_16, crc32_le_base)
6156
DEFINE_CRC32_VX(crc32_be_arch, crc32_be_vgfm_16, crc32_be_base)
6257
DEFINE_CRC32_VX(crc32c_arch, crc32c_le_vgfm_16, crc32c_base)
6358

64-
u32 crc32_optimizations(void)
59+
static inline u32 crc32_optimizations_arch(void)
6560
{
6661
if (cpu_has_vx()) {
6762
return CRC32_LE_OPTIMIZATION |
@@ -70,8 +65,3 @@ u32 crc32_optimizations(void)
7065
}
7166
return 0;
7267
}
73-
EXPORT_SYMBOL(crc32_optimizations);
74-
75-
MODULE_AUTHOR("Hendrik Brueckner <brueckner@linux.vnet.ibm.com>");
76-
MODULE_DESCRIPTION("CRC-32 algorithms using z/Architecture Vector Extension Facility");
77-
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)