From patchwork Fri Sep 18 11:08:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 7215171 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F229C9F32B for ; Fri, 18 Sep 2015 11:08:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 06D6920961 for ; Fri, 18 Sep 2015 11:08:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 246042095E for ; Fri, 18 Sep 2015 11:08:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753608AbbIRLIq (ORCPT ); Fri, 18 Sep 2015 07:08:46 -0400 Received: from michel.telenet-ops.be ([195.130.137.88]:42447 "EHLO michel.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753589AbbIRLIl (ORCPT ); Fri, 18 Sep 2015 07:08:41 -0400 Received: from ayla.of.borg ([84.195.106.123]) by michel.telenet-ops.be with bizsmtp id Jb8Y1r00p2fm56U06b8Y1t; Fri, 18 Sep 2015 13:08:39 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1ZctWq-0001Vu-GT; Fri, 18 Sep 2015 13:08:32 +0200 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1ZctWx-0005OW-4J; Fri, 18 Sep 2015 13:08:39 +0200 From: Geert Uytterhoeven To: Greg Kroah-Hartman , Jiri Slaby Cc: Muhammad Hamza Farooq , Magnus Damm , Yoshihiro Shimoda , Laurent Pinchart , Nobuhiro Iwamatsu , Yoshihiro Kaneko , Kazuya Mizuguchi , Koji Matsuoka , Wolfram Sang , Guennadi Liakhovetski , linux-serial@vger.kernel.org, linux-sh@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v4 09/10] serial: sh-sci: Pause DMA engine and get DMA status again Date: Fri, 18 Sep 2015 13:08:32 +0200 Message-Id: <1442574513-20648-10-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1442574513-20648-1-git-send-email-geert+renesas@glider.be> References: <1442574513-20648-1-git-send-email-geert+renesas@glider.be> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 From: Muhammad Hamza Farooq Occasionally, DMA transaction completes _after_ DMA engine is stopped. Verify if the transaction has not finished before forcing the engine to stop and push the data Signed-off-by: Muhammad Hamza Farooq Signed-off-by: Geert Uytterhoeven --- v4: - New. --- drivers/tty/serial/sh-sci.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 9406fe227bc76c96..b1d1ce1986e6c064 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1277,6 +1277,7 @@ static bool filter(struct dma_chan *chan, void *slave) static void rx_timer_fn(unsigned long arg) { struct sci_port *s = (struct sci_port *)arg; + struct dma_chan *chan = s->chan_rx; struct uart_port *port = &s->port; struct dma_tx_state state; enum dma_status status; @@ -1305,6 +1306,21 @@ static void rx_timer_fn(unsigned long arg) return; } + dmaengine_pause(chan); + + /* + * sometimes DMA transfer doesn't stop even if it is stopped and + * data keeps on coming until transaction is complete so check + * for DMA_COMPLETE again + * Let packet complete handler take care of the packet + */ + status = dmaengine_tx_status(s->chan_rx, s->active_rx, &state); + if (status == DMA_COMPLETE) { + spin_unlock_irqrestore(&port->lock, flags); + dev_dbg(port->dev, "Transaction complete after DMA engine was stopped"); + return; + } + /* Handle incomplete DMA receive */ dmaengine_terminate_all(s->chan_rx); read = sg_dma_len(&s->sg_rx[active]) - state.residue;