From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D13BDC43468 for ; Fri, 18 Sep 2020 02:25:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 89848238A1 for ; Fri, 18 Sep 2020 02:25:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395946; bh=bKxXcVezWZPrhdR0vZrgzGUZW3VPtL3TKD7KAk5bSI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=hL8hcqom/DSjF2NnMZBPTIWUa47W2sCkJEqEx9MeWTT0+PPuG3Uz9lZrTLU4Uf59q 8i6rYfT1Lr8ZILAX8I4xhhc9aok8TzZWp81JHAa7pNpPMO/qKLlkXAXI1/Nv1JAV2H Pz8tXR0LrnBktCimK5feCZgeyzhCdKYpY1/F/Ts0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729225AbgIRCZd (ORCPT ); Thu, 17 Sep 2020 22:25:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:45660 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728867AbgIRCQM (ORCPT ); Thu, 17 Sep 2020 22:16:12 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 217DE23718; Fri, 18 Sep 2020 02:16:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395372; bh=bKxXcVezWZPrhdR0vZrgzGUZW3VPtL3TKD7KAk5bSI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hUCUxGlDlUVRYDR6o5VHjm5s4WxXLaOx6oSbPsDIj1hYx2Ehd55UlghnSHbeDBHXM VqkatH1ZhlUVmmb7wDj77ZuivZZGYZMa/k7gzK/MZhLLTHG4V1pEieoiS0H/tsc7h1 IeanuOJGqzk46pu/j5J2vINOsfBq3j5hktc6lvzY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Raviteja Narayanam , Shubhrajyoti Datta , Greg Kroah-Hartman , Sasha Levin , linux-serial@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 4.9 64/90] serial: uartps: Wait for tx_empty in console setup Date: Thu, 17 Sep 2020 22:14:29 -0400 Message-Id: <20200918021455.2067301-64-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021455.2067301-1-sashal@kernel.org> References: <20200918021455.2067301-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Raviteja Narayanam [ Upstream commit 42e11948ddf68b9f799cad8c0ddeab0a39da33e8 ] On some platforms, the log is corrupted while console is being registered. It is observed that when set_termios is called, there are still some bytes in the FIFO to be transmitted. So, wait for tx_empty inside cdns_uart_console_setup before calling set_termios. Signed-off-by: Raviteja Narayanam Reviewed-by: Shubhrajyoti Datta Link: https://lore.kernel.org/r/1586413563-29125-2-git-send-email-raviteja.narayanam@xilinx.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/xilinx_uartps.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index eb61a07fcbbc3..07ea71a611678 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1268,6 +1268,7 @@ static int cdns_uart_console_setup(struct console *co, char *options) int bits = 8; int parity = 'n'; int flow = 'n'; + unsigned long time_out; if (co->index < 0 || co->index >= CDNS_UART_NR_PORTS) return -EINVAL; @@ -1281,6 +1282,13 @@ static int cdns_uart_console_setup(struct console *co, char *options) if (options) uart_parse_options(options, &baud, &parity, &bits, &flow); + /* Wait for tx_empty before setting up the console */ + time_out = jiffies + usecs_to_jiffies(TX_TIMEOUT); + + while (time_before(jiffies, time_out) && + cdns_uart_tx_empty(port) != TIOCSER_TEMT) + cpu_relax(); + return uart_set_options(port, co, baud, parity, bits, flow); } -- 2.25.1