Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+5 -17
-1
arch/s390/Kconfig
··· 75 75 select ARCH_ENABLE_MEMORY_HOTREMOVE 76 76 select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2 77 77 select ARCH_HAS_CPU_FINALIZE_INIT 78 - select ARCH_HAS_CRC32 79 78 select ARCH_HAS_CURRENT_STACK_POINTER 80 79 select ARCH_HAS_DEBUG_VIRTUAL 81 80 select ARCH_HAS_DEBUG_VM_PGTABLE
-3
arch/s390/lib/Makefile
··· 25 25 lib-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o 26 26 27 27 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
arch/s390/lib/crc32-vx.h lib/crc/s390/crc32-vx.h
+3 -13
arch/s390/lib/crc32.c lib/crc/s390/crc32.h
··· 5 5 * Copyright IBM Corp. 2015 6 6 * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com> 7 7 */ 8 - #define KMSG_COMPONENT "crc32-vx" 9 - #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 10 8 11 - #include <linux/module.h> 12 9 #include <linux/cpufeature.h> 13 - #include <linux/crc32.h> 14 10 #include <asm/fpu.h> 15 11 #include "crc32-vx.h" 16 12 ··· 23 27 * operations of VECTOR LOAD MULTIPLE instructions. 24 28 */ 25 29 #define DEFINE_CRC32_VX(___fname, ___crc32_vx, ___crc32_sw) \ 26 - u32 ___fname(u32 crc, const u8 *data, size_t datalen) \ 30 + static inline u32 ___fname(u32 crc, const u8 *data, size_t datalen) \ 27 31 { \ 28 32 unsigned long prealign, aligned, remaining; \ 29 33 DECLARE_KERNEL_FPU_ONSTACK16(vxstate); \ ··· 50 54 crc = ___crc32_sw(crc, data + aligned, remaining); \ 51 55 \ 52 56 return crc; \ 53 - } \ 54 - EXPORT_SYMBOL(___fname); 57 + } 55 58 56 59 DEFINE_CRC32_VX(crc32_le_arch, crc32_le_vgfm_16, crc32_le_base) 57 60 DEFINE_CRC32_VX(crc32_be_arch, crc32_be_vgfm_16, crc32_be_base) 58 61 DEFINE_CRC32_VX(crc32c_arch, crc32c_le_vgfm_16, crc32c_base) 59 62 60 - u32 crc32_optimizations(void) 63 + static inline u32 crc32_optimizations_arch(void) 61 64 { 62 65 if (cpu_has_vx()) { 63 66 return CRC32_LE_OPTIMIZATION | ··· 65 70 } 66 71 return 0; 67 72 } 68 - EXPORT_SYMBOL(crc32_optimizations); 69 - 70 - MODULE_AUTHOR("Hendrik Brueckner <brueckner@linux.vnet.ibm.com>"); 71 - MODULE_DESCRIPTION("CRC-32 algorithms using z/Architecture Vector Extension Facility"); 72 - MODULE_LICENSE("GPL");
arch/s390/lib/crc32be-vx.c lib/crc/s390/crc32be-vx.c
arch/s390/lib/crc32le-vx.c lib/crc/s390/crc32le-vx.c
+1
lib/crc/Kconfig
··· 74 74 default y if MIPS && CPU_MIPSR6 75 75 default y if PPC64 && ALTIVEC 76 76 default y if RISCV && RISCV_ISA_ZBC 77 + default y if S390 77 78 78 79 config CRC64 79 80 tristate
+1
lib/crc/Makefile
··· 27 27 crc32-$(CONFIG_ARM64) += arm64/crc32-core.o 28 28 crc32-$(CONFIG_PPC) += powerpc/crc32c-vpmsum_asm.o 29 29 crc32-$(CONFIG_RISCV) += riscv/crc32_lsb.o riscv/crc32_msb.o 30 + crc32-$(CONFIG_S390) += s390/crc32le-vx.o s390/crc32be-vx.o 30 31 endif 31 32 32 33 obj-$(CONFIG_CRC64) += crc64.o