-
Notifications
You must be signed in to change notification settings - Fork 646
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
arm64 kernels: add accelerated crc32 routines
Incorporate changes from Linux 4.20 to accelerate the kernel's crc32_le and __crc32c_le helpers. Incorporates: 9784d82db ("make core crc32() routines weak so they can be overridden") 7481cddf2 ("arm64/lib: add accelerated crc32 routines") ff98e20ef ("lib/crc32.c: mark c4c32_le_base/__crc32_le_base alias as __pure") But omits the runtime selection which uses machinery that differs significantly in Linux 4.1. We assume CRC is always available.
- Loading branch information
Showing
12 changed files
with
210 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
release/src-rt-5.02axhnd/kernel/linux-4.1/arch/arm64/lib/crc32.S
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Accelerated CRC32(C) using AArch64 CRC instructions | ||
* | ||
* Copyright (C) 2016 - 2018 Linaro Ltd <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
*/ | ||
|
||
#include <linux/linkage.h> | ||
//#include <asm/alternative.h> | ||
#include <asm/assembler.h> | ||
|
||
.arch armv8-a+crc | ||
|
||
.macro __crc32, c | ||
0: subs x2, x2, #16 | ||
b.mi 8f | ||
ldp x3, x4, [x1], #16 | ||
CPU_BE( rev x3, x3 ) | ||
CPU_BE( rev x4, x4 ) | ||
crc32\c\()x w0, w0, x3 | ||
crc32\c\()x w0, w0, x4 | ||
b.ne 0b | ||
ret | ||
|
||
8: tbz x2, #3, 4f | ||
ldr x3, [x1], #8 | ||
CPU_BE( rev x3, x3 ) | ||
crc32\c\()x w0, w0, x3 | ||
4: tbz x2, #2, 2f | ||
ldr w3, [x1], #4 | ||
CPU_BE( rev w3, w3 ) | ||
crc32\c\()w w0, w0, w3 | ||
2: tbz x2, #1, 1f | ||
ldrh w3, [x1], #2 | ||
CPU_BE( rev16 w3, w3 ) | ||
crc32\c\()h w0, w0, w3 | ||
1: tbz x2, #0, 0f | ||
ldrb w3, [x1] | ||
crc32\c\()b w0, w0, w3 | ||
0: ret | ||
.endm | ||
|
||
.align 5 | ||
ENTRY(crc32_le) | ||
//alternative_if_not ARM64_HAS_CRC32 | ||
// b crc32_le_base | ||
//alternative_else_nop_endif | ||
__crc32 | ||
ENDPROC(crc32_le) | ||
|
||
.align 5 | ||
ENTRY(__crc32c_le) | ||
//alternative_if_not ARM64_HAS_CRC32 | ||
// b __crc32c_le_base | ||
//alternative_else_nop_endif | ||
__crc32 c | ||
ENDPROC(__crc32c_le) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
release/src-rt-5.02hnd/kernel/linux-4.1/arch/arm64/lib/crc32.S
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Accelerated CRC32(C) using AArch64 CRC instructions | ||
* | ||
* Copyright (C) 2016 - 2018 Linaro Ltd <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
*/ | ||
|
||
#include <linux/linkage.h> | ||
//#include <asm/alternative.h> | ||
#include <asm/assembler.h> | ||
|
||
.arch armv8-a+crc | ||
|
||
.macro __crc32, c | ||
0: subs x2, x2, #16 | ||
b.mi 8f | ||
ldp x3, x4, [x1], #16 | ||
CPU_BE( rev x3, x3 ) | ||
CPU_BE( rev x4, x4 ) | ||
crc32\c\()x w0, w0, x3 | ||
crc32\c\()x w0, w0, x4 | ||
b.ne 0b | ||
ret | ||
|
||
8: tbz x2, #3, 4f | ||
ldr x3, [x1], #8 | ||
CPU_BE( rev x3, x3 ) | ||
crc32\c\()x w0, w0, x3 | ||
4: tbz x2, #2, 2f | ||
ldr w3, [x1], #4 | ||
CPU_BE( rev w3, w3 ) | ||
crc32\c\()w w0, w0, w3 | ||
2: tbz x2, #1, 1f | ||
ldrh w3, [x1], #2 | ||
CPU_BE( rev16 w3, w3 ) | ||
crc32\c\()h w0, w0, w3 | ||
1: tbz x2, #0, 0f | ||
ldrb w3, [x1] | ||
crc32\c\()b w0, w0, w3 | ||
0: ret | ||
.endm | ||
|
||
.align 5 | ||
ENTRY(crc32_le) | ||
//alternative_if_not ARM64_HAS_CRC32 | ||
// b crc32_le_base | ||
//alternative_else_nop_endif | ||
__crc32 | ||
ENDPROC(crc32_le) | ||
|
||
.align 5 | ||
ENTRY(__crc32c_le) | ||
//alternative_if_not ARM64_HAS_CRC32 | ||
// b __crc32c_le_base | ||
//alternative_else_nop_endif | ||
__crc32 c | ||
ENDPROC(__crc32c_le) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
release/src-rt-5.02p1axhnd.675x/kernel/linux-4.1/arch/arm64/lib/crc32.S
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Accelerated CRC32(C) using AArch64 CRC instructions | ||
* | ||
* Copyright (C) 2016 - 2018 Linaro Ltd <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
*/ | ||
|
||
#include <linux/linkage.h> | ||
//#include <asm/alternative.h> | ||
#include <asm/assembler.h> | ||
|
||
.arch armv8-a+crc | ||
|
||
.macro __crc32, c | ||
0: subs x2, x2, #16 | ||
b.mi 8f | ||
ldp x3, x4, [x1], #16 | ||
CPU_BE( rev x3, x3 ) | ||
CPU_BE( rev x4, x4 ) | ||
crc32\c\()x w0, w0, x3 | ||
crc32\c\()x w0, w0, x4 | ||
b.ne 0b | ||
ret | ||
|
||
8: tbz x2, #3, 4f | ||
ldr x3, [x1], #8 | ||
CPU_BE( rev x3, x3 ) | ||
crc32\c\()x w0, w0, x3 | ||
4: tbz x2, #2, 2f | ||
ldr w3, [x1], #4 | ||
CPU_BE( rev w3, w3 ) | ||
crc32\c\()w w0, w0, w3 | ||
2: tbz x2, #1, 1f | ||
ldrh w3, [x1], #2 | ||
CPU_BE( rev16 w3, w3 ) | ||
crc32\c\()h w0, w0, w3 | ||
1: tbz x2, #0, 0f | ||
ldrb w3, [x1] | ||
crc32\c\()b w0, w0, w3 | ||
0: ret | ||
.endm | ||
|
||
.align 5 | ||
ENTRY(crc32_le) | ||
//alternative_if_not ARM64_HAS_CRC32 | ||
// b crc32_le_base | ||
//alternative_else_nop_endif | ||
__crc32 | ||
ENDPROC(crc32_le) | ||
|
||
.align 5 | ||
ENTRY(__crc32c_le) | ||
//alternative_if_not ARM64_HAS_CRC32 | ||
// b __crc32c_le_base | ||
//alternative_else_nop_endif | ||
__crc32 c | ||
ENDPROC(__crc32c_le) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters