Archive-only list for patches
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: qinjian@cqplus1.com, mturquette@baylibre.com, sboyd@kernel.org
Cc: ndesaulniers@google.com, trix@redhat.com,
	linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org,
	llvm@lists.linux.dev, patches@lists.linux.dev
Subject: Re: [PATCH] clk: sp7021: Adjust width of _m in HWM_FIELD_PREP()
Date: Mon, 1 May 2023 14:37:14 -0700	[thread overview]
Message-ID: <20230501213714.GA1007102@dev-arch.thelio-3990X> (raw)
In-Reply-To: <20230501-sp7021-field_prep-warning-v1-1-5b36d71feefe@kernel.org>

On Mon, May 01, 2023 at 02:34:47PM -0700, Nathan Chancellor wrote:
> When building with clang + W=1, there is a warning around an internal
> comparison check within the FIELD_PREP() macro, due to a 32-bit variable
> comparison against ~0ull:
> 
>   drivers/clk/clk-sp7021.c:316:8: error: result of comparison of constant 18446744073709551615 with expression of type 'typeof (_Generic((_m), ...' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
>           r0 |= HWM_FIELD_PREP(MASK_SEL_FRA, clk->p[SEL_FRA]);
>                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   drivers/clk/clk-sp7021.c:45:15: note: expanded from macro 'HWM_FIELD_PREP'
>           (_m << 16) | FIELD_PREP(_m, value);     \
>                        ^~~~~~~~~~~~~~~~~~~~~
>   include/linux/bitfield.h:114:3: note: expanded from macro 'FIELD_PREP'
>                   __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: ");    \
>                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   include/linux/bitfield.h:71:53: note: expanded from macro '__BF_FIELD_CHECK'
>                   BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask) >     \
>                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
>   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
>   include/linux/compiler_types.h:397:22: note: expanded from macro 'compiletime_assert'
>           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>           ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   include/linux/compiler_types.h:385:23: note: expanded from macro '_compiletime_assert'
>           __compiletime_assert(condition, msg, prefix, suffix)
>           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   include/linux/compiler_types.h:377:9: note: expanded from macro '__compiletime_assert'
>                   if (!(condition))                                       \
>                         ^~~~~~~~~
> 
> This is expected given the tyoes of the input. Increase the size of the
> temporary variable in HWM_FIELD_PREP() to eliminate the warning, which
> follows the logic of commit cfd6fb45cfaf ("crypto: ccree - avoid
> out-of-range warnings from clang") for the same reasons.

Gah, I forgot:

Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/202303221947.pXP2v4xJ-lkp@intel.com/

> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  drivers/clk/clk-sp7021.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/clk-sp7021.c b/drivers/clk/clk-sp7021.c
> index 8fec14120105..11d22043ddd7 100644
> --- a/drivers/clk/clk-sp7021.c
> +++ b/drivers/clk/clk-sp7021.c
> @@ -41,7 +41,7 @@ enum {
>  /* HIWORD_MASK FIELD_PREP */
>  #define HWM_FIELD_PREP(mask, value)		\
>  ({						\
> -	u32 _m = mask;				\
> +	u64 _m = mask;				\
>  	(_m << 16) | FIELD_PREP(_m, value);	\
>  })
>  
> 
> ---
> base-commit: d54c1fd4a51e8fbc7f9da86b0cd338a4f7cd2bb2
> change-id: 20230501-sp7021-field_prep-warning-223f17aeea8e
> 
> Best regards,
> -- 
> Nathan Chancellor <nathan@kernel.org>
> 

  reply	other threads:[~2023-05-01 21:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-01 21:34 [PATCH] clk: sp7021: Adjust width of _m in HWM_FIELD_PREP() Nathan Chancellor
2023-05-01 21:37 ` Nathan Chancellor [this message]
2023-05-01 22:03   ` Nick Desaulniers
2023-05-01 22:15     ` Nick Desaulniers
2023-05-03  1:24 ` Stephen Boyd

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=20230501213714.GA1007102@dev-arch.thelio-3990X \
    --to=nathan@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mturquette@baylibre.com \
    --cc=ndesaulniers@google.com \
    --cc=patches@lists.linux.dev \
    --cc=qinjian@cqplus1.com \
    --cc=sboyd@kernel.org \
    --cc=trix@redhat.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