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: 150241 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3458009ljp; Mon, 5 Nov 2018 21:02:13 -0800 (PST) X-Google-Smtp-Source: AJdET5eQB3hamD9z1xX4qcpwX4j1q3JW1bBbrr9ZT0T8FKIp1TqZVZgDuywr9frlYtKcDYJCOKMg X-Received: by 2002:a17:902:650f:: with SMTP id b15-v6mr24658866plk.2.1541480533736; Mon, 05 Nov 2018 21:02:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541480533; cv=none; d=google.com; s=arc-20160816; b=bSdjIuZCTsOnGKQUpWHEsa/LIA3jjPbKcEWZcaIss4RI0fRfHXJkd/0ZBtbS3nKqfs ygo1q8CycFFJjJ8exrQTXx4jQ5iWMSKmynrvNNxNPePk6nTi+YGQf+Lcz5LVUOdck444 SdAY7dDmyQxFX2q+6YRspHBSS0C1kWPiy7HI1/JOaqSBQpmUDvJM1ZEZDwc5NmphHdae FjJuT8PrabUsSROmujpi9ckerPHxKrefL9DoSKqDMleJGOOiHZ0BlnpWP76O8VSUMfVN ZTV8Vvk7VMlNxsgR69TIrS62uFIyDcLp8cVtGFScP5UOctlkbaXjyCNAEMqt6Gbz8CbI gVdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=sy/AQFQMaVt4C0zh+b0IOP8wDwMdYLhdTc2K4kZ/W/E=; b=y/uOX5oU0e31x+oEa2eSLQp3g2kEd1zUq/dlDI66PuWVk8/kVPP6xYAZnCW8D0krcT z5zhBzuKth60/wznfbovHOQxihGahb473xKxKPfQoCjflMyVeJUaKUUqnTh+Wui64zsI vF44naOk7nvtfByNe0VlA44UaBlFVkxyGonnuEye8eMJ+hVOUAZ7i7MmcSEwPf2C2IBR Nr8yda0IxNPIyNLPb7PgnLPs++AOLBDrz7g4JYUql5ygBCwcbP7Pbvg+sYbbgzU9Hh3C vx1k3uQF2r4AjuKgyqQ+VWWDV3S89dF0RwonwKqj/x9BWCqEG8nbFH7ZVQd0yUvfumfr guxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S+YCR0Nn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w7-v6si44787070pgh.131.2018.11.05.21.02.13; Mon, 05 Nov 2018 21:02:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S+YCR0Nn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729791AbeKFOZ2 (ORCPT + 32 others); Tue, 6 Nov 2018 09:25:28 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:36181 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729724AbeKFOZ2 (ORCPT ); Tue, 6 Nov 2018 09:25:28 -0500 Received: by mail-pf1-f195.google.com with SMTP id j22-v6so5539152pfh.3 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=SArCUE3ThS5itLzAb36ySZjK9X2BoVz8ADkinUyDGK07vAYNvWkyjJwO7GWGMjjR9Y uiGOEwCyD1DIrCsKu6naowU3SFLY0/nI3sQEgL7Un4mcC6bvwJH8jK7NUavzVWWhxIkQ 1Hl+THPnKufb9AJrociuiNIzuPkT4wsUrkiy2uWaufB1znlU9/tdpALQE6hFx19M6QU6 aBfc56D4UNMkRC7xNC6XtIu9p1jRIvogwVLDvGRkQegX3X4r0d6hhKOsqgHXLRIWoVVa n7gAEIJ5gu7erGHb3FpoFUJtniBvQTvYzkfErq9H6LZwezJ8EXLEwCUCYFbud08/a2cY gDqw== X-Gm-Message-State: AGRZ1gIE2CbtGV8q4KuAnxe/vz2gTTNHixZpVxDUgSp8pdTKO4HhhccZ sdoNJ1r7Lu8xWQlK6q5YxLP3SA== 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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 1.7.9.5 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);