From: Arnd Bergmann <arnd@arndb.de> To: Christoph Hellwig <hch@lst.de>, Marek Szyprowski <m.szyprowski@samsung.com> Cc: Nick Desaulniers <ndesaulniers@google.com>, Arnd Bergmann <arnd@arndb.de>, Robin Murphy <robin.murphy@arm.com>, Jesper Dangaard Brouer <brouer@redhat.com>, Paul Burton <paul.burton@mips.com>, Geert Uytterhoeven <geert@linux-m68k.org>, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] dma-mapping: work around clang bug Date: Thu, 7 Mar 2019 09:52:37 +0100 [thread overview] Message-ID: <20190307085246.1477426-1-arnd@arndb.de> (raw) Clang has a rather annoying behavior of checking for integer arithmetic problems in code paths that are discarded by gcc before that perfoms the same checks. For DMA_BIT_MASK(64), this leads to a warning despite the result of the macro being completely sensible: arch/arm/plat-iop/adma.c:146:24: error: shift count >= width of type [-Werror,-Wshift-count-overflow] .coherent_dma_mask = DMA_BIT_MASK(64), The best workaround I could come up with is to shift the value twice, which makes the macro way less readable but always has the same result. Link: https://bugs.llvm.org/show_bug.cgi?id=38789 Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- v2: fix off-by-one error --- include/linux/dma-mapping.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 75e60be91e5f..9e438fe6b130 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -138,7 +138,8 @@ struct dma_map_ops { extern const struct dma_map_ops dma_virt_ops; extern const struct dma_map_ops dma_dummy_ops; -#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) +/* double shift to work around https://bugs.llvm.org/show_bug.cgi?id=38789 */ +#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<((n)-1))<<1)-1) #define DMA_MASK_NONE 0x0ULL -- 2.20.0
WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> To: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>, Marek Szyprowski <m.szyprowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org> Cc: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>, Nick Desaulniers <ndesaulniers-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Paul Burton <paul.burton-8NJIiSa5LzA@public.gmane.org>, Geert Uytterhoeven <geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>, Jesper Dangaard Brouer <brouer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>, Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org> Subject: [PATCH] [v2] dma-mapping: work around clang bug Date: Thu, 7 Mar 2019 09:52:37 +0100 [thread overview] Message-ID: <20190307085246.1477426-1-arnd@arndb.de> (raw) Clang has a rather annoying behavior of checking for integer arithmetic problems in code paths that are discarded by gcc before that perfoms the same checks. For DMA_BIT_MASK(64), this leads to a warning despite the result of the macro being completely sensible: arch/arm/plat-iop/adma.c:146:24: error: shift count >= width of type [-Werror,-Wshift-count-overflow] .coherent_dma_mask = DMA_BIT_MASK(64), The best workaround I could come up with is to shift the value twice, which makes the macro way less readable but always has the same result. Link: https://bugs.llvm.org/show_bug.cgi?id=38789 Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> --- v2: fix off-by-one error --- include/linux/dma-mapping.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 75e60be91e5f..9e438fe6b130 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -138,7 +138,8 @@ struct dma_map_ops { extern const struct dma_map_ops dma_virt_ops; extern const struct dma_map_ops dma_dummy_ops; -#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) +/* double shift to work around https://bugs.llvm.org/show_bug.cgi?id=38789 */ +#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<((n)-1))<<1)-1) #define DMA_MASK_NONE 0x0ULL -- 2.20.0
next reply other threads:[~2019-03-07 8:53 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-03-07 8:52 Arnd Bergmann [this message] 2019-03-07 8:52 ` [PATCH] [v2] dma-mapping: work around clang bug Arnd Bergmann 2019-03-07 9:17 ` Robin Murphy 2019-03-07 9:17 ` Robin Murphy 2019-03-07 9:28 ` Arnd Bergmann 2019-03-07 9:34 ` Geert Uytterhoeven 2019-03-07 9:43 ` Robin Murphy 2019-03-07 9:43 ` Robin Murphy
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=20190307085246.1477426-1-arnd@arndb.de \ --to=arnd@arndb.de \ --cc=brouer@redhat.com \ --cc=geert@linux-m68k.org \ --cc=hch@lst.de \ --cc=iommu@lists.linux-foundation.org \ --cc=linux-kernel@vger.kernel.org \ --cc=m.szyprowski@samsung.com \ --cc=ndesaulniers@google.com \ --cc=paul.burton@mips.com \ --cc=robin.murphy@arm.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: linkBe 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.