From: Will Deacon <will@kernel.org>
To: Qian Cai <cai@lca.pw>
Cc: catalin.marinas@arm.com, rrichter@cavium.com,
robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] arm64/prefetch: fix a -Wtype-limits warning
Date: Mon, 5 Aug 2019 11:00:59 +0100 [thread overview]
Message-ID: <20190805100059.4gml6c4kclz2iin3@willie-the-truck> (raw)
In-Reply-To: <20190803003358.992-1-cai@lca.pw>
On Fri, Aug 02, 2019 at 08:33:58PM -0400, Qian Cai wrote:
> The commit d5370f754875 ("arm64: prefetch: add alternative pattern for
> CPUs without a prefetcher") introduced MIDR_IS_CPU_MODEL_RANGE() to be
> used in has_no_hw_prefetch() with rv_min=0 which generates a compilation
> warning from GCC,
>
> In file included from ./arch/arm64/include/asm/cache.h:8,
> from ./include/linux/cache.h:6,
> from ./include/linux/printk.h:9,
> from ./include/linux/kernel.h:15,
> from ./include/linux/cpumask.h:10,
> from arch/arm64/kernel/cpufeature.c:11:
> arch/arm64/kernel/cpufeature.c: In function 'has_no_hw_prefetch':
> ./arch/arm64/include/asm/cputype.h:59:26: warning: comparison of
> unsigned expression >= 0 is always true [-Wtype-limits]
> _model == (model) && rv >= (rv_min) && rv <= (rv_max); \
> ^~
> arch/arm64/kernel/cpufeature.c:889:9: note: in expansion of macro
> 'MIDR_IS_CPU_MODEL_RANGE'
> return MIDR_IS_CPU_MODEL_RANGE(midr, MIDR_THUNDERX,
> ^~~~~~~~~~~~~~~~~~~~~~~
>
> Fix it by making "rv" a "s32".
>
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
>
> v2: Use "s32" for "rv", so "variant 0/revision 0" can be covered.
>
> arch/arm64/include/asm/cputype.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h
> index e7d46631cc42..d52fe8651c2d 100644
> --- a/arch/arm64/include/asm/cputype.h
> +++ b/arch/arm64/include/asm/cputype.h
> @@ -54,7 +54,7 @@
> #define MIDR_IS_CPU_MODEL_RANGE(midr, model, rv_min, rv_max) \
> ({ \
> u32 _model = (midr) & MIDR_CPU_MODEL_MASK; \
> - u32 rv = (midr) & (MIDR_REVISION_MASK | MIDR_VARIANT_MASK); \
> + s32 rv = (midr) & (MIDR_REVISION_MASK | MIDR_VARIANT_MASK); \
Hmm, but this really isn't a signed quantity: it's two fields extracted
from an ID register. I think the code is fine. Are you explicitly enabling
-Wtype-limits somehow?
Will
WARNING: multiple messages have this Message-ID (diff)
From: Will Deacon <will@kernel.org>
To: Qian Cai <cai@lca.pw>
Cc: rrichter@cavium.com, catalin.marinas@arm.com,
robin.murphy@arm.com, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2] arm64/prefetch: fix a -Wtype-limits warning
Date: Mon, 5 Aug 2019 11:00:59 +0100 [thread overview]
Message-ID: <20190805100059.4gml6c4kclz2iin3@willie-the-truck> (raw)
In-Reply-To: <20190803003358.992-1-cai@lca.pw>
On Fri, Aug 02, 2019 at 08:33:58PM -0400, Qian Cai wrote:
> The commit d5370f754875 ("arm64: prefetch: add alternative pattern for
> CPUs without a prefetcher") introduced MIDR_IS_CPU_MODEL_RANGE() to be
> used in has_no_hw_prefetch() with rv_min=0 which generates a compilation
> warning from GCC,
>
> In file included from ./arch/arm64/include/asm/cache.h:8,
> from ./include/linux/cache.h:6,
> from ./include/linux/printk.h:9,
> from ./include/linux/kernel.h:15,
> from ./include/linux/cpumask.h:10,
> from arch/arm64/kernel/cpufeature.c:11:
> arch/arm64/kernel/cpufeature.c: In function 'has_no_hw_prefetch':
> ./arch/arm64/include/asm/cputype.h:59:26: warning: comparison of
> unsigned expression >= 0 is always true [-Wtype-limits]
> _model == (model) && rv >= (rv_min) && rv <= (rv_max); \
> ^~
> arch/arm64/kernel/cpufeature.c:889:9: note: in expansion of macro
> 'MIDR_IS_CPU_MODEL_RANGE'
> return MIDR_IS_CPU_MODEL_RANGE(midr, MIDR_THUNDERX,
> ^~~~~~~~~~~~~~~~~~~~~~~
>
> Fix it by making "rv" a "s32".
>
> Signed-off-by: Qian Cai <cai@lca.pw>
> ---
>
> v2: Use "s32" for "rv", so "variant 0/revision 0" can be covered.
>
> arch/arm64/include/asm/cputype.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h
> index e7d46631cc42..d52fe8651c2d 100644
> --- a/arch/arm64/include/asm/cputype.h
> +++ b/arch/arm64/include/asm/cputype.h
> @@ -54,7 +54,7 @@
> #define MIDR_IS_CPU_MODEL_RANGE(midr, model, rv_min, rv_max) \
> ({ \
> u32 _model = (midr) & MIDR_CPU_MODEL_MASK; \
> - u32 rv = (midr) & (MIDR_REVISION_MASK | MIDR_VARIANT_MASK); \
> + s32 rv = (midr) & (MIDR_REVISION_MASK | MIDR_VARIANT_MASK); \
Hmm, but this really isn't a signed quantity: it's two fields extracted
from an ID register. I think the code is fine. Are you explicitly enabling
-Wtype-limits somehow?
Will
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-08-05 10:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-03 0:33 [PATCH v2] arm64/prefetch: fix a -Wtype-limits warning Qian Cai
2019-08-03 0:33 ` Qian Cai
2019-08-05 10:00 ` Will Deacon [this message]
2019-08-05 10:00 ` Will Deacon
2019-08-05 12:03 ` Qian Cai
2019-08-05 12:03 ` Qian Cai
2019-08-05 17:03 ` Will Deacon
2019-08-05 17:03 ` Will Deacon
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=20190805100059.4gml6c4kclz2iin3@willie-the-truck \
--to=will@kernel.org \
--cc=cai@lca.pw \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=rrichter@cavium.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.