Merge tag 'linux-watchdog-4.20-rc1' of git://www.linux-watchdog.org/linux-watchdog
[sfrench/cifs-2.6.git] / arch / arm64 / lib / crc32.S
1 /*
2  * Accelerated CRC32(C) using AArch64 CRC instructions
3  *
4  * Copyright (C) 2016 - 2018 Linaro Ltd <ard.biesheuvel@linaro.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10
11 #include <linux/linkage.h>
12 #include <asm/alternative.h>
13 #include <asm/assembler.h>
14
15         .cpu            generic+crc
16
17         .macro          __crc32, c
18 0:      subs            x2, x2, #16
19         b.mi            8f
20         ldp             x3, x4, [x1], #16
21 CPU_BE( rev             x3, x3          )
22 CPU_BE( rev             x4, x4          )
23         crc32\c\()x     w0, w0, x3
24         crc32\c\()x     w0, w0, x4
25         b.ne            0b
26         ret
27
28 8:      tbz             x2, #3, 4f
29         ldr             x3, [x1], #8
30 CPU_BE( rev             x3, x3          )
31         crc32\c\()x     w0, w0, x3
32 4:      tbz             x2, #2, 2f
33         ldr             w3, [x1], #4
34 CPU_BE( rev             w3, w3          )
35         crc32\c\()w     w0, w0, w3
36 2:      tbz             x2, #1, 1f
37         ldrh            w3, [x1], #2
38 CPU_BE( rev16           w3, w3          )
39         crc32\c\()h     w0, w0, w3
40 1:      tbz             x2, #0, 0f
41         ldrb            w3, [x1]
42         crc32\c\()b     w0, w0, w3
43 0:      ret
44         .endm
45
46         .align          5
47 ENTRY(crc32_le)
48 alternative_if_not ARM64_HAS_CRC32
49         b               crc32_le_base
50 alternative_else_nop_endif
51         __crc32
52 ENDPROC(crc32_le)
53
54         .align          5
55 ENTRY(__crc32c_le)
56 alternative_if_not ARM64_HAS_CRC32
57         b               __crc32c_le_base
58 alternative_else_nop_endif
59         __crc32         c
60 ENDPROC(__crc32c_le)