From patchwork Sat Sep 29 05:49:00 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: 147816 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1575277lji; Fri, 28 Sep 2018 22:50:13 -0700 (PDT) X-Google-Smtp-Source: ACcGV61p+0GJifXRjPd3uB33I6Sv378rz02MtwMPJLr75yPz+ZpvaCCV52b8ZHikvTbMInQdU52G X-Received: by 2002:a17:902:7084:: with SMTP id z4-v6mr1724838plk.236.1538200213311; Fri, 28 Sep 2018 22:50:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538200213; cv=none; d=google.com; s=arc-20160816; b=imtyIROVU4sq3l3QbvF3c0ry6Vc9VUJtmFb/h2V+KX2UbnMLB8j4gHt+iz37AEDZjS 6a1J+F/WZTEfPXG3awZx1R65Q8BGT6C7kFjjCQSUhG6+9uOUCH1fm5AGuMewfk50jiaW CqVaKv43CewN5t0hkc0toJnzHNWD/skRUWnCrRue00Y5MxLJFxLiEDeIQYSMSVYHyeQ9 CBZRKIsfx6wHuNekmllfq0xOBjHDVLJRTvadojUjXc3O1H5wYZc/lhdJfGF1urc35Gh0 6qdfqBn6gxWCxVJg6YCE4LBwzxmJLx60jCPyR/1piywlvJNSDFcTzXhJbR3MRKQ167EM xMXA== 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=PoUMqKpsWCUry6DCL5qHUmcGgnxm9aVrd5TpNU55eN4Os0IAZmeg9JuE4HiS6x8Sk1 z1oe5FeZ5twuW62WJB0g5YLyZad15F24NE1Jt5yCCtAj8UJkIZMnPddrt7pMgD/lkHlT hzAP9D0OugJFju6LnJrZVhiffU48/iu2mgL8hgvGh5oU2FUUfDoJmf/ArH87MSo+ByK8 mM588Y54B3nFWQrF7Tls9joU40747ZY/QJuf+zs4lhEBafjsY1zwL8t8B4MySjYs2gi3 X0lP2i/ylzrECeWz9HwfYsHTZNHKGn6qhQMxctzOCM42NHBVU+NGdxnx7l6hlskT+wsY 4lNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZkhC3ycx; 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 d36-v6si6848259pla.446.2018.09.28.22.50.12; Fri, 28 Sep 2018 22:50:13 -0700 (PDT) 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=ZkhC3ycx; 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 S1727526AbeI2MRK (ORCPT + 32 others); Sat, 29 Sep 2018 08:17:10 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34331 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727505AbeI2MRJ (ORCPT ); Sat, 29 Sep 2018 08:17:09 -0400 Received: by mail-pf1-f196.google.com with SMTP id k19-v6so5687662pfi.1 for ; Fri, 28 Sep 2018 22:50:05 -0700 (PDT) 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=ZkhC3ycxpJc5Fbohpuuz/zGXQ4Lg5WaCwHn4bHPoSg9nAEJ4BLLLxDNL3mgbp45CDA hG43S+7ghflX3AsBUKVTsEb8rQlc0Ca8dAvxi0G6+arKBMtT/7gjUddGLZOygut7Z9Kc KTZvD8bUAlkWMdGPY06KOAbZ1npPXRk3ssn38= 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=rhnMeXdpv0CK8qNMJ/nv/nB3k4RualhYyUyZyEjBWfRMAOlC1f+r/6ulVTQh7h505/ YQ7UJ42megelIHZkG8/FgWNpg9GOOCgNCKJ2lG2vUyoD0PERimUo2XR9wEGpSxbKFbLb LpcctlKMqzEtCqZk6JrWcTGN6+YfYushzl1ALfTwjil7F7sajHTKP4kRHEblXNeP/c2T eLnyf3ME6vxk6p1W8yz27d9DsCBk6KPp/AY7u78GFyBpsxoAFClFDG+UXl1XBfFl2iq8 N5q1DBwkdeQNMgryy9VDZlQTqKu6+pymw+w7dGCUh62qZchDKUpgN9CugQ82xrHgU+n5 pbNQ== X-Gm-Message-State: ABuFfohsPvLZobImsIc4T44/rWc04kb5UHm9lrLxZRI0vhvh5GhcgSLa wfRlqyO3QbSZIzkYmSYYIC0gCg== X-Received: by 2002:a65:4103:: with SMTP id w3-v6mr1605709pgp.284.1538200205296; Fri, 28 Sep 2018 22:50:05 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id i80-v6sm11118049pfi.87.2018.09.28.22.50.02 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Sep 2018 22:50:04 -0700 (PDT) From: Baolin Wang To: dan.j.williams@intel.com, vkoul@kernel.org, eric.long@spreadtrum.com Cc: broonie@kernel.org, baolin.wang@linaro.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/7] dmaengine: sprd: Get transfer residue depending on the transfer direction Date: Sat, 29 Sep 2018 13:49:00 +0800 Message-Id: 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);