]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
lib/crc: s390: Migrate optimized CRC code into lib/crc/
authorEric Biggers <ebiggers@kernel.org>
Sat, 7 Jun 2025 20:04:51 +0000 (13:04 -0700)
committerEric Biggers <ebiggers@kernel.org>
Mon, 30 Jun 2025 16:31:57 +0000 (09:31 -0700)
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>
arch/s390/Kconfig
arch/s390/lib/Makefile
lib/crc/Kconfig
lib/crc/Makefile
lib/crc/s390/crc32-vx.h [moved from arch/s390/lib/crc32-vx.h with 100% similarity]
lib/crc/s390/crc32.h [moved from arch/s390/lib/crc32.c with 81% similarity]
lib/crc/s390/crc32be-vx.c [moved from arch/s390/lib/crc32be-vx.c with 100% similarity]
lib/crc/s390/crc32le-vx.c [moved from arch/s390/lib/crc32le-vx.c with 100% similarity]

index 0c16dc443e2f65fc6bd71352e1cc8d7aa60a7c6a..22b90f6aa1a09d4355e07b259c205c3590737f18 100644 (file)
@@ -75,7 +75,6 @@ config S390
        select ARCH_ENABLE_MEMORY_HOTREMOVE
        select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
        select ARCH_HAS_CPU_FINALIZE_INIT
-       select ARCH_HAS_CRC32
        select ARCH_HAS_CURRENT_STACK_POINTER
        select ARCH_HAS_DEBUG_VIRTUAL
        select ARCH_HAS_DEBUG_VM_PGTABLE
index cd35cdbfa87134ab67ea0e0a9d490d4c95fe9b0e..7c8583d46eca1d50cd2d3bf76d04210c0ae24649 100644 (file)
@@ -25,6 +25,3 @@ obj-$(CONFIG_S390_MODULES_SANITY_TEST_HELPERS) += test_modules_helpers.o
 lib-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
 
 obj-$(CONFIG_EXPOLINE_EXTERN) += expoline.o
-
-obj-$(CONFIG_CRC32_ARCH) += crc32-s390.o
-crc32-s390-y := crc32.o crc32le-vx.o crc32be-vx.o
index b8894c451aca9d31631f691b5ea403b08cd0f40e..c8d540a6b04a0563e87097706597e17dc89f8aff 100644 (file)
@@ -74,6 +74,7 @@ config CRC32_ARCH
        default y if MIPS && CPU_MIPSR6
        default y if PPC64 && ALTIVEC
        default y if RISCV && RISCV_ISA_ZBC
+       default y if S390
 
 config CRC64
        tristate
index 190f889adf556e98daf332c3993204c94e0f0e47..bec58266251f8555c5461368659cf09031c9894b 100644 (file)
@@ -27,6 +27,7 @@ crc32-$(CONFIG_ARM) += arm/crc32-core.o
 crc32-$(CONFIG_ARM64) += arm64/crc32-core.o
 crc32-$(CONFIG_PPC) += powerpc/crc32c-vpmsum_asm.o
 crc32-$(CONFIG_RISCV) += riscv/crc32_lsb.o riscv/crc32_msb.o
+crc32-$(CONFIG_S390) += s390/crc32le-vx.o s390/crc32be-vx.o
 endif
 
 obj-$(CONFIG_CRC64) += crc64.o
similarity index 81%
rename from arch/s390/lib/crc32.c
rename to lib/crc/s390/crc32.h
index 3c4b344417c114220cb82a95077adc9bdd500338..59c8983d428bedee2ad7c904262242d258d55ed8 100644 (file)
@@ -5,12 +5,8 @@
  * Copyright IBM Corp. 2015
  * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
  */
-#define KMSG_COMPONENT "crc32-vx"
-#define pr_fmt(fmt)    KMSG_COMPONENT ": " fmt
 
-#include <linux/module.h>
 #include <linux/cpufeature.h>
-#include <linux/crc32.h>
 #include <asm/fpu.h>
 #include "crc32-vx.h"
 
@@ -27,7 +23,7 @@
  * operations of VECTOR LOAD MULTIPLE instructions.
  */
 #define DEFINE_CRC32_VX(___fname, ___crc32_vx, ___crc32_sw)                \
-       u32 ___fname(u32 crc, const u8 *data, size_t datalen)               \
+       static inline u32 ___fname(u32 crc, const u8 *data, size_t datalen) \
        {                                                                   \
                unsigned long prealign, aligned, remaining;                 \
                DECLARE_KERNEL_FPU_ONSTACK16(vxstate);                      \
                        crc = ___crc32_sw(crc, data + aligned, remaining);  \
                                                                            \
                return crc;                                                 \
-       }                                                                   \
-       EXPORT_SYMBOL(___fname);
+       }
 
 DEFINE_CRC32_VX(crc32_le_arch, crc32_le_vgfm_16, crc32_le_base)
 DEFINE_CRC32_VX(crc32_be_arch, crc32_be_vgfm_16, crc32_be_base)
 DEFINE_CRC32_VX(crc32c_arch, crc32c_le_vgfm_16, crc32c_base)
 
-u32 crc32_optimizations(void)
+static inline u32 crc32_optimizations_arch(void)
 {
        if (cpu_has_vx()) {
                return CRC32_LE_OPTIMIZATION |
@@ -70,8 +65,3 @@ u32 crc32_optimizations(void)
        }
        return 0;
 }
-EXPORT_SYMBOL(crc32_optimizations);
-
-MODULE_AUTHOR("Hendrik Brueckner <brueckner@linux.vnet.ibm.com>");
-MODULE_DESCRIPTION("CRC-32 algorithms using z/Architecture Vector Extension Facility");
-MODULE_LICENSE("GPL");