From patchwork Tue May 17 03:48:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 9108691 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2F73CBF29F for ; Tue, 17 May 2016 03:51:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1A07920268 for ; Tue, 17 May 2016 03:51:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4018D201B9 for ; Tue, 17 May 2016 03:51:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755278AbcEQDvd (ORCPT ); Mon, 16 May 2016 23:51:33 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:38226 "EHLO relay1.mentorg.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754802AbcEQDs6 (ORCPT ); Mon, 16 May 2016 23:48:58 -0400 Received: from svr-orw-fem-05.mgc.mentorg.com ([147.34.97.43]) by relay1.mentorg.com with esmtp id 1b2W09-0004wW-Fz from Jiada_Wang@mentor.com ; Mon, 16 May 2016 20:48:57 -0700 Received: from jiwang-OptiPlex-980.tokyo.mentorg.com (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.3.224.2; Mon, 16 May 2016 20:48:57 -0700 From: Jiada Wang To: , CC: , , , , , Subject: [PATCH 01/10] dma: imx-sdma: use chn_real_count to report residue for UART Date: Tue, 17 May 2016 12:48:47 +0900 Message-ID: <1463456936-10634-2-git-send-email-jiada_wang@mentor.com> X-Mailer: git-send-email 2.4.5 In-Reply-To: <1463456936-10634-1-git-send-email-jiada_wang@mentor.com> References: <1463456936-10634-1-git-send-email-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For uart rx dma data may not receive fully, so the number of data read by sdma script once isn't always equal to period_len, thus residue returned from sdma_tx_status() isn't valid for uart rx dma. The old way to use chn_real_count to report residue should be used for uart rx dma. Signed-off-by: Jiada Wang --- drivers/dma/imx-sdma.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 0f6fd42..1f1b64b 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -680,6 +680,11 @@ static void sdma_update_channel_loop(struct sdma_channel *sdmac) bd->mode.status |= BD_DONE; sdmac->buf_tail++; sdmac->buf_tail %= sdmac->num_bd; + if (sdmac->peripheral_type == IMX_DMATYPE_UART) { + /* restore mode.count after counter readed */ + sdmac->chn_real_count = bd->mode.count; + bd->mode.count = sdmac->chn_count; + } } } @@ -1285,6 +1290,9 @@ static struct dma_async_tx_descriptor *sdma_prep_dma_cyclic( goto err_out; } + if (sdmac->peripheral_type == IMX_DMATYPE_UART) + sdmac->chn_count = period_len; + while (buf < buf_len) { struct sdma_buffer_descriptor *bd = &sdmac->bd[i]; int param; @@ -1361,7 +1369,8 @@ static enum dma_status sdma_tx_status(struct dma_chan *chan, struct sdma_channel *sdmac = to_sdma_chan(chan); u32 residue; - if (sdmac->flags & IMX_DMA_SG_LOOP) + if ((sdmac->flags & IMX_DMA_SG_LOOP) && + (sdmac->peripheral_type != IMX_DMATYPE_UART)) residue = (sdmac->num_bd - sdmac->buf_tail) * sdmac->period_len; else residue = sdmac->chn_count - sdmac->chn_real_count;