From patchwork Thu Feb 8 12:55:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Raghavendra X-Patchwork-Id: 10207105 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6FA6260327 for ; Thu, 8 Feb 2018 12:56:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60C22294EC for ; Thu, 8 Feb 2018 12:56:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55063294F1; Thu, 8 Feb 2018 12:56:14 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 00B0C294EC for ; Thu, 8 Feb 2018 12:56:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750806AbeBHMzb (ORCPT ); Thu, 8 Feb 2018 07:55:31 -0500 Received: from lelnx193.ext.ti.com ([198.47.27.77]:38768 "EHLO lelnx193.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750847AbeBHMz3 (ORCPT ); Thu, 8 Feb 2018 07:55:29 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id w18CtC4a013090; Thu, 8 Feb 2018 06:55:12 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1518094512; bh=tVWPebkWJNCXOwnb64ailST4EQ0ZqgXXH4w+gt/RuDQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=lFg92sjFwFjJE8J5zWhx624KNBKEp0VGnoHkox2sl7KZSdbrqwqw6LZMhh1+D0Q8/ wPJfMIzJjjUPtC8QONte13Il/ZUrclfnr6BcQ57N5oZDgy1BQwx3VxOHf/nak3WJ88 roDCwbA6vRvkG9OCUBFdXGE5LZ+nfy3N3+qWLyRE= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w18CtClp006529; Thu, 8 Feb 2018 06:55:12 -0600 Received: from DLEE109.ent.ti.com (157.170.170.41) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Thu, 8 Feb 2018 06:55:11 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Thu, 8 Feb 2018 06:55:11 -0600 Received: from a0132425.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w18Ct3K1025596; Thu, 8 Feb 2018 06:55:09 -0600 From: Vignesh R To: Greg Kroah-Hartman CC: Jiri Slaby , Andy Shevchenko , , , , , Vignesh R Subject: [PATCH 2/2] serial: 8250: 8250_omap: Fix throttling when DMA is enabled Date: Thu, 8 Feb 2018 18:25:42 +0530 Message-ID: <20180208125542.15649-3-vigneshr@ti.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180208125542.15649-1-vigneshr@ti.com> References: <20180208125542.15649-1-vigneshr@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP omap_8250_throttle() is called when tty RX buffer is about to overflow and can no longer keep up with the rate at which UART is receiving data. So, the expectation of this callback, is that UART stops RX and asserts HW flow control to signal the sender to stop sending more data. omap_8250_throttle() disables RX FIFO interrupts thus FIFO is no longer serviced, leading to assertion of flow control once RX FIFO is full. But, this does not work when DMA is enabled as driver keeps queuing new RX DMA request in completion handler without brothering about throttling request made by the higher layer. This patch introduces a flag that can be used to determine whether or not to queue next RX DMA request based on throttling request. Without this patch, tty buffer overflows are reported at higher baudrates. Signed-off-by: Vignesh R --- drivers/tty/serial/8250/8250_omap.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c index 57f6eba47f44..624b501fd253 100644 --- a/drivers/tty/serial/8250/8250_omap.c +++ b/drivers/tty/serial/8250/8250_omap.c @@ -114,6 +114,7 @@ struct omap8250_priv { struct uart_8250_dma omap8250_dma; spinlock_t rx_dma_lock; bool rx_dma_broken; + bool throttled; }; #ifdef CONFIG_SERIAL_8250_DMA @@ -692,6 +693,7 @@ static void omap_8250_shutdown(struct uart_port *port) static void omap_8250_throttle(struct uart_port *port) { + struct omap8250_priv *priv = port->private_data; struct uart_8250_port *up = up_to_u8250p(port); unsigned long flags; @@ -700,6 +702,7 @@ static void omap_8250_throttle(struct uart_port *port) spin_lock_irqsave(&port->lock, flags); up->ier &= ~(UART_IER_RLSI | UART_IER_RDI); serial_out(up, UART_IER, up->ier); + priv->throttled = true; spin_unlock_irqrestore(&port->lock, flags); pm_runtime_mark_last_busy(port->dev); @@ -738,12 +741,16 @@ static int omap_8250_rs485_config(struct uart_port *port, static void omap_8250_unthrottle(struct uart_port *port) { + struct omap8250_priv *priv = port->private_data; struct uart_8250_port *up = up_to_u8250p(port); unsigned long flags; pm_runtime_get_sync(port->dev); spin_lock_irqsave(&port->lock, flags); + priv->throttled = false; + if (up->dma) + up->dma->rx_dma(up); up->ier |= UART_IER_RLSI | UART_IER_RDI; serial_out(up, UART_IER, up->ier); spin_unlock_irqrestore(&port->lock, flags); @@ -788,6 +795,7 @@ static void __dma_rx_do_complete(struct uart_8250_port *p) static void __dma_rx_complete(void *param) { struct uart_8250_port *p = param; + struct omap8250_priv *priv = p->port.private_data; struct uart_8250_dma *dma = p->dma; struct dma_tx_state state; unsigned long flags; @@ -805,7 +813,8 @@ static void __dma_rx_complete(void *param) return; } __dma_rx_do_complete(p); - omap_8250_rx_dma(p); + if (!priv->throttled) + omap_8250_rx_dma(p); spin_unlock_irqrestore(&p->port.lock, flags); }