From patchwork Tue Nov 6 05:01:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 10669635 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1315E1709 for ; Tue, 6 Nov 2018 05:02:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 036D929B9F for ; Tue, 6 Nov 2018 05:02:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC1F82A0A7; Tue, 6 Nov 2018 05:02:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91AE429B9F for ; Tue, 6 Nov 2018 05:02:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729728AbeKFOZ2 (ORCPT ); Tue, 6 Nov 2018 09:25:28 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:33307 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729622AbeKFOZ2 (ORCPT ); Tue, 6 Nov 2018 09:25:28 -0500 Received: by mail-pg1-f194.google.com with SMTP id q5-v6so5272085pgv.0 for ; Mon, 05 Nov 2018 21:02:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=sy/AQFQMaVt4C0zh+b0IOP8wDwMdYLhdTc2K4kZ/W/E=; b=S+YCR0NnfFkn0XSpoQbyn6N99EvfFcVtcsSNDeAqW3vUoxp81iTMd1XtpDF7USkANh fQM8DVG9Tye6T7w6cM1dn1glzsTnzrBFDQf+ScM5967tKT+c70ssVf0jjbR1WVrUvEUs CMboNPqZTUpwKgFrOPswpHOLTZL2fO2HKt2p0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=sy/AQFQMaVt4C0zh+b0IOP8wDwMdYLhdTc2K4kZ/W/E=; b=NzFqcyEGHBz6yWUeLaI/f2lSpXFb2KjnJ7A4tDQw2RCbzHe/uiI628xpeVs+VAplA7 +M6n4OWqXSE5UwsMKC8jzTN7mBMCU5z6SnUVsIfK5m9q2NcVu71noeAT5rQ4VthqH22g 3Yp8FvXSAfl6rWONpa2qDS+ObAmAFMKfONINJVJnFxQbOpwvTvaWOtbsnp9ilGRFiIh3 18XCHD/iPFF1qTGoe63EYRwuY6HCCv+Q35HWTBPo2HSnFc/GRF+s1J/kesB+5KGAk/4S ihLUvxIDexudcDup5ZGjGRzPuZaKUwIT2lqhDyCybae8O6A0PXeOxZpWZVpD4aGZEuwu 0z1w== X-Gm-Message-State: AGRZ1gKrCTYjWkkfYXrMHsm5odSYjnX0hQM6Fmx5gbvzP6BNrJUfgqBe l1YWShr2MqDPKBtGsj+oEGkMUA== X-Google-Smtp-Source: AJdET5cwk/YCksbb909uu3cC0k5TcdMMTZ2UgY9k6BaXQojLaPNo8OqbMpSlPi+QPNKUZWBHQRoFhQ== X-Received: by 2002:a63:2e02:: with SMTP id u2mr2621110pgu.9.1541480525976; Mon, 05 Nov 2018 21:02:05 -0800 (PST) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id o7-v6sm55735416pfb.23.2018.11.05.21.02.03 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Nov 2018 21:02:05 -0800 (PST) From: Baolin Wang To: dan.j.williams@intel.com, vkoul@kernel.org, eric.long@unisoc.com Cc: broonie@kernel.org, baolin.wang@linaro.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RESEND PATCH 2/7] dmaengine: sprd: Get transfer residue depending on the transfer direction Date: Tue, 6 Nov 2018 13:01:32 +0800 Message-Id: <2968b6dce6864608b97391e5b86ee3c47e3fb8e6.1541480353.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Long Add one field to save the transfer direction for struct sprd_dma_desc, which is used to get correct transfer residue depending on the transfer direction. [Baolin Wang adds one field to present the transfer direction] Signed-off-by: Eric Long Signed-off-by: Baolin Wang --- drivers/dma/sprd-dma.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c index c226dc93..4f3587b 100644 --- a/drivers/dma/sprd-dma.c +++ b/drivers/dma/sprd-dma.c @@ -159,6 +159,7 @@ struct sprd_dma_chn_hw { struct sprd_dma_desc { struct virt_dma_desc vd; struct sprd_dma_chn_hw chn_hw; + enum dma_transfer_direction dir; }; /* dma channel description */ @@ -331,6 +332,17 @@ static void sprd_dma_stop_and_disable(struct sprd_dma_chn *schan) sprd_dma_disable_chn(schan); } +static unsigned long sprd_dma_get_src_addr(struct sprd_dma_chn *schan) +{ + unsigned long addr, addr_high; + + addr = readl(schan->chn_base + SPRD_DMA_CHN_SRC_ADDR); + addr_high = readl(schan->chn_base + SPRD_DMA_CHN_WARP_PTR) & + SPRD_DMA_HIGH_ADDR_MASK; + + return addr | (addr_high << SPRD_DMA_HIGH_ADDR_OFFSET); +} + static unsigned long sprd_dma_get_dst_addr(struct sprd_dma_chn *schan) { unsigned long addr, addr_high; @@ -534,7 +546,12 @@ static enum dma_status sprd_dma_tx_status(struct dma_chan *chan, else pos = 0; } else if (schan->cur_desc && schan->cur_desc->vd.tx.cookie == cookie) { - pos = sprd_dma_get_dst_addr(schan); + struct sprd_dma_desc *sdesc = to_sprd_dma_desc(vd); + + if (sdesc->dir == DMA_DEV_TO_MEM) + pos = sprd_dma_get_dst_addr(schan); + else + pos = sprd_dma_get_src_addr(schan); } else { pos = 0; } @@ -804,6 +821,8 @@ static int sprd_dma_fill_linklist_desc(struct dma_chan *chan, if (!sdesc) return NULL; + sdesc->dir = dir; + for_each_sg(sgl, sg, sglen, i) { len = sg_dma_len(sg);