From patchwork Fri Jun 24 14:59:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 9197729 X-Patchwork-Delegate: geert@linux-m68k.org 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 0124960871 for ; Fri, 24 Jun 2016 14:59:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5DA2283E5 for ; Fri, 24 Jun 2016 14:59:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA8B1284B3; Fri, 24 Jun 2016 14:59:23 +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=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 81F6F28493 for ; Fri, 24 Jun 2016 14:59:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751098AbcFXO7W (ORCPT ); Fri, 24 Jun 2016 10:59:22 -0400 Received: from baptiste.telenet-ops.be ([195.130.132.51]:48256 "EHLO baptiste.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751025AbcFXO7V (ORCPT ); Fri, 24 Jun 2016 10:59:21 -0400 Received: from ayla.of.borg ([84.195.107.21]) by baptiste.telenet-ops.be with bizsmtp id AezJ1t0090TjorY01ezJvH; Fri, 24 Jun 2016 16:59:19 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1bGSZi-0003Vr-5k; Fri, 24 Jun 2016 16:59:18 +0200 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1bGSZj-0003IP-1t; Fri, 24 Jun 2016 16:59:19 +0200 From: Geert Uytterhoeven To: Greg Kroah-Hartman , Jiri Slaby Cc: Magnus Damm , Yoshihiro Shimoda , linux-serial@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-sh@vger.kernel.org, uclinux-h8-devel@lists.sourceforge.jp, Geert Uytterhoeven Subject: [PATCH v2 2/4] serial: sh-sci: Stop transfers in sci_shutdown() Date: Fri, 24 Jun 2016 16:59:14 +0200 Message-Id: <1466780356-12623-3-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1466780356-12623-1-git-send-email-geert+renesas@glider.be> References: <1466780356-12623-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 Make sure the transmitter and receiver are stopped when shutting down the port, and related interrupts are disabled. Without this: - New input data may be received into the RX FIFO, possibly triggering a new RX DMA completion, - Transfers will still be enabled on a subsequent startup of the UART, before the UART's FIFOs have been reset, causing reading of stale data. Inspired by a patch in the BSP by Koji Matsuoka . Signed-off-by: Geert Uytterhoeven --- v2: - Do not clear clock source bits, since the serial console relies on them, as reported by Shimoda-san. v1 was extracted from "[PATCH/RFC v3 0/4] serial: sh-sci: Add DT DMA support". The issues with the serial console seen before on r8a7740/armadillo and sh73a0/kzm9g seem to be gone. Changes after resurrection: - Write zero to also disable related interrupts, as suggested by Laurent Pinchart, - Enhanced patch description. --- drivers/tty/serial/sh-sci.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index d6ba90c572f7475c..eecace576c3b758f 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1890,12 +1890,17 @@ static void sci_shutdown(struct uart_port *port) { struct sci_port *s = to_sci_port(port); unsigned long flags; + u16 scr; dev_dbg(port->dev, "%s(%d)\n", __func__, port->line); spin_lock_irqsave(&port->lock, flags); sci_stop_rx(port); sci_stop_tx(port); + /* Stop RX and TX, disable related interrupts, keep clock source */ + scr = serial_port_in(port, SCSCR); + serial_port_out(port, SCSCR, scr & (SCSCR_CKE1 | SCSCR_CKE0)); + spin_unlock_irqrestore(&port->lock, flags); #ifdef CONFIG_SERIAL_SH_SCI_DMA