[PW_SID:1083850] arch/riscv: Add bitrev.h file to support rev8 and brev8#1801
[PW_SID:1083850] arch/riscv: Add bitrev.h file to support rev8 and brev8#1801linux-riscv-bot wants to merge 4 commits into
Conversation
Currently, the bit reversal lookup table is controlled by !HAVE_ARCH_BITREVERSE. This makes it difficult for architectures to provide a hardware-accelerated implementation while still falling back to the generic table for specific configurations. Introduce CONFIG_GENERIC_BITREVERSE to explicitly manage the generic lookup table implementation. By using 'def_bool !HAVE_ARCH_BITREVERSE' with a dependency on 'BITREVERSE', we ensure that: 1. The table is only compiled when needed. 2. The .config is not polluted with useless options when BITREVERSE is disabled. 3. Avoids bloating the .data section for architectures that have full hardware bit-reverse support and don't need the table. Update lib/bitrev.c to use CONFIG_GENERIC_BITREVERSE instead of checking the absence of HAVE_ARCH_BITREVERSE. This provides a cleaner interface for architectures like RISC-V that may want to selectively use the generic implementation as a fallback. Suggested-by: David Laight <David.Laight@ACULAB.COM> Suggested-by: Yury Norov <ynorov@nvidia.com> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Define generic __bitrev8/16/32 using the implementation in <linux/bitrev.h>, so they can be reused in <asm/bitrev.h>, such as RISCV. Reviewed-by: Yury Norov <ynorov@nvidia.com> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The RISC-V Bit-manipulation Extension for Cryptography (Zbkb) provides the 'brev8' instruction, which reverses the bits within each byte. Combined with the 'rev8' instruction (from Zbb or Zbkb), which reverses the byte order of a register, we can efficiently implement 16-bit, 32-bit, and (on RV64) 64-bit bit reversal. This is significantly faster than the default software table-lookup implementation in lib/bitrev.c, as it replaces memory accesses and multiple arithmetic operations with just two or three hardware instructions. Select HAVE_ARCH_BITREVERSE as well as GENERIC_BITREVERSE, and provide <asm/bitrev.h> to utilize these instructions when the Zbkb extension is available at runtime via the alternatives mechanism. Link: https://docs.riscv.org/reference/isa/unpriv/b-st-ext.html Suggested-by: David Laight <david.laight.linux@gmail.com> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig" |
|
Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig" |
|
Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig" |
|
Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig" |
|
Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig" |
|
Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig" |
|
Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig" |
|
Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig" |
|
Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig" |
|
Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig" |
|
Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig" |
|
Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig" |
|
Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse" |
|
Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse" |
|
Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse" |
|
Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse" |
|
Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse" |
|
Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse" |
|
Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse" |
|
Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse" |
|
Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse" |
|
Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse" |
|
Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse" |
|
Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse" |
|
Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8" |
|
Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8" |
|
Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8" |
|
Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8" |
|
Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8" |
|
Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8" |
|
Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8" |
|
Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8" |
|
Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8" |
|
Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8" |
|
Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8" |
|
Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8" |
506e7f6 to
01805bc
Compare
PR for series 1083850 applied to workflow__riscv__fixes
Name: arch/riscv: Add bitrev.h file to support rev8 and brev8
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1083850
Version: 5