mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
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>
This commit is contained in:
parent
0bcfca5640
commit
530b304f00
8 changed files with 15 additions and 58 deletions
|
@ -8,8 +8,6 @@ config ARM
|
|||
select ARCH_HAS_CACHE_LINE_SIZE if OF
|
||||
select ARCH_HAS_CPU_CACHE_ALIASING
|
||||
select ARCH_HAS_CPU_FINALIZE_INIT if MMU
|
||||
select ARCH_HAS_CRC32 if KERNEL_MODE_NEON
|
||||
select ARCH_HAS_CRC_T10DIF if KERNEL_MODE_NEON
|
||||
select ARCH_HAS_CURRENT_STACK_POINTER
|
||||
select ARCH_HAS_DEBUG_VIRTUAL if MMU
|
||||
select ARCH_HAS_DMA_ALLOC if MMU
|
||||
|
|
|
@ -47,9 +47,3 @@ ifeq ($(CONFIG_KERNEL_MODE_NEON),y)
|
|||
endif
|
||||
|
||||
obj-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o
|
||||
|
||||
obj-$(CONFIG_CRC32_ARCH) += crc32-arm.o
|
||||
crc32-arm-y := crc32.o crc32-core.o
|
||||
|
||||
obj-$(CONFIG_CRC_T10DIF_ARCH) += crc-t10dif-arm.o
|
||||
crc-t10dif-arm-y := crc-t10dif.o crc-t10dif-core.o
|
||||
|
|
|
@ -50,6 +50,7 @@ config ARCH_HAS_CRC_T10DIF
|
|||
config CRC_T10DIF_ARCH
|
||||
bool
|
||||
depends on CRC_T10DIF && CRC_OPTIMIZATIONS
|
||||
default y if ARM && KERNEL_MODE_NEON
|
||||
|
||||
config CRC32
|
||||
tristate
|
||||
|
@ -64,6 +65,7 @@ config ARCH_HAS_CRC32
|
|||
config CRC32_ARCH
|
||||
bool
|
||||
depends on CRC32 && CRC_OPTIMIZATIONS
|
||||
default y if ARM && KERNEL_MODE_NEON
|
||||
|
||||
config CRC64
|
||||
tristate
|
||||
|
|
|
@ -13,12 +13,14 @@ obj-$(CONFIG_CRC_T10DIF) += crc-t10dif.o
|
|||
crc-t10dif-y := crc-t10dif-main.o
|
||||
ifeq ($(CONFIG_CRC_T10DIF_ARCH),y)
|
||||
CFLAGS_crc-t10dif-main.o += -I$(src)/$(SRCARCH)
|
||||
crc-t10dif-$(CONFIG_ARM) += arm/crc-t10dif-core.o
|
||||
endif
|
||||
|
||||
obj-$(CONFIG_CRC32) += crc32.o
|
||||
crc32-y := crc32-main.o
|
||||
ifeq ($(CONFIG_CRC32_ARCH),y)
|
||||
CFLAGS_crc32-main.o += -I$(src)/$(SRCARCH)
|
||||
crc32-$(CONFIG_ARM) += arm/crc32-core.o
|
||||
endif
|
||||
|
||||
obj-$(CONFIG_CRC64) += crc64.o
|
||||
|
|
|
@ -5,12 +5,6 @@
|
|||
* Copyright (C) 2016 Linaro Ltd <ard.biesheuvel@linaro.org>
|
||||
*/
|
||||
|
||||
#include <linux/crc-t10dif.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
#include <crypto/internal/simd.h>
|
||||
|
||||
#include <asm/neon.h>
|
||||
|
@ -25,7 +19,7 @@ asmlinkage u16 crc_t10dif_pmull64(u16 init_crc, const u8 *buf, size_t len);
|
|||
asmlinkage void crc_t10dif_pmull8(u16 init_crc, const u8 *buf, size_t len,
|
||||
u8 out[16]);
|
||||
|
||||
u16 crc_t10dif_arch(u16 crc, const u8 *data, size_t length)
|
||||
static inline u16 crc_t10dif_arch(u16 crc, const u8 *data, size_t length)
|
||||
{
|
||||
if (length >= CRC_T10DIF_PMULL_CHUNK_SIZE) {
|
||||
if (static_branch_likely(&have_pmull)) {
|
||||
|
@ -49,24 +43,13 @@ u16 crc_t10dif_arch(u16 crc, const u8 *data, size_t length)
|
|||
}
|
||||
return crc_t10dif_generic(crc, data, length);
|
||||
}
|
||||
EXPORT_SYMBOL(crc_t10dif_arch);
|
||||
|
||||
static int __init crc_t10dif_arm_init(void)
|
||||
#define crc_t10dif_mod_init_arch crc_t10dif_mod_init_arch
|
||||
static inline void crc_t10dif_mod_init_arch(void)
|
||||
{
|
||||
if (elf_hwcap & HWCAP_NEON) {
|
||||
static_branch_enable(&have_neon);
|
||||
if (elf_hwcap2 & HWCAP2_PMULL)
|
||||
static_branch_enable(&have_pmull);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
subsys_initcall(crc_t10dif_arm_init);
|
||||
|
||||
static void __exit crc_t10dif_arm_exit(void)
|
||||
{
|
||||
}
|
||||
module_exit(crc_t10dif_arm_exit);
|
||||
|
||||
MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
|
||||
MODULE_DESCRIPTION("Accelerated CRC-T10DIF using ARM NEON and Crypto Extensions");
|
||||
MODULE_LICENSE("GPL v2");
|
|
@ -6,11 +6,6 @@
|
|||
*/
|
||||
|
||||
#include <linux/cpufeature.h>
|
||||
#include <linux/crc32.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
#include <crypto/internal/simd.h>
|
||||
|
||||
|
@ -29,14 +24,14 @@ asmlinkage u32 crc32_armv8_le(u32 init_crc, const u8 buf[], u32 len);
|
|||
asmlinkage u32 crc32c_pmull_le(const u8 buf[], u32 len, u32 init_crc);
|
||||
asmlinkage u32 crc32c_armv8_le(u32 init_crc, const u8 buf[], u32 len);
|
||||
|
||||
static u32 crc32_le_scalar(u32 crc, const u8 *p, size_t len)
|
||||
static inline u32 crc32_le_scalar(u32 crc, const u8 *p, size_t len)
|
||||
{
|
||||
if (static_branch_likely(&have_crc32))
|
||||
return crc32_armv8_le(crc, p, len);
|
||||
return crc32_le_base(crc, p, len);
|
||||
}
|
||||
|
||||
u32 crc32_le_arch(u32 crc, const u8 *p, size_t len)
|
||||
static inline u32 crc32_le_arch(u32 crc, const u8 *p, size_t len)
|
||||
{
|
||||
if (len >= PMULL_MIN_LEN + 15 &&
|
||||
static_branch_likely(&have_pmull) && crypto_simd_usable()) {
|
||||
|
@ -57,16 +52,15 @@ u32 crc32_le_arch(u32 crc, const u8 *p, size_t len)
|
|||
}
|
||||
return crc32_le_scalar(crc, p, len);
|
||||
}
|
||||
EXPORT_SYMBOL(crc32_le_arch);
|
||||
|
||||
static u32 crc32c_scalar(u32 crc, const u8 *p, size_t len)
|
||||
static inline u32 crc32c_scalar(u32 crc, const u8 *p, size_t len)
|
||||
{
|
||||
if (static_branch_likely(&have_crc32))
|
||||
return crc32c_armv8_le(crc, p, len);
|
||||
return crc32c_base(crc, p, len);
|
||||
}
|
||||
|
||||
u32 crc32c_arch(u32 crc, const u8 *p, size_t len)
|
||||
static inline u32 crc32c_arch(u32 crc, const u8 *p, size_t len)
|
||||
{
|
||||
if (len >= PMULL_MIN_LEN + 15 &&
|
||||
static_branch_likely(&have_pmull) && crypto_simd_usable()) {
|
||||
|
@ -87,37 +81,21 @@ u32 crc32c_arch(u32 crc, const u8 *p, size_t len)
|
|||
}
|
||||
return crc32c_scalar(crc, p, len);
|
||||
}
|
||||
EXPORT_SYMBOL(crc32c_arch);
|
||||
|
||||
u32 crc32_be_arch(u32 crc, const u8 *p, size_t len)
|
||||
{
|
||||
return crc32_be_base(crc, p, len);
|
||||
}
|
||||
EXPORT_SYMBOL(crc32_be_arch);
|
||||
#define crc32_be_arch crc32_be_base /* not implemented on this arch */
|
||||
|
||||
static int __init crc32_arm_init(void)
|
||||
#define crc32_mod_init_arch crc32_mod_init_arch
|
||||
static inline void crc32_mod_init_arch(void)
|
||||
{
|
||||
if (elf_hwcap2 & HWCAP2_CRC32)
|
||||
static_branch_enable(&have_crc32);
|
||||
if (elf_hwcap2 & HWCAP2_PMULL)
|
||||
static_branch_enable(&have_pmull);
|
||||
return 0;
|
||||
}
|
||||
subsys_initcall(crc32_arm_init);
|
||||
|
||||
static void __exit crc32_arm_exit(void)
|
||||
{
|
||||
}
|
||||
module_exit(crc32_arm_exit);
|
||||
|
||||
u32 crc32_optimizations(void)
|
||||
static inline u32 crc32_optimizations_arch(void)
|
||||
{
|
||||
if (elf_hwcap2 & (HWCAP2_CRC32 | HWCAP2_PMULL))
|
||||
return CRC32_LE_OPTIMIZATION | CRC32C_OPTIMIZATION;
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(crc32_optimizations);
|
||||
|
||||
MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
|
||||
MODULE_DESCRIPTION("Accelerated CRC32(C) using ARM CRC, NEON and Crypto Extensions");
|
||||
MODULE_LICENSE("GPL v2");
|
Loading…
Add table
Reference in a new issue