From patchwork Thu Mar 7 10:48:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 159838 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp7281874jad; Thu, 7 Mar 2019 02:49:26 -0800 (PST) X-Google-Smtp-Source: APXvYqwg1otHC/KbrSs3oWRr/4c1jpF7h07xtWKZA9+Il7opvSxJtzOAINzJvLZzvBL2hl28dms3 X-Received: by 2002:a63:1a25:: with SMTP id a37mr11145035pga.428.1551955766302; Thu, 07 Mar 2019 02:49:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551955766; cv=none; d=google.com; s=arc-20160816; b=0kcWmblyJJrHLkz5lrbGBxW9wvc6ewJdaAasiq1u5c/b8I57cJhGqnbaAJoejZnpEz K6IJuTVE+B03rMXcM0DiKMW5VHoNDHI+7cGuxH61MH56/prct61xoazpTCciedwkv0ch 3RId/4JsNJQyBSnAUVPkoAznEYN2j2OT0ySYwd5f7mRsP3OE8oNt4Fq+urQP4AjZ4bRU 8ZE5JwNPq/m6pzTBhqbDDdm4UO8v6R/jNo5YTv20q8dPuL8AbBMYmjL4gVMHABBH8q3U LxLE7BrfPkX1Zh1bybObZln+i201N5sibLWLleP8K6D8/ouscgGMC9B4TESVB/UkNLNn mktw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=yr4LrBe96LchxJmW2COAY8d/2wBoyEuQx9G0CzXEY3Q=; b=tEY1/jIankzROwmWfQtw9UQFKar/PRK1bPw8VS6Ia4tV5Gms3R28cfzAkIjekWzvjk q8uUfHWTeIdhoUvCNmhSMpyKN8x8MgcwXAuh1Gojz3SeKTJddaL9gxKWkn11c/3kz39I vcC9up9ImTJISj+qveuPRWxBVm1jdeU/SySPF95MiGr1O9TvdTiTdO5AYB+HRxl/arMP xnt8fvOTDXQDf8ByfXWC+1Eq7Yf+2HxDyhU64FKFhnq0xpOckocCDKHMbvEtw3X6EFwa TovS8bki6Q7zf31uc2XnmF9Nm4zVtB6b0lU1KOCwcEOxfBIhYj/rH/f8U4Q5VKcssNim XTgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e28si3562253pgm.368.2019.03.07.02.49.25; Thu, 07 Mar 2019 02:49:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726351AbfCGKtY (ORCPT + 31 others); Thu, 7 Mar 2019 05:49:24 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:45513 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726028AbfCGKtY (ORCPT ); Thu, 7 Mar 2019 05:49:24 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1MQ5jC-1hNlBo2eyu-00M4YD; Thu, 07 Mar 2019 11:49:04 +0100 From: Arnd Bergmann To: Christoph Hellwig , Marek Szyprowski Cc: Nick Desaulniers , Arnd Bergmann , Geert Uytterhoeven , Robin Murphy , Jesper Dangaard Brouer , Geert Uytterhoeven , Paul Burton , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v3] dma-mapping: work around clang bug Date: Thu, 7 Mar 2019 11:48:41 +0100 Message-Id: <20190307104900.2506657-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:SzMYzs5WTwwfpI3IgrpvZg3w8SruVDTlenEysSiOwZsB642hMs3 1Q8mb5BaswhiPxtn3DvOU9dv9TrsI/Qtw1FKvyVV1z+5I7K4pULqclcZPjyt2LHgRtlslGO i0aAZG+1N3RKOblrHF4QEqd4AeoTNX1lfWUbudH/+nV5THGMsrGElx3rTF5L43V7JhyjeRB rvokGZl+nlcvsaWKF0U6g== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:0LqwgvOLYpM=:psrSLhepFK/TX/fa5B7zsI +mm474dCa4yiYd2mx8wiCjcxsgDpqfCMFA8eVXJ7qyaihJltnMiDP5A0wp9TV06j7hv8I6TIE URb8Uhf5bu9TBzQilP7cMZnU/GazFdtLf+WZx8UrTeb7SKnSShLpda+Y9Wdbyg0CQ02sRiSmu 9/RB2IV5xjqDymnv02KkJ84IqoN9EPrecHyGF7xvHMfJoo9BOW0kOWtQxgmiY/sR+kMfOcA9f 3E1ofvaKSbRLMT8sIx7wRxrfjE3boG//26IzaknFQI03Q1NqGlvFpeD3lCPF4IOykYoz1aHUg JW7wEBrCjaqb2d8ku2i1RcikXinshSXKs+HDruNd1ieMSvC5AeAVAEySOlUj2FMjJRowXGbmw 3J2Vwm0BVYQupoCt+fARnhHpCM4dq5vrgExAttVhcaGOjb226dJW2UVhRPCecFNM0ZPC3D/BT KY1E3UTWCGSklLsTarsGPl5BcDWR2PLr5PQWGPaCOvdnMwZ4hpkvd5cErWX9qYOMCb5xM+Brv nagn7qakxYKc57Ia90WjVFxnJIQNvwhlOhtSJjp0Kvy32sJYoSRjZEUJfHIRVTu7nkTFnwBXI ypQscp7GJ2qg2OF7GrxW5d7x817iFi7j+9yEhY02fmJM9JdiQIAPy3gtCniJX/NV5X26LegFI Xx2bsqQS5+p+oAG7OkM0/LcYeUlmHx/aWAU4brmyMxBxOVTvbAVr88j0uafz77IZ/mJF2w5Iw 7BFvbiosfCpZyb6eBbBA0puf1/gf9yZZjL9E1g== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Robin Murphy Signed-off-by: Arnd Bergmann --- 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(-) -- 2.20.0 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