From patchwork Fri Dec 22 18:06:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 13503680 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C2703C41535 for ; Fri, 22 Dec 2023 18:07:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ETB72Gv6+ZFObxk+ES49Qjb5LG1h9pcbI2yXC4BFZTU=; b=t7PmaZ1VaqPDKF ZGn1lLOZKZRyYeDmhzM8Ur63dgHkirnFzcBUD3Zql8UbNbxXPT4wuyVwlX1k/iAh/kckQr5Qd1kkX 4+uP+VpDI2u8zzJhEE/Ce4xC5xaz5L38h66gXMfwp2OH2mnzGmPJ0ZsiyoHH5qd8M9pRc1jI2IIb9 qeEUG1aSQ90nXjsENrBb1d2Vd5naNh2nfogDqc01XDIAc+pcn/Q9cv5pWNWSRTrgams+LSr3JrRa2 H9cJYag4I/xQOf+KgwyZD6wHEWqu7D1lbNd0qOnpOSF+hw9MKZMOoVTVL4bymrd+fdwFQL/SiQQtu ukXbIZY4TZ5zEWHtqQ3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rGjvL-006caY-09; Fri, 22 Dec 2023 18:07:03 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rGjvC-006cXB-02 for linux-arm-kernel@lists.infradead.org; Fri, 22 Dec 2023 18:06:55 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 646A9CE22C0; Fri, 22 Dec 2023 18:06:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2331BC433C9; Fri, 22 Dec 2023 18:06:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703268410; bh=lX+6lFYU6sXpA5iyj5rt2HioLz9F3owwQBDV7k0OyTM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fVu6VfJq2xG417MNUBKyvn4J5v99Z+2F/SHFohDTYUwqLcESvql6+1cHd1naw60YF 3V9EgoNP78KyLWVidzbzO9b63qr5eO/xlUZ3LDQ+Sk1CbIS9G7EHkARiTvm5Vnc18i xJa9H+186q/CDsHSKB+Cs3jz19yvfcNRbqf0in1pa625/q+QqDw4HCyr6Pb98U7bpw wIIg7bP6oIG22bO5ATf42G0jpaT6WO7trDgnZ0+LnuHndL+JEpS7mcHUJVWiPGREdJ 5yzUpXhD7uB3TkXUoRt6N1m823icEgz7XhBRkoVLgqlxYdQJVmj1zSX3o5WUBhMwUv h2yRWtJWKk+jg== From: Nathan Chancellor Date: Fri, 22 Dec 2023 11:06:44 -0700 Subject: [PATCH 1/2] dmaengine: xilinx: xdma: Fix operator precedence in xdma_prep_interleaved_dma() MIME-Version: 1.0 Message-Id: <20231222-dma-xilinx-xdma-clang-fixes-v1-1-84a18ff184d2@kernel.org> References: <20231222-dma-xilinx-xdma-clang-fixes-v1-0-84a18ff184d2@kernel.org> In-Reply-To: <20231222-dma-xilinx-xdma-clang-fixes-v1-0-84a18ff184d2@kernel.org> To: lizhi.hou@amd.com, brian.xu@amd.com, raj.kumar.rampelli@amd.com, vkoul@kernel.org, jankul@alatek.krakow.pl Cc: dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, patches@lists.linux.dev, Nathan Chancellor X-Mailer: b4 0.13-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4102; i=nathan@kernel.org; h=from:subject:message-id; bh=lX+6lFYU6sXpA5iyj5rt2HioLz9F3owwQBDV7k0OyTM=; b=owGbwMvMwCUmm602sfCA1DTG02pJDKmtFyx7Ze4/VD7pt1h+W8lNnvprb278cv+W4XF7seK9o 5ZnX4vt6ShlYRDjYpAVU2Spfqx63NBwzlnGG6cmwcxhZQIZwsDFKQATafrB8L/IdbfJXEcTx1zX Esfv06SS5HecypBTfLHE5Erng29H2WYzMvxIvrAr7HXZEtaIxiM29qHFAWvbyqQ+MiYe9TnTkNZ yjAcA X-Developer-Key: i=nathan@kernel.org; a=openpgp; fpr=2437CB76E544CB6AB3D9DFD399739260CB6CB716 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231222_100654_399350_E4BFA19E X-CRM114-Status: UNSURE ( 9.47 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Clang warns (or errors with CONFIG_WERROR=y): drivers/dma/xilinx/xdma.c:757:68: error: operator '?:' has lower precedence than '+'; '+' will be evaluated first [-Werror,-Wparentheses] 757 | src_addr += dmaengine_get_src_icg(xt, &xt->sgl[i]) + xt->src_inc ? | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ drivers/dma/xilinx/xdma.c:757:68: note: place parentheses around the '+' expression to silence this warning 757 | src_addr += dmaengine_get_src_icg(xt, &xt->sgl[i]) + xt->src_inc ? | ^ | ( ) drivers/dma/xilinx/xdma.c:757:68: note: place parentheses around the '?:' expression to evaluate it first 757 | src_addr += dmaengine_get_src_icg(xt, &xt->sgl[i]) + xt->src_inc ? | ^ | ( 758 | xt->sgl[i].size : 0; | | ) drivers/dma/xilinx/xdma.c:759:68: error: operator '?:' has lower precedence than '+'; '+' will be evaluated first [-Werror,-Wparentheses] 759 | dst_addr += dmaengine_get_dst_icg(xt, &xt->sgl[i]) + xt->dst_inc ? | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ drivers/dma/xilinx/xdma.c:759:68: note: place parentheses around the '+' expression to silence this warning 759 | dst_addr += dmaengine_get_dst_icg(xt, &xt->sgl[i]) + xt->dst_inc ? | ^ | ( ) drivers/dma/xilinx/xdma.c:759:68: note: place parentheses around the '?:' expression to evaluate it first 759 | dst_addr += dmaengine_get_dst_icg(xt, &xt->sgl[i]) + xt->dst_inc ? | ^ | ( 760 | xt->sgl[i].size : 0; | | ) The src_inc and dst_inc members of 'struct dma_interleaved_template' are booleans, so it does not make sense for the addition to happen first. Wrap the conditional operator in parantheses so it is evaluated first. Closes: https://github.com/ClangBuiltLinux/linux/issues/1971 Fixes: 2f8f90cd2f8d ("dmaengine: xilinx: xdma: Implement interleaved DMA transfers") Signed-off-by: Nathan Chancellor --- drivers/dma/xilinx/xdma.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/dma/xilinx/xdma.c b/drivers/dma/xilinx/xdma.c index 4ebc90b41bdb..d5b9fc3fd955 100644 --- a/drivers/dma/xilinx/xdma.c +++ b/drivers/dma/xilinx/xdma.c @@ -754,10 +754,10 @@ xdma_prep_interleaved_dma(struct dma_chan *chan, dst_addr = xt->dst_start; for (i = 0; i < xt->frame_size; ++i) { desc_num += xdma_fill_descs(sw_desc, src_addr, dst_addr, xt->sgl[i].size, desc_num); - src_addr += dmaengine_get_src_icg(xt, &xt->sgl[i]) + xt->src_inc ? - xt->sgl[i].size : 0; - dst_addr += dmaengine_get_dst_icg(xt, &xt->sgl[i]) + xt->dst_inc ? - xt->sgl[i].size : 0; + src_addr += dmaengine_get_src_icg(xt, &xt->sgl[i]) + (xt->src_inc ? + xt->sgl[i].size : 0); + dst_addr += dmaengine_get_dst_icg(xt, &xt->sgl[i]) + (xt->dst_inc ? + xt->sgl[i].size : 0); period_size += xt->sgl[i].size; } sw_desc->period_size = period_size;