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; From patchwork Fri Dec 22 18:06:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 13503716 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 211E4C41535 for ; Fri, 22 Dec 2023 19:17:35 +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=wrPnvyoqisTsqLn1+vn/Klu4wznnF4a8TX3w6PtfQDY=; b=HBJ+dS8eQM06dK iGm5f6KN9gLXTJACvZITo3Qo2mduvB4CDC+wvQG24RGF2f+25jwNNMfmVzJq1HfItugWEERKfsrM/ hOUEOeZW1Dkgd8VIIu8f76MLhutJVpifjfwdmIC6GQjjmj97c/gaKWm4uMQlJhDwgAPbHTnb9tAqg xQShS/NO27vUs9enA2jbh6PmYR26P3KusVu2SxKBxyUR0snBVe2lPiaCN69c+Q+WqMlPafKNAZHLP ABYh26qXihbu7hWTeyv8FAl+UC/V79sQ6tvaGU1J27Mp+201pYg9g5htkPSSXQ0/0c3pJ2+CWtzGJ uB+FvAK1bggdDxxKfeLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rGl1F-006gfF-24; Fri, 22 Dec 2023 19:17:13 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rGjvA-006cWo-1W for linux-arm-kernel@lists.infradead.org; Fri, 22 Dec 2023 18:06:53 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B076261CCD; Fri, 22 Dec 2023 18:06:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0766C433CB; 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=1703268411; bh=1NacUmbt0EL+svtNIQXZRZLRDTEQIO2JqZEQWM/2bL4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=bOsqJa9Z2mcuE07Kuz2eSAWosTxeaDtF/q2v65sbHGA7ebEHuNTiSVjILmaTGKqm0 1viWAz+89BjuLjd0fo7Vf7K3baMl0HfFHMT5utV0/eEEGIGknPAqI5gKSvfOvXLKg0 vUQw6x7EXx3m8T4FzUvL2XZJh+vcW0xKLAvEGQyVB8TbJ0Y62++OOtbpnxIzfe+HcY AOlRCcjhwSokLf46G1Yk2dT8jCdV/pviSByjpFHe9iuvbEEbqCdSvU/7J42v+/0I6D Cbo0nRCToqM/HhW9CTqyLPxYuOG7/KLWd4gNyQdOcKgSeuQn6tUrwkUObA5IdfLhW8 pWWX19xVjAw+Q== From: Nathan Chancellor Date: Fri, 22 Dec 2023 11:06:45 -0700 Subject: [PATCH 2/2] dmaengine: xilinx: xdma: Fix initialization location of desc in xdma_channel_isr() MIME-Version: 1.0 Message-Id: <20231222-dma-xilinx-xdma-clang-fixes-v1-2-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=1437; i=nathan@kernel.org; h=from:subject:message-id; bh=1NacUmbt0EL+svtNIQXZRZLRDTEQIO2JqZEQWM/2bL4=; b=owGbwMvMwCUmm602sfCA1DTG02pJDKmtFyz1xZ3TE51/h8nMXfzmg90qwSjOtSXl6o9Pl51zm iDiani6o5SFQYyLQVZMkaX6sepxQ8M5ZxlvnJoEM4eVCWQIAxenAEykRJrhn8lFq0c/dhlvlqi7 stmgek3Xfq3Sl+pm5T0v1NoS4l7tCmL4X8m6dGvo+leXfKrMLm/T04zVfqj6yKvxqkqfoL3LB9Y rjAA= 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_100652_555194_4313FEFE X-CRM114-Status: GOOD ( 10.66 ) 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:894:3: error: variable 'desc' is uninitialized when used here [-Werror,-Wuninitialized] 894 | desc->error = true; | ^~~~ The initialization of desc was moved too far forward, move it back so that this assignment does not result in a potential crash at runtime while clearing up the warning. Closes: https://github.com/ClangBuiltLinux/linux/issues/1972 Fixes: 2f8f90cd2f8d ("dmaengine: xilinx: xdma: Implement interleaved DMA transfers") Signed-off-by: Nathan Chancellor --- drivers/dma/xilinx/xdma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/dma/xilinx/xdma.c b/drivers/dma/xilinx/xdma.c index d5b9fc3fd955..ee595d1ebc63 100644 --- a/drivers/dma/xilinx/xdma.c +++ b/drivers/dma/xilinx/xdma.c @@ -888,6 +888,8 @@ static irqreturn_t xdma_channel_isr(int irq, void *dev_id) if (ret) goto out; + desc = to_xdma_desc(vd); + st &= XDMA_CHAN_STATUS_MASK; if ((st & XDMA_CHAN_ERROR_MASK) || !(st & (CHAN_CTRL_IE_DESC_COMPLETED | CHAN_CTRL_IE_DESC_STOPPED))) { @@ -901,7 +903,6 @@ static irqreturn_t xdma_channel_isr(int irq, void *dev_id) if (ret) goto out; - desc = to_xdma_desc(vd); if (desc->interleaved_dma) { xchan->busy = false; desc->completed_desc_num += complete_desc_num;