* [PATCH] [v3] dma-mapping: work around clang bug
@ 2019-03-07 10:48 Arnd Bergmann
2019-03-08 15:27 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2019-03-07 10:48 UTC (permalink / raw)
To: Christoph Hellwig, Marek Szyprowski
Cc: Nick Desaulniers, Arnd Bergmann, Geert Uytterhoeven,
Robin Murphy, Jesper Dangaard Brouer, Geert Uytterhoeven,
Paul Burton, iommu, linux-kernel
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
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v3: use (2ull << n-1) instead of ((1ull << n-1) << 1)
special-case 0 instead of 64
v2: fix off-by-one error
---
include/linux/dma-mapping.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 75e60be91e5f..5788d60c2223 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -138,7 +138,11 @@ 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))
+/*
+ * Shifting '2' instead of '1' because of
+ * https://bugs.llvm.org/show_bug.cgi?id=38789
+ */
+#define DMA_BIT_MASK(n) (((n) == 0) ? 0ULL : (2ULL<<((n)-1))-1)
#define DMA_MASK_NONE 0x0ULL
--
2.20.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] [v3] dma-mapping: work around clang bug
@ 2019-03-08 15:27 ` Christoph Hellwig
0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2019-03-08 15:27 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Christoph Hellwig, Marek Szyprowski, Nick Desaulniers,
Geert Uytterhoeven, Robin Murphy, Jesper Dangaard Brouer,
Geert Uytterhoeven, Paul Burton, iommu, linux-kernel
NAK on this whole patch. Please fix the compiler instead of making
a complete mess of a common macro.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] [v3] dma-mapping: work around clang bug
@ 2019-03-08 15:27 ` Christoph Hellwig
0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2019-03-08 15:27 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Geert Uytterhoeven, Nick Desaulniers,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Paul Burton,
Geert Uytterhoeven, Jesper Dangaard Brouer, Robin Murphy,
Christoph Hellwig
NAK on this whole patch. Please fix the compiler instead of making
a complete mess of a common macro.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] [v3] dma-mapping: work around clang bug
2019-03-08 15:27 ` Christoph Hellwig
(?)
@ 2019-03-08 18:00 ` Nick Desaulniers
-1 siblings, 0 replies; 4+ messages in thread
From: Nick Desaulniers @ 2019-03-08 18:00 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Arnd Bergmann, Marek Szyprowski, Geert Uytterhoeven,
Robin Murphy, Jesper Dangaard Brouer, Geert Uytterhoeven,
Paul Burton, iommu, LKML
On Fri, Mar 8, 2019 at 7:27 AM Christoph Hellwig <hch@lst.de> wrote:
>
> NAK on this whole patch. Please fix the compiler instead of making
> a complete mess of a common macro.
Definitely on the TODO list; higher priority, but not highest right
now. I'll see if I can get some help with it.
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-03-08 18:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07 10:48 [PATCH] [v3] dma-mapping: work around clang bug Arnd Bergmann
2019-03-08 15:27 ` Christoph Hellwig
2019-03-08 15:27 ` Christoph Hellwig
2019-03-08 18:00 ` Nick Desaulniers
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.