From patchwork Thu Mar 7 08:52:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 159804 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp7182022jad; Thu, 7 Mar 2019 00:53:13 -0800 (PST) X-Google-Smtp-Source: APXvYqzP8IobCDQsYwdAFFq5tttQ9E0XYrTm7RphtVLackjup4IScAW1u5jcyQsGN2OhOXBHM8eV X-Received: by 2002:aa7:8597:: with SMTP id w23mr11414963pfn.87.1551948793753; Thu, 07 Mar 2019 00:53:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551948793; cv=none; d=google.com; s=arc-20160816; b=XBcHvvkpKh9sCTvVLKR5MV+3sKumCymmV4skCoT2bhW8jRiRw+eGeaaI8e2KY7J3yP 1DaDjuulZJfKEvCXwh74txiucHDSz1xgsDjytew0LG4/c21zA7HPqgb+wcvcInShPc2L jYao0cpIrWcnFaOyUhDFMxb/nyqg0zipkp6WEZqC1LYXDpqr3LfrPOqLyahTZAYaYuEb FG0wbTGdJIAZfmG6qiK9Zp5E+tF/UY4AnXYqoT1HWmu1iuvOXDkC25t7DlQELzsmLqgl okpMZR0f+FPwrH3N5RUAbBjHOW7rq3xUJDsbemDCKwhU6RtnwsUF6+dVZohM7XI1Z2KL oilQ== 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=AaO9/XJuM+qYdrX1ImLNhraBOQs6j13JRDvJEL8zcGs=; b=iHIUFIXM9D1k4udhPNT00W+aCi6Q8ph36rXL05j/Puyw1L1IKOjJZ+2zij1QtRtR/R frHoYHL7GukFyRT2YXJowtDMVl4ZZM8IB6eEyE7q4rY40PR3qOa4mf5biUx1kVko6tuG xEOq0KCxyl45Kcbjd+ZYS4t1GV5dtTmnhi/VB85mFjQMORd3OOnAkx/5JHe0F3CSElFI 2Ec8Md3XWnMLPioL4OPCTIThz+qzvI/8+oGbbCIfy1zWRqNIOEoxP53DvGGuhja0mG7O lBgp72wkMR8CcfdBEPncpD7Y/KaQ2chDCqPwN+7IOEB6p8PwPDV2QgyzuSjWsxIrliRX B48A== 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 c9si3445115pgi.139.2019.03.07.00.53.11; Thu, 07 Mar 2019 00:53:13 -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 S1726185AbfCGIxG (ORCPT + 31 others); Thu, 7 Mar 2019 03:53:06 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:46513 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725795AbfCGIxF (ORCPT ); Thu, 7 Mar 2019 03:53:05 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1M3VAI-1h2MjY0k5K-000fik; Thu, 07 Mar 2019 09:52:50 +0100 From: Arnd Bergmann To: Christoph Hellwig , Marek Szyprowski Cc: Nick Desaulniers , Arnd Bergmann , Robin Murphy , Jesper Dangaard Brouer , Paul Burton , Geert Uytterhoeven , 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 Message-Id: <20190307085246.1477426-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:1IG7sJztCRmdMYLAxD1DRCX9ygMUlZqxJER9m/CQjvO3kayExA1 QQg2Vh4VFd634KQk/V7DgsPvCs5qrZiWWSMDWjw8My+OondYUhbyZnjxPdRm4FtLUwo4oWo geWLoW/IK2SvGlieteCB9EQsi/XSRmOtOsbtvQFXti2cnSf23BM03z4pH8HNrMGzChO/zAN 3nI6JGHOwUD6YAgqzH0zQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:Aq9vowMyGQw=:4/EhYBlD7VTqK2bmmic/Fs d9xdO8N99/JRa0yvSA1l6Cofge09LQKa/9pR+6a46WluxBgCgVkWGhclKlBBXTwBaOZXBlZow qC3LLv3/thjWbYfNFxe1tCkMkWqTn8BzOAUFIcgS3No1STcaIXg7O0buOYT0NOkOBlYUxB6Q9 esaBM8sZQ0nXSbIBpNhTnnuATBdb9QXzGumP08usZYXq2MrxIJMyLFfwqPLiYyXONSnv6Zssf 9VnFNMBVP1AleGFISeak7WLTNloWpPjrnJhQYbNQkFMU98K+FUOm2zuKKpB/eadwo4zWNRtLX MVcWiNnWdF5Uopoi5tzi5vqpoQEHsF+qq52lpvbu/7tebSz5O1uu4kjJ6arpAO37xv63rRkEy +G1tQQY559DgcaTkLf+W3OCDoN9yPyCXDbTurDkY055nO6BOv3vQOcHwSb7nLB6fiEucRSb+F uzbpfm55kqaFUuuNbkzCGmLX4eLnfpHRbmVmSwkipkofWJnKIxMV5PUfkHa3CJ0Y+1sHkm4S/ rFoi6coLhPR3LJflUo7xtbItWofe3Ju9elCebKITe0tRjHPuyPpOHIdBRsQov0GUCS+JWIKhD J5evYD4cR34dYcnlVbqHgaND1dBq7raA6XK6lKS3kkVYpy0bPyI8LPnIsg+Z70aRfaYVSiRKd 3FLB9Zv1BYuuaLBt9mk6E3egd88OOlZs3fPeZksiM0MZP2hIuJT7gDhWMikGLR9tg5j3rA3U7 iyRVNQ3UDTw6hKgzbBDelREYrf67KRhuI9M7TA== 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 Signed-off-by: Arnd Bergmann --- v2: fix off-by-one error --- include/linux/dma-mapping.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.20.0 Reviewed-by: Geert Uytterhoeven Reviewed-by: Robin Murphy 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