From patchwork Fri Dec 2 12:35:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 9458347 X-Patchwork-Delegate: horms@verge.net.au 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 7459960756 for ; Fri, 2 Dec 2016 12:36:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 675592852B for ; Fri, 2 Dec 2016 12:36:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C28B2853F; Fri, 2 Dec 2016 12:36:00 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 130832853D for ; Fri, 2 Dec 2016 12:36:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759658AbcLBMfk (ORCPT ); Fri, 2 Dec 2016 07:35:40 -0500 Received: from baptiste.telenet-ops.be ([195.130.132.51]:50228 "EHLO baptiste.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758494AbcLBMfT (ORCPT ); Fri, 2 Dec 2016 07:35:19 -0500 Received: from ayla.of.borg ([84.193.137.253]) by baptiste.telenet-ops.be with bizsmtp id F0bD1u00g5UCtCs010bDlf; Fri, 02 Dec 2016 13:35:17 +0100 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1cCn3Z-0005JP-L1; Fri, 02 Dec 2016 13:35:13 +0100 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1cCn3d-0002Qg-DJ; Fri, 02 Dec 2016 13:35:17 +0100 From: Geert Uytterhoeven To: Greg Kroah-Hartman , Jiri Slaby Cc: Yoshihiro Shimoda , Wolfram Sang , Christoph Baumann , linux-serial@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 1/2] serial: sh-sci: Fix early deassertion of dedicated RTS Date: Fri, 2 Dec 2016 13:35:10 +0100 Message-Id: <1480682111-9299-2-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1480682111-9299-1-git-send-email-geert+renesas@glider.be> References: <1480682111-9299-1-git-send-email-geert+renesas@glider.be> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If a UART has dedicated RTS/CTS pins, there are some issues: 1. When changing hardware control flow, the new AUTORTS state is not immediately reflected in the hardware, but only when RTS is raised. However, the serial core doesn't call .set_mctrl() after .set_termios(), hence AUTORTS may only become effective when the port is closed, and reopened later. Note that this problem does not happen when manually using stty to change CRTSCTS, as AUTORTS will work fine on next open. 2. When hardware control flow is disabled (or AUTORTS is not yet effective), changing any serial port configuration deasserts RTS, as .set_termios() calls sci_init_pins(). To fix both issues, call .set_mctrl() from .set_termios() when dedicated RTS/CTS pins are present, to refresh the AUTORTS or RTS state. This is similar to what other drivers supporting AUTORTS do (e.g. omap-serial). Reported-by: Baumann, Christoph (C.) (issue 1) Fixes: 33f50ffc253854cf ("serial: sh-sci: Fix support for hardware-assisted RTS/CTS") Signed-off-by: Geert Uytterhoeven --- Tested on r8a7791/koelsch with HSCIF1 (GPIO hardware flow control), and HSCIF2 and SCIFB0 (dedicated hardware flow control). A simple test program (basically "cat" with CRTSCTS configuration capability) can be found at https://github.com/geertu/sercat Without this patch the following will fail: 1. sercat -f /dev/hscif2 & seq 100 120 | sercat -f -w /dev/hscif1 # hangs 2. seq 200 220 | sercat -f -w /dev/hscif2 & sercat -f /dev/hscif1 # no data received --- drivers/tty/serial/sh-sci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 91e7dddbf72cd3de..c503db1900f003ed 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -2340,6 +2340,10 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios, serial_port_out(port, SCFCR, ctrl); } + if (port->flags & UPF_HARD_FLOW) { + /* Refresh (Auto) RTS */ + sci_set_mctrl(port, port->mctrl); + } scr_val |= s->cfg->scscr & ~(SCSCR_CKE1 | SCSCR_CKE0); dev_dbg(port->dev, "SCSCR 0x%x\n", scr_val);