Skip to content

[PW_SID:1090622] [v2,1/5] arch: select HAVE_ARCH_BITREVERSE conditionally on BITREVERSE#1875

Closed
linux-riscv-bot wants to merge 6 commits into
workflow__riscv__fixesfrom
pw1090622
Closed

[PW_SID:1090622] [v2,1/5] arch: select HAVE_ARCH_BITREVERSE conditionally on BITREVERSE#1875
linux-riscv-bot wants to merge 6 commits into
workflow__riscv__fixesfrom
pw1090622

Conversation

@linux-riscv-bot
Copy link
Copy Markdown

PR for series 1090622 applied to workflow__riscv__fixes

Name: [v2,1/5] arch: select HAVE_ARCH_BITREVERSE conditionally on BITREVERSE
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1090622
Version: 2

Linux RISC-V bot and others added 6 commits May 2, 2026 08:13
Architectures may have bit reversal instructions, but if the API not
needed, the corresponding option should not be selected because it may
lead to generating the unneeded code.

Signed-off-by: Yury Norov <ynorov@nvidia.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The generic bit reversal implementation is controlled by
!HAVE_ARCH_BITREVERSE. This makes it difficult for architectures to
provide a hardware-accelerated implementation while being able to
fall back to the generic version if needed.

This patch adds GENERIC_BITREVERSE, so bitreverse API is controlled by
BITREVERSE, GENERIC_BITREVERSE and HAVE_ARCH_BITREVERSE options. The
relationship between them is described as follows:

 - BITREVERSE is selected by user code; it's required to generate the API;
 - Architectures may select HAVE_ARCH_BITREVERSE and provide an arch
   implementation in arch/$(ARCH)/include/asm/bitrev.h.
 - if HAVE_ARCH_BITREVERSE isn't set, BITREVERSE selects GENERIC_BITREVERSE;
 - if GENERIC_BITREVERSE is set and HAVE_ARCH_BITREVERSE is not, the kernel
   provides generic implementation only, and wires bitrevXX() to it.
 - if HAVE_ARCH_BITREVERSE is set and GENERIC_BITREVERSE is not, the arch
   code provides __arch_bitrevXX(), and it is wired to bitrevXX();
 - if both GENERIC_BITREVERSE and HAVE_ARCH_BITREVERSE are selected, the kernel
   generates generic___bitrev(), but wires bitrev() to the __arch_bitrev().

The last option allows architectures to use generic___bitrev() as a
fallback option.

Drivers and core code should never select GENERIC_BITREVERSE or
HAVE_ARCH_BITREVERSE explicitly.

Architectures that require generic bitreverse API as a fallback should
explicitly enable GENERIC_BITREVERSE together with HAVE_ARCH_BITREVERSE.

Signed-off-by: Yury Norov <ynorov@nvidia.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: Yury Norov <ynorov@nvidia.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.

[Yury: select the options conditionally on BITREVERSE]

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: Yury Norov <ynorov@nvidia.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Arch bitrev API is covered in MAINTAINERS under the BITOPS entry,
while generic bitrev is unmaintained. Move it under BITOPS too.

Signed-off-by: Yury Norov <ynorov@nvidia.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,1/5] arch: select HAVE_ARCH_BITREVERSE conditionally on BITREVERSE"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 143.57 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,1/5] arch: select HAVE_ARCH_BITREVERSE conditionally on BITREVERSE"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1044.85 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,1/5] arch: select HAVE_ARCH_BITREVERSE conditionally on BITREVERSE"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1420.87 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,1/5] arch: select HAVE_ARCH_BITREVERSE conditionally on BITREVERSE"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 25.91 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,1/5] arch: select HAVE_ARCH_BITREVERSE conditionally on BITREVERSE"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 27.54 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,1/5] arch: select HAVE_ARCH_BITREVERSE conditionally on BITREVERSE"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.59 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,1/5] arch: select HAVE_ARCH_BITREVERSE conditionally on BITREVERSE"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 88.49 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,1/5] arch: select HAVE_ARCH_BITREVERSE conditionally on BITREVERSE"
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 1: "[v2,1/5] arch: select HAVE_ARCH_BITREVERSE conditionally on BITREVERSE"
kdoc
Desc: Detects for kdoc errors
Duration: 1.30 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,1/5] arch: select HAVE_ARCH_BITREVERSE conditionally on BITREVERSE"
module-param
Desc: Detect module_param changes
Duration: 0.29 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,1/5] arch: select HAVE_ARCH_BITREVERSE conditionally on BITREVERSE"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,1/5] arch: select HAVE_ARCH_BITREVERSE conditionally on BITREVERSE"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.32 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v2,2/5] lib/bitrev: Introduce GENERIC_BITREVERSE"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 142.00 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v2,2/5] lib/bitrev: Introduce GENERIC_BITREVERSE"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1160.46 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v2,2/5] lib/bitrev: Introduce GENERIC_BITREVERSE"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1717.96 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v2,2/5] lib/bitrev: Introduce GENERIC_BITREVERSE"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 26.43 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v2,2/5] lib/bitrev: Introduce GENERIC_BITREVERSE"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 27.62 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v2,2/5] lib/bitrev: Introduce GENERIC_BITREVERSE"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.14 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v2,2/5] lib/bitrev: Introduce GENERIC_BITREVERSE"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 87.40 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v2,2/5] lib/bitrev: Introduce GENERIC_BITREVERSE"
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: "[v2,2/5] lib/bitrev: Introduce GENERIC_BITREVERSE"
kdoc
Desc: Detects for kdoc errors
Duration: 0.91 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v2,2/5] lib/bitrev: Introduce GENERIC_BITREVERSE"
module-param
Desc: Detect module_param changes
Duration: 0.27 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v2,2/5] lib/bitrev: Introduce GENERIC_BITREVERSE"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 3.12 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v2,2/5] lib/bitrev: Introduce GENERIC_BITREVERSE"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.46 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v2,3/5] bitops: Define generic___bitrev8/16/32 for reuse"
module-param
Desc: Detect module_param changes
Duration: 5.58 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v2,3/5] bitops: Define generic___bitrev8/16/32 for reuse"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.30 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 3: "[v2,3/5] bitops: Define generic___bitrev8/16/32 for reuse"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.32 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

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

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[v2,4/5] 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: 1356.91 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[v2,4/5] 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: 2004.03 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[v2,4/5] 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: 26.34 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[v2,4/5] 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: 27.19 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

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

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

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

CHECK: Lines should not end with a '('
#101: 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 d988c6128ce0 ("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 4: "[v2,4/5] arch/riscv: Add bitrev.h file to support rev8 and brev8"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 86.64 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[v2,4/5] 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.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

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

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 4: "[v2,4/5] 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 4: "[v2,4/5] 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 4: "[v2,4/5] arch/riscv: Add bitrev.h file to support rev8 and brev8"
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 5: "[v2,5/5] MAINTAINERS: BITOPS: include bitrev.[ch]"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 140.57 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v2,5/5] MAINTAINERS: BITOPS: include bitrev.[ch]"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1019.99 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v2,5/5] MAINTAINERS: BITOPS: include bitrev.[ch]"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1387.66 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v2,5/5] MAINTAINERS: BITOPS: include bitrev.[ch]"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 30.79 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v2,5/5] MAINTAINERS: BITOPS: include bitrev.[ch]"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 26.95 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v2,5/5] MAINTAINERS: BITOPS: include bitrev.[ch]"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.80 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v2,5/5] MAINTAINERS: BITOPS: include bitrev.[ch]"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 88.11 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v2,5/5] MAINTAINERS: BITOPS: include bitrev.[ch]"
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 5: "[v2,5/5] MAINTAINERS: BITOPS: include bitrev.[ch]"
kdoc
Desc: Detects for kdoc errors
Duration: 0.95 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v2,5/5] MAINTAINERS: BITOPS: include bitrev.[ch]"
module-param
Desc: Detect module_param changes
Duration: 0.34 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v2,5/5] MAINTAINERS: BITOPS: include bitrev.[ch]"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 5: "[v2,5/5] MAINTAINERS: BITOPS: include bitrev.[ch]"
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 2c3b264 to 2d4fcdd Compare May 10, 2026 02:08
@linux-riscv-bot linux-riscv-bot deleted the pw1090622 branch May 14, 2026 00:01
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