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

Configure Feed

Select the types of activity you want to include in your feed.

lib/crc: arm: Migrate optimized CRC code into lib/crc/

Move the arm-optimized CRC code from arch/arm/lib/crc* into its new
location in lib/crc/arm/, 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-4-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>

+15 -58
-2
arch/arm/Kconfig
··· 8 8 select ARCH_HAS_CACHE_LINE_SIZE if OF 9 9 select ARCH_HAS_CPU_CACHE_ALIASING 10 10 select ARCH_HAS_CPU_FINALIZE_INIT if MMU 11 - select ARCH_HAS_CRC32 if KERNEL_MODE_NEON 12 - select ARCH_HAS_CRC_T10DIF if KERNEL_MODE_NEON 13 11 select ARCH_HAS_CURRENT_STACK_POINTER 14 12 select ARCH_HAS_DEBUG_VIRTUAL if MMU 15 13 select ARCH_HAS_DMA_ALLOC if MMU
-6
arch/arm/lib/Makefile
··· 47 47 endif 48 48 49 49 obj-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o 50 - 51 - obj-$(CONFIG_CRC32_ARCH) += crc32-arm.o 52 - crc32-arm-y := crc32.o crc32-core.o 53 - 54 - obj-$(CONFIG_CRC_T10DIF_ARCH) += crc-t10dif-arm.o 55 - crc-t10dif-arm-y := crc-t10dif.o crc-t10dif-core.o
arch/arm/lib/crc-t10dif-core.S lib/crc/arm/crc-t10dif-core.S
+3 -20
arch/arm/lib/crc-t10dif.c lib/crc/arm/crc-t10dif.h
··· 5 5 * Copyright (C) 2016 Linaro Ltd <ard.biesheuvel@linaro.org> 6 6 */ 7 7 8 - #include <linux/crc-t10dif.h> 9 - #include <linux/init.h> 10 - #include <linux/kernel.h> 11 - #include <linux/module.h> 12 - #include <linux/string.h> 13 - 14 8 #include <crypto/internal/simd.h> 15 9 16 10 #include <asm/neon.h> ··· 19 25 asmlinkage void crc_t10dif_pmull8(u16 init_crc, const u8 *buf, size_t len, 20 26 u8 out[16]); 21 27 22 - u16 crc_t10dif_arch(u16 crc, const u8 *data, size_t length) 28 + static inline u16 crc_t10dif_arch(u16 crc, const u8 *data, size_t length) 23 29 { 24 30 if (length >= CRC_T10DIF_PMULL_CHUNK_SIZE) { 25 31 if (static_branch_likely(&have_pmull)) { ··· 43 49 } 44 50 return crc_t10dif_generic(crc, data, length); 45 51 } 46 - EXPORT_SYMBOL(crc_t10dif_arch); 47 52 48 - static int __init crc_t10dif_arm_init(void) 53 + #define crc_t10dif_mod_init_arch crc_t10dif_mod_init_arch 54 + static inline void crc_t10dif_mod_init_arch(void) 49 55 { 50 56 if (elf_hwcap & HWCAP_NEON) { 51 57 static_branch_enable(&have_neon); 52 58 if (elf_hwcap2 & HWCAP2_PMULL) 53 59 static_branch_enable(&have_pmull); 54 60 } 55 - return 0; 56 61 } 57 - subsys_initcall(crc_t10dif_arm_init); 58 - 59 - static void __exit crc_t10dif_arm_exit(void) 60 - { 61 - } 62 - module_exit(crc_t10dif_arm_exit); 63 - 64 - MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>"); 65 - MODULE_DESCRIPTION("Accelerated CRC-T10DIF using ARM NEON and Crypto Extensions"); 66 - MODULE_LICENSE("GPL v2");
arch/arm/lib/crc32-core.S lib/crc/arm/crc32-core.S
+8 -30
arch/arm/lib/crc32.c lib/crc/arm/crc32.h
··· 6 6 */ 7 7 8 8 #include <linux/cpufeature.h> 9 - #include <linux/crc32.h> 10 - #include <linux/init.h> 11 - #include <linux/kernel.h> 12 - #include <linux/module.h> 13 - #include <linux/string.h> 14 9 15 10 #include <crypto/internal/simd.h> 16 11 ··· 24 29 asmlinkage u32 crc32c_pmull_le(const u8 buf[], u32 len, u32 init_crc); 25 30 asmlinkage u32 crc32c_armv8_le(u32 init_crc, const u8 buf[], u32 len); 26 31 27 - static u32 crc32_le_scalar(u32 crc, const u8 *p, size_t len) 32 + static inline u32 crc32_le_scalar(u32 crc, const u8 *p, size_t len) 28 33 { 29 34 if (static_branch_likely(&have_crc32)) 30 35 return crc32_armv8_le(crc, p, len); 31 36 return crc32_le_base(crc, p, len); 32 37 } 33 38 34 - u32 crc32_le_arch(u32 crc, const u8 *p, size_t len) 39 + static inline u32 crc32_le_arch(u32 crc, const u8 *p, size_t len) 35 40 { 36 41 if (len >= PMULL_MIN_LEN + 15 && 37 42 static_branch_likely(&have_pmull) && crypto_simd_usable()) { ··· 52 57 } 53 58 return crc32_le_scalar(crc, p, len); 54 59 } 55 - EXPORT_SYMBOL(crc32_le_arch); 56 60 57 - static u32 crc32c_scalar(u32 crc, const u8 *p, size_t len) 61 + static inline u32 crc32c_scalar(u32 crc, const u8 *p, size_t len) 58 62 { 59 63 if (static_branch_likely(&have_crc32)) 60 64 return crc32c_armv8_le(crc, p, len); 61 65 return crc32c_base(crc, p, len); 62 66 } 63 67 64 - u32 crc32c_arch(u32 crc, const u8 *p, size_t len) 68 + static inline u32 crc32c_arch(u32 crc, const u8 *p, size_t len) 65 69 { 66 70 if (len >= PMULL_MIN_LEN + 15 && 67 71 static_branch_likely(&have_pmull) && crypto_simd_usable()) { ··· 81 87 } 82 88 return crc32c_scalar(crc, p, len); 83 89 } 84 - EXPORT_SYMBOL(crc32c_arch); 85 90 86 - u32 crc32_be_arch(u32 crc, const u8 *p, size_t len) 87 - { 88 - return crc32_be_base(crc, p, len); 89 - } 90 - EXPORT_SYMBOL(crc32_be_arch); 91 + #define crc32_be_arch crc32_be_base /* not implemented on this arch */ 91 92 92 - static int __init crc32_arm_init(void) 93 + #define crc32_mod_init_arch crc32_mod_init_arch 94 + static inline void crc32_mod_init_arch(void) 93 95 { 94 96 if (elf_hwcap2 & HWCAP2_CRC32) 95 97 static_branch_enable(&have_crc32); 96 98 if (elf_hwcap2 & HWCAP2_PMULL) 97 99 static_branch_enable(&have_pmull); 98 - return 0; 99 100 } 100 - subsys_initcall(crc32_arm_init); 101 101 102 - static void __exit crc32_arm_exit(void) 103 - { 104 - } 105 - module_exit(crc32_arm_exit); 106 - 107 - u32 crc32_optimizations(void) 102 + static inline u32 crc32_optimizations_arch(void) 108 103 { 109 104 if (elf_hwcap2 & (HWCAP2_CRC32 | HWCAP2_PMULL)) 110 105 return CRC32_LE_OPTIMIZATION | CRC32C_OPTIMIZATION; 111 106 return 0; 112 107 } 113 - EXPORT_SYMBOL(crc32_optimizations); 114 - 115 - MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>"); 116 - MODULE_DESCRIPTION("Accelerated CRC32(C) using ARM CRC, NEON and Crypto Extensions"); 117 - MODULE_LICENSE("GPL v2");
+2
lib/crc/Kconfig
··· 50 50 config CRC_T10DIF_ARCH 51 51 bool 52 52 depends on CRC_T10DIF && CRC_OPTIMIZATIONS 53 + default y if ARM && KERNEL_MODE_NEON 53 54 54 55 config CRC32 55 56 tristate ··· 65 64 config CRC32_ARCH 66 65 bool 67 66 depends on CRC32 && CRC_OPTIMIZATIONS 67 + default y if ARM && KERNEL_MODE_NEON 68 68 69 69 config CRC64 70 70 tristate
+2
lib/crc/Makefile
··· 13 13 crc-t10dif-y := crc-t10dif-main.o 14 14 ifeq ($(CONFIG_CRC_T10DIF_ARCH),y) 15 15 CFLAGS_crc-t10dif-main.o += -I$(src)/$(SRCARCH) 16 + crc-t10dif-$(CONFIG_ARM) += arm/crc-t10dif-core.o 16 17 endif 17 18 18 19 obj-$(CONFIG_CRC32) += crc32.o 19 20 crc32-y := crc32-main.o 20 21 ifeq ($(CONFIG_CRC32_ARCH),y) 21 22 CFLAGS_crc32-main.o += -I$(src)/$(SRCARCH) 23 + crc32-$(CONFIG_ARM) += arm/crc32-core.o 22 24 endif 23 25 24 26 obj-$(CONFIG_CRC64) += crc64.o