From patchwork Tue Jun 21 07:35:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 9189937 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 5CB2E6075A for ; Tue, 21 Jun 2016 08:55:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CD1D27F8E for ; Tue, 21 Jun 2016 08:55:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4158027FBE; Tue, 21 Jun 2016 08:55:35 +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=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 6C98127FA3 for ; Tue, 21 Jun 2016 08:55:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752035AbcFUIz0 (ORCPT ); Tue, 21 Jun 2016 04:55:26 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:14352 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751123AbcFUIzU convert rfc822-to-8bit (ORCPT ); Tue, 21 Jun 2016 04:55:20 -0400 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie2.idc.renesas.com with ESMTP; 21 Jun 2016 16:35:59 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id E8D104E381; Tue, 21 Jun 2016 16:35:59 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id D981D2806F; Tue, 21 Jun 2016 16:35:59 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id D3B232806D; Tue, 21 Jun 2016 16:35:59 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac2.idc.renesas.com with ESMTP id SAB27201; Tue, 21 Jun 2016 16:35:59 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'208";a="213428369" Received: from mail-pu1apc01lp0015.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.15]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 21 Jun 2016 16:35:58 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=rH3amKT3opeBb1O3HHlUTZ7CboqI4HMIDvdCpi0M0+c=; b=msBYwHGEZDGZ3Njhd7DGiqwEciSObWbgB+E2DNjDPkcLwLDOerzcT0DIUQQa5VpdpY48nO+h2I/E1LiyoUZe/DQaAm9DZdDxFewrTxs4qJtMBYbkjxC/UkCO8JR0pys1ltfOzhMlxGJHBYtiOXSCyHpiAJpfJEafcKEYkpDlnj4= Received: from SG2PR06MB0919.apcprd06.prod.outlook.com (10.162.204.152) by SG2PR06MB0918.apcprd06.prod.outlook.com (10.162.201.158) with Microsoft SMTP Server (TLS) id 15.1.523.12; Tue, 21 Jun 2016 07:35:57 +0000 Received: from SG2PR06MB0919.apcprd06.prod.outlook.com ([10.162.204.152]) by SG2PR06MB0919.apcprd06.prod.outlook.com ([10.162.204.152]) with mapi id 15.01.0523.015; Tue, 21 Jun 2016 07:35:57 +0000 From: Yoshihiro Shimoda To: Geert Uytterhoeven CC: "linux-serial@vger.kernel.org" , "linux-renesas-soc@vger.kernel.org" , "Greg Kroah-Hartman" , Jiri Slaby , Magnus Damm Subject: RE: [PATCH 2/4] serial: sh-sci: Stop transfers in sci_shutdown() Thread-Topic: [PATCH 2/4] serial: sh-sci: Stop transfers in sci_shutdown() Thread-Index: AQHRt3satS1b2wwZ6EGA/7C0iQwjpJ/zrG7w Date: Tue, 21 Jun 2016 07:35:57 +0000 Message-ID: References: <1464286718-10745-1-git-send-email-geert+renesas@glider.be> <1464286718-10745-3-git-send-email-geert+renesas@glider.be> In-Reply-To: <1464286718-10745-3-git-send-email-geert+renesas@glider.be> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=yoshihiro.shimoda.uh@renesas.com; x-originating-ip: [211.11.155.144] x-ms-office365-filtering-correlation-id: 398bd724-6578-4b1f-a58b-08d399a6af4d x-microsoft-exchange-diagnostics: 1; SG2PR06MB0918; 20:pgAUEZs+NPsj1ucFQCSX1G+lKRJNhObpCH+HFbHt3Y7dhVYaQBck73R9hKDzJuxX2Ba/6NmPBB7RFvdeH/7Ld9hWnuqUqJaaX0yhcv5GWwIrcO/Bf1+iZiWNPnc7K5MLRePxdQDHoPNU/6Tdn4ULi9sAXRj+nmWRz0+imwCE84c= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SG2PR06MB0918; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:SG2PR06MB0918; BCL:0; PCL:0; RULEID:; SRVR:SG2PR06MB0918; x-forefront-prvs: 098076C36C x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(7916002)(377454003)(199003)(69234005)(189002)(9686002)(110136002)(54356999)(586003)(76176999)(77096005)(101416001)(92566002)(68736007)(10400500002)(11100500001)(8936002)(50986999)(87936001)(66066001)(7846002)(189998001)(86362001)(97736004)(8676002)(81166006)(105586002)(106116001)(81156014)(106356001)(3280700002)(2900100001)(102836003)(3660700001)(76576001)(74316001)(122556002)(4326007)(2906002)(5002640100001)(3846002)(6116002)(19580405001)(33656002)(217423001)(2950100001)(7696003)(7736002)(5003600100003)(19580395003); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR06MB0918; H:SG2PR06MB0919.apcprd06.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jun 2016 07:35:57.2032 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB0918 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 Hi, Geert-san, > From: Geert Uytterhoeven > Sent: Friday, May 27, 2016 3:19 AM > > 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 > --- > 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, If we write zero to the register, we cannot use the port as a console after it is called. In fact, I have an issue while rc scripts are running on my root filesystem. When rc scripts is running, "shutdown" is called a lot. After the "shutdown", if the kernel will put strings using a console, it cannot put strings because the register is zero (TE and CKE are 0). So, we have to consider it. FYI, I made a patch to fix this issue. (Perhaps, both the CKE and TE should be set in the serial_console_write(), but I don't know how to set the CKE for now :) ) Best regards, Yoshihiro Shimoda diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index afa25ec..b5b1b38 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -1989,6 +1989,7 @@ static void sci_shutdown(struct uart_port *port) { struct sci_port *s = to_sci_port(port); unsigned long flags; + unsigned int ctrl; dev_dbg(port->dev, "%s(%d)\n", __func__, port->line); @@ -1998,8 +1999,12 @@ static void sci_shutdown(struct uart_port *port) spin_lock_irqsave(&port->lock, flags); sci_stop_rx(port); sci_stop_tx(port); - /* Stop RX and TX, disable related interrupts */ - serial_port_out(port, SCSCR, 0); + /* Stop RX and TX, disable related interrupts, keep clock source */ + ctrl = serial_port_in(port, SCSCR); + ctrl = (s->cfg->scscr & ~(SCSCR_CKE1 | SCSCR_CKE0)) | + (ctrl & (SCSCR_CKE1 | SCSCR_CKE0)); + serial_port_out(port, SCSCR, ctrl); + spin_unlock_irqrestore(&port->lock, flags); #ifdef CONFIG_SERIAL_SH_SCI_DMA @@ -2801,6 +2806,8 @@ static void serial_console_write(struct console *co, const char *s, ctrl = serial_port_in(port, SCSCR); ctrl_temp = (sci_port->cfg->scscr & ~(SCSCR_CKE1 | SCSCR_CKE0)) | (ctrl & (SCSCR_CKE1 | SCSCR_CKE0)); + ctrl_temp |= SCSCR_TE; /* FIXME: while "break ctl" is on */ + serial_port_out(port, SCSCR, ctrl_temp); uart_console_write(port, s, count, serial_console_putchar);