From: Nathan Chancellor <nathan@kernel.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Naresh Kamboju <naresh.kamboju@linaro.org>,
clang-built-linux <llvm@lists.linux.dev>,
open list <linux-kernel@vger.kernel.org>,
dmaengine@vger.kernel.org, lkft-triage@lists.linaro.org,
Linux Regressions <regressions@lists.linux.dev>,
Vinod Koul <vkoul@kernel.org>, Guodong Xu <guodong@riscstar.com>,
Anders Roxell <anders.roxell@linaro.org>,
Dan Carpenter <dan.carpenter@linaro.org>,
Benjamin Copeland <benjamin.copeland@linaro.org>
Subject: Re: next-20250903 x86_64 clang-20 allyesconfig mmp_pdma.c:1188:14: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
Date: Wed, 3 Sep 2025 09:59:31 -0700 [thread overview]
Message-ID: <20250903165931.GA3288670@ax162> (raw)
In-Reply-To: <a07b0ebf-25e7-48ba-a1da-2c04fc0e027f@app.fastmail.com>
On Wed, Sep 03, 2025 at 02:04:10PM +0200, Arnd Bergmann wrote:
> On Wed, Sep 3, 2025, at 12:08, Naresh Kamboju wrote:
>
> > Build error:
> > drivers/dma/mmp_pdma.c:1188:14: error: shift count >= width of type
> > [-Werror,-Wshift-count-overflow]
> > 1188 | .dma_mask = DMA_BIT_MASK(64), /* force 64-bit DMA
> > addr capability */
> > | ^~~~~~~~~~~~~~~~
> > include/linux/dma-mapping.h:73:54: note: expanded from macro 'DMA_BIT_MASK'
> > 73 | #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
> > | ^ ~~~
>
> I see two separate issues:
>
> 1. The current DMA_BIT_MASK() definition seems unfortunate, as the
> '(n) == 64' check is meant to avoid this problem, but I think this
> only works inside of a function, not in a static structure definition.
Right, this is one of our longest outstanding issues :/
https://github.com/ClangBuiltLinux/linux/issues/92
https://github.com/llvm/llvm-project/issues/38137
This only happens at global scope.
> This could perhaps be avoided by replacing the ?: operator with
> __builtin_choose_expr(), but that likely causes other build failures.
Yeah, that makes the problem worse somehow even though GCC says the
non-taken option should not be evaluated...
drivers/dma/mmp_pdma.c:1188:14: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
1188 | .dma_mask = DMA_BIT_MASK(64), /* force 64-bit DMA addr capability */
| ^~~~~~~~~~~~~~~~
include/linux/dma-mapping.h:73:70: note: expanded from macro 'DMA_BIT_MASK'
73 | #define DMA_BIT_MASK(n) __builtin_choose_expr((n) == 64, ~0ULL, (1ULL<<(n))-1)
| ^ ~~~
drivers/dma/mmp_pdma.c:1323:27: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
1323 | dma_set_mask(pdev->dev, DMA_BIT_MASK(64));
| ^~~~~~~~~~~~~~~~
include/linux/dma-mapping.h:73:70: note: expanded from macro 'DMA_BIT_MASK'
73 | #define DMA_BIT_MASK(n) __builtin_choose_expr((n) == 64, ~0ULL, (1ULL<<(n))-1)
| ^ ~~~
> Guodong, how about a patch to drop all the custom dma_mask handling
> and instead just use dma_set_mask_and_coherent(DMA_BIT_MASK(64))
> or dma_set_mask_and_coherent(DMA_BIT_MASK(32)) here? Instead of
> passing the mask in the mmp_pdma_ops, you can replace it e.g. with
> a 'bool addr64' flag, or an 'int dma_width' number that
> gets passed into the DMA_MASK_MASK().
If this works, I think it is worth pursuing to avoid this bogus
warning/error.
Cheers,
Nathan
next prev parent reply other threads:[~2025-09-03 16:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-03 10:08 next-20250903 x86_64 clang-20 allyesconfig mmp_pdma.c:1188:14: error: shift count >= width of type [-Werror,-Wshift-count-overflow] Naresh Kamboju
2025-09-03 11:29 ` Dan Carpenter
2025-09-03 12:04 ` Arnd Bergmann
2025-09-03 16:59 ` Nathan Chancellor [this message]
2025-09-04 7:38 ` Guodong Xu
2025-09-17 18:25 ` Nathan Chancellor
2025-09-18 14:33 ` Guodong Xu
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=20250903165931.GA3288670@ax162 \
--to=nathan@kernel.org \
--cc=anders.roxell@linaro.org \
--cc=arnd@arndb.de \
--cc=benjamin.copeland@linaro.org \
--cc=dan.carpenter@linaro.org \
--cc=dmaengine@vger.kernel.org \
--cc=guodong@riscstar.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkft-triage@lists.linaro.org \
--cc=llvm@lists.linux.dev \
--cc=naresh.kamboju@linaro.org \
--cc=regressions@lists.linux.dev \
--cc=vkoul@kernel.org \
/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.