public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Jinjie Ruan <ruanjinjie@huawei.com>
Cc: pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu,
	alex@ghiti.fr, yury.norov@gmail.com, linux@rasmusvillemoes.dk,
	arnd@arndb.de, akpm@linux-foundation.org,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-arch@vger.kernel.org, david.laight.linux@gmail.com,
	cp0613@linux.alibaba.com
Subject: Re: [PATCH v5 2/3] bitops: Define generic __bitrev8/16/32 for reuse
Date: Wed, 29 Apr 2026 13:29:22 -0700	[thread overview]
Message-ID: <20260429202922.GA3575295@ax162> (raw)
In-Reply-To: <20260421130752.607500-3-ruanjinjie@huawei.com>

Hi Jinjie,

On Tue, Apr 21, 2026 at 09:07:51PM +0800, Jinjie Ruan wrote:
> 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>
> ---
>  include/asm-generic/bitops/__bitrev.h | 25 +++++++++++++++++++++++++
>  include/linux/bitrev.h                | 20 ++++----------------
>  2 files changed, 29 insertions(+), 16 deletions(-)
>  create mode 100644 include/asm-generic/bitops/__bitrev.h
> 
> diff --git a/include/asm-generic/bitops/__bitrev.h b/include/asm-generic/bitops/__bitrev.h
> new file mode 100644
> index 000000000000..f06af929678d
> --- /dev/null
> +++ b/include/asm-generic/bitops/__bitrev.h
> @@ -0,0 +1,25 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _ASM_GENERIC_BITOPS___BITREV_H_
> +#define _ASM_GENERIC_BITOPS___BITREV_H_
> +
> +#ifdef CONFIG_GENERIC_BITREVERSE

The dependencies of this symbol seem insufficient, as I can trigger a
build failure on next-20260429 like so:

  $ make -skj"$(nproc)" ARCH=s390 CROSS_COMPILE=s390-linux- mrproper tinyconfig fs/select.o
  In file included from include/linux/crc32.h:6,
                   from include/linux/etherdevice.h:23,
                   from include/linux/if_vlan.h:11,
                   from include/linux/filter.h:21,
                   from include/net/xdp.h:10,
                   from include/net/busy_poll.h:19,
                   from fs/select.c:33:
  include/linux/etherdevice.h: In function 'eth_hw_addr_crc':
  include/linux/bitrev.h:16:20: error: implicit declaration of function 'generic___bitrev32' [-Wimplicit-function-declaration]
     16 | #define __bitrev32 generic___bitrev32
        |                    ^~~~~~~~~~~~~~~~~~
  include/linux/bitrev.h:67:9: note: in expansion of macro '__bitrev32'
     67 |         __bitrev32(__x);                                \
        |         ^~~~~~~~~~
  include/linux/crc32.h:107:36: note: in expansion of macro 'bitrev32'
    107 | #define ether_crc(length, data)    bitrev32(crc32_le(~0, data, length))
        |                                    ^~~~~~~~
  include/linux/etherdevice.h:292:16: note: in expansion of macro 'ether_crc'
    292 |         return ether_crc(ETH_ALEN, ha->addr);
        |                ^~~~~~~~~
  make[5]: *** [scripts/Makefile.build:289: fs/select.o] Error 1
  ...

  $ scripts/config -s BITREVERSE
  undef

  $ rg BITREVERSE .config

> +#include <asm/types.h>
> +
> +extern u8 const byte_rev_table[256];
> +static __always_inline __attribute_const__ u8 generic___bitrev8(u8 byte)
> +{
> +	return byte_rev_table[byte];
> +}
> +
> +static __always_inline __attribute_const__ u16 generic___bitrev16(u16 x)
> +{
> +	return (generic___bitrev8(x & 0xff) << 8) | generic___bitrev8(x >> 8);
> +}
> +
> +static __always_inline __attribute_const__ u32 generic___bitrev32(u32 x)
> +{
> +	return (generic___bitrev16(x & 0xffff) << 16) | generic___bitrev16(x >> 16);
> +}
> +#endif /* CONFIG_GENERIC_BITREVERSE */
> +
> +#endif /* _ASM_GENERIC_BITOPS___BITREV_H_ */
> diff --git a/include/linux/bitrev.h b/include/linux/bitrev.h
> index d35b8ec1c485..11620a70e776 100644
> --- a/include/linux/bitrev.h
> +++ b/include/linux/bitrev.h
> @@ -12,22 +12,10 @@
>  #define __bitrev8 __arch_bitrev8
>  
>  #else
> -extern u8 const byte_rev_table[256];
> -static inline u8 __bitrev8(u8 byte)
> -{
> -	return byte_rev_table[byte];
> -}
> -
> -static inline u16 __bitrev16(u16 x)
> -{
> -	return (__bitrev8(x & 0xff) << 8) | __bitrev8(x >> 8);
> -}
> -
> -static inline u32 __bitrev32(u32 x)
> -{
> -	return (__bitrev16(x & 0xffff) << 16) | __bitrev16(x >> 16);
> -}
> -
> +#include <asm-generic/bitops/__bitrev.h>
> +#define __bitrev32 generic___bitrev32
> +#define __bitrev16 generic___bitrev16
> +#define __bitrev8 generic___bitrev8
>  #endif /* CONFIG_HAVE_ARCH_BITREVERSE */
>  
>  #define __bitrev8x4(x)	(__bitrev32(swab32(x)))
> -- 
> 2.34.1
> 

-- 
Cheers,
Nathan

  reply	other threads:[~2026-04-29 20:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-21 13:07 [PATCH v5 0/3] arch/riscv: Add bitrev.h file to support rev8 and brev8 Jinjie Ruan
2026-04-21 13:07 ` [PATCH v5 1/3] lib/bitrev: Introduce GENERIC_BITREVERSE and cleanup Kconfig Jinjie Ruan
2026-04-21 13:07 ` [PATCH v5 2/3] bitops: Define generic __bitrev8/16/32 for reuse Jinjie Ruan
2026-04-29 20:29   ` Nathan Chancellor [this message]
2026-04-30  1:47     ` Yury Norov
2026-04-30  3:59       ` Nathan Chancellor
2026-04-30 16:41         ` Yury Norov
2026-04-30 19:02           ` Nathan Chancellor
2026-04-21 13:07 ` [PATCH v5 3/3] arch/riscv: Add bitrev.h file to support rev8 and brev8 Jinjie Ruan
2026-04-27 20:18 ` [PATCH v5 0/3] " Yury Norov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260429202922.GA3575295@ax162 \
    --to=nathan@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=arnd@arndb.de \
    --cc=cp0613@linux.alibaba.com \
    --cc=david.laight.linux@gmail.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=ruanjinjie@huawei.com \
    --cc=yury.norov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox