Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp1673144rwe; Sat, 15 Apr 2023 04:04:39 -0700 (PDT) X-Google-Smtp-Source: AKy350Zmf/RXYgRQqvcIHQIbxlhzpdWvE1uNy6RyG+tkfsTk8eJ+N+1qiuJaJGrh8s0zOJQmzHrr X-Received: by 2002:a05:6808:2446:b0:389:9176:cbe5 with SMTP id bw6-20020a056808244600b003899176cbe5mr6349988oib.24.1681556679294; Sat, 15 Apr 2023 04:04:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681556679; cv=none; d=google.com; s=arc-20160816; b=0pPaszO2qPIDJfrLVQfEaG4oeECYcVpPBccTji73bHoSkO0YpKfucR4tDnvAa1b6V0 tHVCwf21tqFXZEYzo+xEwe6oj6fBCRIMlN4yNWqPbiwSdfyFjtwhshM5MgFoG9tvRmjZ S3JtoOd5ca/DttyF/Tv41Iq4zpKXOGCA3AkAMV8ZgkYCLJxjv97bbvNTKwj4edf51u1B m5Z4YETT7kkm3LB72Bd7BDV4Nco2o4KEdTnAcfxxV0ul8RoPRtHA3AMgsGg01CabDxN6 KQuioezT2HV0a526XmwGZmKDi5Kqlgn2+QeUEZxuO7MK1o5Ek+YwKTlMSHNxvoqGD6gW bgAA== 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=VzO7Iwj9jaFnR9jpFAlcL6VK7ZIXRZzCKjaEAzg80q4=; b=k//HIKB6X8xlAT6vpyvW9O6lnvlnF+DIdYEsjAoVtR5WqMFR6+BkE+C+54w7lj+fLk j+dkorJbqgmmjzrSx51JnGC1Ju5Unte68lMri4jbIBcvkwtIey/3aejhpXlDmQVsT+iC 6sipZPbiJ+AFnqnThK8tPmBmdKPM1+c3eJU2V5Lzn4Sbq9E7s42uDkdqBqBzRDTK6XLj Hw1DT2t2EuAa7TNNIj/v/1HjpVd6e1LAtuIJPmz9jLyv5ZkfOkuAetEAMsU23Z/8rgXO PPMq/5w0bjTLWdzedLEqAMRpcJ/OReinJzPLAHR5LP/PjnHtcrjNipaRdoTIRX24u/Cd UHmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oXv9uxLo; 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 z8-20020a056808028800b0037faf33366asi5658114oic.245.2023.04.15.04.04.25; Sat, 15 Apr 2023 04:04:39 -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=oXv9uxLo; 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 S229967AbjDOKuH (ORCPT + 99 others); Sat, 15 Apr 2023 06:50:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230477AbjDOKts (ORCPT ); Sat, 15 Apr 2023 06:49:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA3D0AD38; Sat, 15 Apr 2023 03:49:16 -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 0CA8E6181A; Sat, 15 Apr 2023 10:47:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C736C433A0; Sat, 15 Apr 2023 10:47:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681555630; bh=iP3PWNMb+3tRizoMnR4yxUHqhZ9zp9+fFtQ/nNwpumk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oXv9uxLoVAr5ls6Itb9ugVt6EB+K6BCBXT7RN0PxBJLTg+66ybFQQ1jFYQ1TO0/MM omLfs4DzjLDpB2WoqGB3JnobfDeKTy550Oe/j2+UwSd3I91k7w0rESggsyZ4MnmlP+ PA2fUX9pcdhwYvkcfBNEH5oipviz2Co8/7FGQyC9bggD6eWcfDp/sANzoYMaeStURO 1dya3nwzGf4S82qColc98e+f2n9pYmYmgqFce2u19PJTKaQT91cnlJuYwXV4BPq+Ic mxEIuZWj9025ERpBEGYoC4qwVOjn0uU1aiiO5NbgKqdnhpbPzErEIWoweE8VDMc1VW iL4C1FayMlZXQ== From: Jisheng Zhang To: Eugeniy Paltsev , Vinod Koul Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 10/11] dmaengine: dw-axi-dmac: move dma_chan_tx_status() Date: Sat, 15 Apr 2023 18:36:00 +0800 Message-Id: <20230415103601.2979-11-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230415103601.2979-1-jszhang@kernel.org> References: <20230415103601.2979-1-jszhang@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 1c1b9574985a..1d00793a83bf 100644 --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c @@ -300,48 +300,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); @@ -1166,6 +1124,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.39.2