Skip to content

[PW_SID:1083850] arch/riscv: Add bitrev.h file to support rev8 and brev8#1801

Closed
linux-riscv-bot wants to merge 4 commits into
workflow__riscv__fixesfrom
pw1083850
Closed

[PW_SID:1083850] arch/riscv: Add bitrev.h file to support rev8 and brev8#1801
linux-riscv-bot wants to merge 4 commits into
workflow__riscv__fixesfrom
pw1083850

Conversation

@linux-riscv-bot
Copy link
Copy Markdown

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

Linux RISC-V bot and others added 4 commits April 5, 2026 01:35
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>
@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 136.27 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1127.09 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1622.49 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 29.52 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 26.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.02 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 83.76 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig"
kdoc
Desc: Detects for kdoc errors
Duration: 1.17 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig"
module-param
Desc: Detect module_param changes
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v5,1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.31 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 135.58 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1313.44 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1900.46 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 25.05 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 26.17 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 2.14 seconds
Result: WARNING
Output:

WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#20: 
new file mode 100644

total: 0 errors, 1 warnings, 0 checks, 51 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit 2096817699d9 ("bitops: Define generic __bitrev8/16/32 for reuse") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 1 warnings, 0 checks, 51 lines checked
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?


@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 84.40 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse"
kdoc
Desc: Detects for kdoc errors
Duration: 1.30 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse"
module-param
Desc: Detect module_param changes
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v5,2/3] bitops: Define generic __bitrev8/16/32 for reuse"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.31 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 136.72 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1337.72 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1921.01 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 25.11 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 26.27 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 2.22 seconds
Result: WARNING
Output:

WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#53: 
new file mode 100644

CHECK: Lines should not end with a '('
#74: FILE: arch/riscv/include/asm/bitrev.h:17:
+	asm volatile(

CHECK: Lines should not end with a '('
#98: FILE: arch/riscv/include/asm/bitrev.h:41:
+	asm volatile(

total: 0 errors, 1 warnings, 2 checks, 65 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit 90b9c722e65a ("arch/riscv: Add bitrev.h file to support rev8 and brev8") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 1 warnings, 2 checks, 65 lines checked
CHECK: Lines should not end with a '('
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?


@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 84.93 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8"
kdoc
Desc: Detects for kdoc errors
Duration: 0.97 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8"
module-param
Desc: Detect module_param changes
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v5,3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.32 seconds
Result: PASS

@linux-riscv-bot linux-riscv-bot force-pushed the workflow__riscv__fixes branch from 506e7f6 to 01805bc Compare April 24, 2026 14:53
@linux-riscv-bot linux-riscv-bot deleted the pw1083850 branch April 29, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants