From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753398AbcEBMZX (ORCPT ); Mon, 2 May 2016 08:25:23 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:55425 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752126AbcEBMZS (ORCPT ); Mon, 2 May 2016 08:25:18 -0400 X-AuditID: cbfec7f5-f792a6d000001302-4f-5727472ac437 From: Krzysztof Kozlowski To: Greg Kroah-Hartman , Jiri Slaby , linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Marek Szyprowski , Chanwoo Choi , stable@vger.kernel.org, Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH stable] serial: samsung: Reorder the sequence of clock control when call s3c24xx_serial_set_termios() Date: Mon, 02 May 2016 14:25:07 +0200 Message-id: <1462191907-27403-1-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgluLIzCtJLcpLzFFi42I5/e/4NV0td/Vwgyfr5Cw2zljPanH9y3NW i+bF69kspmz4wGTx+oWhxeVdc9gszizuZbdYe+Quu8WCjY8YHTg99s9dw+7Rt2UVo8f6LVdZ PD5vkgtgieKySUnNySxLLdK3S+DKeNxtUnBXouL88r3sDYwnRLsYOTkkBEwkWpZsZYWwxSQu 3FvP1sXIxSEksJRR4tTT5VBOI5PEs8uz2ECq2ASMJTYvXwKWEBGYyChx7PA2FhCHWeAGo8TG Y6vYuxg5OIQFyiWeXMkFaWARUJW4t3ERI4jNK+Aucb7jJtQ6OYmTxyazTmDkXsDIsIpRNLU0 uaA4KT3XSK84Mbe4NC9dLzk/dxMjJFy+7mBceszqEKMAB6MSD69Hulq4EGtiWXFl7iFGCQ5m JRHePBf1cCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8M3e9DxESSE8sSc1OTS1ILYLJMnFwSjUw Hqksm9nxNFquYsOmR7usjq9/2Ji55Ymn0PoZZs/N7ZpOOrxvS4s8dDhe0mQ+v6OV9rFnDQ/2 lv0VNnnL+9ziDquMgGphulF6QaBTpCFj1buMeg4b+Tyxh0czFxy4yfXqb8Aqr7pb6ixT9oru 2+zHpsQTkl7513mxccfRp7ZsjYeiXkzSbdygxFKckWioxVxUnAgAM0vrMhMCAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chanwoo Choi commit b8995f527aac143e83d3900ff39357651ea4e0f6 upstream This patch fixes the broken serial log when changing the clock source of uart device. Before disabling the original clock source, this patch enables the new clock source to protect the clock off state for a split second. [k.kozlowski]: On SMP systems this opens a short time window when both clocks (old and new) are disabled and a second thread uses TTY/UART. This leads to broken log or imprecise external abort (on one of ARM64 boards): Unhandled fault: synchronous external abort (0x96000210) at 0xffffff8008080008 Internal error: : 96000210 [#1] PREEMPT SMP [] s3c24xx_serial_console_putchar+0x8/0x64 [] s3c24xx_serial_console_write+0x30/0x38 [] call_console_drivers.constprop.22+0x100/0x108 [] console_unlock+0x504/0x58c [] vprintk_emit+0x2cc/0x478 [] vprintk_default+0x38/0x40 [] printk+0xac/0xb8 [] audit_printk_skb+0x68/0x6c [] audit_log_end+0x13c/0x188 [] common_lsm_audit+0xb4/0x618 [] smack_log+0xe8/0x10c [] smk_tskacc+0x8c/0xa4 [] smk_curacc+0x2c/0x34 [] smack_inode_permission+0x60/0x70 [] security_inode_permission+0x58/0x80 [] __inode_permission+0x40/0xa0 [] inode_permission+0x14/0x4c [] may_open+0x5c/0x10c [] path_openat+0x13c/0xec8 [] do_filp_open+0x64/0xc0 [] do_sys_open+0x144/0x208 [] SyS_openat+0x10/0x18 [] __sys_trace_return+0x0/0x4 Signed-off-by: Chanwoo Choi Reviewed-by: Marek Szyprowski Signed-off-by: Greg Kroah-Hartman Cc: Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") [k.kozlowski: Backport to stable, update commit msg] Signed-off-by: Krzysztof Kozlowski --- The original Samsung serial driver was broken so this should be backported as far as possible including the 2.6.12. :) --- drivers/tty/serial/samsung.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c index ac7f8df54406..99bb23161dd6 100644 --- a/drivers/tty/serial/samsung.c +++ b/drivers/tty/serial/samsung.c @@ -1271,6 +1271,8 @@ static void s3c24xx_serial_set_termios(struct uart_port *port, /* check to see if we need to change clock source */ if (ourport->baudclk != clk) { + clk_prepare_enable(clk); + s3c24xx_serial_setsource(port, clk_sel); if (!IS_ERR(ourport->baudclk)) { @@ -1278,8 +1280,6 @@ static void s3c24xx_serial_set_termios(struct uart_port *port, ourport->baudclk = ERR_PTR(-EINVAL); } - clk_prepare_enable(clk); - ourport->baudclk = clk; ourport->baudclk_rate = clk ? clk_get_rate(clk) : 0; } -- 1.9.1