Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1707592rwd; Sun, 21 May 2023 04:50:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ53Wugftzq8nv/FTdogdm0EKc0Nz+9bHBrdqgxMgRLse5FocCkqh1G/i5V/JT4heDbJo7CJ X-Received: by 2002:a17:902:db07:b0:1ac:8dae:d842 with SMTP id m7-20020a170902db0700b001ac8daed842mr9818400plx.46.1684669815754; Sun, 21 May 2023 04:50:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684669815; cv=none; d=google.com; s=arc-20160816; b=qGBxCq30602xJjlP5naeGBvZHxTbl2CPdyvSPRmIVoeZvXt8ryVZlshFmTqekCfHo5 qSZUYzgMFcmBmWOw5T2lObIlIl+JRE2+qlt67R7b2jU1qU7PZ8meLVTI68AdOHwHMoMQ Y2nik7WpplcAdkqxZ6OVyTDAjFWLgnNMPkv2D2PoBXnHDzItfdGQOBvZ2RrVlqnfB+Z4 GH/fEwaz8deK2onX7+Bciilj9snHfACSWhYduaeIO/bCa56TNoKvxyV46ACZUV23Mm3i CliYvJzvK9avhJ63rTEEPHB29hTbkhnkwM78Wq5xhxPiz1LU9n0eAoXDc4YY5NsoIbkC V5jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sf1zcZVOOhtKIjM5/3EZhKRiuu9o7kaxevEK2H5yYzk=; b=MPH0P66mtRIAO1iF9BiWqw52rv88x5GBQHFG9h4s4C2Umz0TIH+A5aZl23A7cQJcQW crYN8waJ8LdWqfV//W1CZf1iDegI+O4KkIudaEEk+1WsCYwNb+G8JV/vf8la1itnJ/Hi f6aqOp1k3E29Px+SFrCRa5vocShdEIL4oGn3DP/3cCmts6aI0qtejNIxHTYGsI/hUcL/ YauONoDKCfZeQRHo2A0+xMTjeZ7RD/EXbWN4rOQjYIuF7VbfRFTaPbcpZ0bfWQpQ3Wca ED0avKVY/Nk79BOY9vr+qZaq967kSwbQT995pAM00Fi2Wzg0IwKFnULer/bejU9JuaBS QKAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZTS2wewK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w19-20020a170902d3d300b001ab115a96c7si2783530plb.340.2023.05.21.04.50.00; Sun, 21 May 2023 04:50:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZTS2wewK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230241AbjEULsT (ORCPT + 99 others); Sun, 21 May 2023 07:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230484AbjEUK1w (ORCPT ); Sun, 21 May 2023 06:27:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59AD110F0; Sun, 21 May 2023 03:23:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E36A3611F6; Sun, 21 May 2023 10:23:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 758A8C4339C; Sun, 21 May 2023 10:23:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684664618; bh=3vm8AIqJvr6Fc6EEUZBTa078hFQD/CBcDZ6PM3gC9JA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZTS2wewKlHnWKe/Xt0LHnE/CRuHSfAree8mN77wrdaHUgAwoMzJxDIv9fOnD9xuCa Z5gw7/WkCIz6Uc2CXENgFaDYuWj294/D9DAA+hm9kPqKFv7z1S5mRIv5a1HU4r0Lzw sKVlEtkCZMAVHPdG/CS9SooYm3vY4TG4AOwg358K5yhravQ8lP9qpcUMOU79pvWG3M JAkzoXuK3cNMCqbSdrR+OS7eeFcKOVgY9tr9AgjRQBX5QgcNuWnETHSTGcoz7Bpd6H G1hGLEeTqCj3IsudnqNzsjs4MFMzyzhW2rlfsy/onGJMTxxzWwRd32XawUkkPKfN83 +H8XR1Xxshipw== From: Jisheng Zhang To: Eugeniy Paltsev , Vinod Koul Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 10/11] dmaengine: dw-axi-dmac: move dma_chan_tx_status() Date: Sun, 21 May 2023 18:12:15 +0800 Message-Id: <20230521101216.4084-11-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230521101216.4084-1-jszhang@kernel.org> References: <20230521101216.4084-1-jszhang@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We will add polled support soon, for which we need to call dw_axi_dma_handle_ch() in dma_chan_tx_status(). Move the function to avoid pre-declaration. No functionality changes. Signed-off-by: Jisheng Zhang --- .../dma/dw-axi-dmac/dw-axi-dmac-platform.c | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c index f14fdfc9c7e9..091c15c2ec31 100644 --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c @@ -307,48 +307,6 @@ static void vchan_desc_put(struct virt_dma_desc *vdesc) axi_desc_put(vd_to_axi_desc(vdesc)); } -static enum dma_status -dma_chan_tx_status(struct dma_chan *dchan, dma_cookie_t cookie, - struct dma_tx_state *txstate) -{ - struct axi_dma_chan *chan = dchan_to_axi_dma_chan(dchan); - struct axi_dma_desc *desc = NULL; - struct virt_dma_desc *vdesc; - enum dma_status status; - u32 completed_length; - unsigned long flags; - u32 completed_blocks; - size_t bytes = 0; - u32 length; - u32 len; - - status = dma_cookie_status(dchan, cookie, txstate); - if (status == DMA_COMPLETE || !txstate) - return status; - - spin_lock_irqsave(&chan->vc.lock, flags); - - vdesc = vchan_find_desc(&chan->vc, cookie); - if (vdesc) { - desc = vd_to_axi_desc(vdesc); - } else if (chan->desc && chan->desc->vd.tx.cookie == cookie) { - desc = chan->desc; - } - - if (desc) { - length = desc->length; - completed_blocks = desc->completed_blocks; - len = desc->hw_desc[0].len; - completed_length = completed_blocks * len; - bytes = length - completed_length; - } - - spin_unlock_irqrestore(&chan->vc.lock, flags); - dma_set_residue(txstate, bytes); - - return status; -} - static void write_desc_llp(struct axi_dma_hw_desc *desc, dma_addr_t adr) { desc->lli->llp = cpu_to_le64(adr); @@ -1173,6 +1131,48 @@ static irqreturn_t dw_axi_dma_ch_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } +static enum dma_status +dma_chan_tx_status(struct dma_chan *dchan, dma_cookie_t cookie, + struct dma_tx_state *txstate) +{ + struct axi_dma_chan *chan = dchan_to_axi_dma_chan(dchan); + struct axi_dma_desc *desc = NULL; + struct virt_dma_desc *vdesc; + enum dma_status status; + u32 completed_length; + unsigned long flags; + u32 completed_blocks; + size_t bytes = 0; + u32 length; + u32 len; + + status = dma_cookie_status(dchan, cookie, txstate); + if (status == DMA_COMPLETE || !txstate) + return status; + + spin_lock_irqsave(&chan->vc.lock, flags); + + vdesc = vchan_find_desc(&chan->vc, cookie); + if (vdesc) { + desc = vd_to_axi_desc(vdesc); + } else if (chan->desc && chan->desc->vd.tx.cookie == cookie) { + desc = chan->desc; + } + + if (desc) { + length = desc->length; + completed_blocks = desc->completed_blocks; + len = desc->hw_desc[0].len; + completed_length = completed_blocks * len; + bytes = length - completed_length; + } + + spin_unlock_irqrestore(&chan->vc.lock, flags); + dma_set_residue(txstate, bytes); + + return status; +} + static int dma_chan_terminate_all(struct dma_chan *dchan) { struct axi_dma_chan *chan = dchan_to_axi_dma_chan(dchan); -- 2.40.0