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: 10620639 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 1E68D15A6 for ; Sat, 29 Sep 2018 05:50:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 115EF29CEB for ; Sat, 29 Sep 2018 05:50:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 05F422AFF5; Sat, 29 Sep 2018 05:50:40 +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 A35CA29CEB for ; Sat, 29 Sep 2018 05:50:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727510AbeI2MRK (ORCPT ); Sat, 29 Sep 2018 08:17:10 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:36540 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727504AbeI2MRJ (ORCPT ); Sat, 29 Sep 2018 08:17:09 -0400 Received: by mail-pf1-f196.google.com with SMTP id b7-v6so5679121pfo.3 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=BV58EQopIO1faZWLdqFpltkhhoPp7jPjjXb4QoeJqIfThtdZrvwn2OS+8vNjpTn8JD VfCbAfHaN3gWFg2pm6w2fMyyPcky/vq6Ux9bWWxN9dTcx/K8KU//LIyT0/65j/X+lW0I /Ho6sRBjOErniMTou0blYc0d6CrDM+VFSHZ6VQkbvGgwAx+i6qy6QTbG8N2XLWP8E7JS VFmotphZ/9RuTEAwrwW5QZ7o3CLss2Z+dZi5wxpqdL+GVgtSJyOYInyA9l7qeRXmspL9 mu8U2heFJ1Qv6f0VOpOVK6ax0BPx7mYMjun6klYVuYdRHkLpqCsH+YluGPjIhMAKfqok t7Zg== X-Gm-Message-State: ABuFfoi2WnKUejbe813gHY0kCsJ6vKA69ww0mQFLPz4BB4Q423+ZhuXW qGhj8Efv2QRiSYrleYGPo26XqQ== X-Google-Smtp-Source: ACcGV61H2D7d5k5Fc0OMSlKEzKUBkYWrjRVkBZk07K+oMTolCSBlzqEtxXZFqnm9aUcmE00wgRgyHg== 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: 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);