Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp732181ybb; Wed, 8 Apr 2020 08:51:51 -0700 (PDT) X-Google-Smtp-Source: APiQypKRgQz8UCwbX2eP4tGS69g1yQncci6yJ8G7597sl/tT89/QVFiaYXXZ+BA3waTbkW1qKPCU X-Received: by 2002:a4a:3f19:: with SMTP id e25mr6479812ooa.67.1586361110961; Wed, 08 Apr 2020 08:51:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586361110; cv=none; d=google.com; s=arc-20160816; b=03msJHS1hDXIqDXnl1M5qGQSkRaipvfTvydfG2a50VVuhxzDbGAvJafDCxeSCSo/fG BhSUnK8gBeCm1+xUJPXkhnNzczNPZbO7wByZD2xCygLLp6hRbSPbKx5UApIizWKGOaoT p0zHWStECOfbx0V6/x8DWFbh6/SUcs0LwtaT/4/N1/10EnNB+TJnjil9Zx2Q0+OlpGck Lqjv718Wuy7pECEJsmpSHxkRjFRXKiY5oaShXffWGoRMGJFpFijjbTjmVaqa+qHbXWCS jvCJrakv4UT0PxEQ9CfZUMwD1KcikO/doEKZCa7uiPXyg1hW/jrkq15zi0SaWPpC8Ims W38A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version; bh=YNUdkmQTWDzwTbqgdcGnNU45SOlK0NZdGhiIo7QuIXM=; b=KLPctCqvjrZFeVrkH1vlkz5LimxxxNvoqcO+AKvboQgRT7YPndKQOIhl/OFmNfOBME 9x5RH+ai7FA5u142iOBmJ71nbWpDWyj+GJS2HW9VpbFivsBze0HEIivoxU/0pe/BM8pI kIn+NjUKhkvWNMZwh8ZEavW1b/ZlrRJEETwucSYG+J9iBEZzDU5rkTI3Fb567OVaJRH1 XA/gx+1xXRV9HC/HnZ2kervp09lNd86C6qOVirFx1BeZ8YnkoNm6qDuHN3sE7MhTmOc4 uvf1wghCiIOep385NKEo3ZjY4UWry5Hf5GClpag+1375eF0aISxELnBXHtbCFgtSxLNM yufg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z9si2133300oih.157.2020.04.08.08.51.38; Wed, 08 Apr 2020 08:51:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729667AbgDHPvI (ORCPT + 99 others); Wed, 8 Apr 2020 11:51:08 -0400 Received: from fieber.vanmierlo.com ([84.243.197.177]:44597 "EHLO kerio9.vanmierlo.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729176AbgDHPvI (ORCPT ); Wed, 8 Apr 2020 11:51:08 -0400 X-Footer: dmFubWllcmxvLmNvbQ== Received: from roundcube.vanmierlo.com ([192.168.37.37]) (authenticated user m.brock@vanmierlo.com) by kerio9.vanmierlo.com (Kerio Connect 9.2.11 beta 1) with ESMTPA; Wed, 8 Apr 2020 17:50:32 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 08 Apr 2020 17:50:32 +0200 From: Maarten Brock To: Raviteja Narayanam Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jslaby@suse.com, michal.simek@xilinx.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, git@xilinx.com, linux-serial-owner@vger.kernel.org Subject: Re: [PATCH] serial: uartps: Wait for tx_empty in console setup In-Reply-To: <1586278391-9061-1-git-send-email-raviteja.narayanam@xilinx.com> References: <1586278391-9061-1-git-send-email-raviteja.narayanam@xilinx.com> Message-ID: <396bcf8a0068fc05e70cc439a4843b61@vanmierlo.com> X-Sender: m.brock@vanmierlo.com User-Agent: Roundcube Webmail/1.3.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-04-07 18:53, Raviteja Narayanam wrote: > 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 > --- > drivers/tty/serial/xilinx_uartps.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/tty/serial/xilinx_uartps.c > b/drivers/tty/serial/xilinx_uartps.c > index 6b26f76..23468ff 100644 > --- a/drivers/tty/serial/xilinx_uartps.c > +++ b/drivers/tty/serial/xilinx_uartps.c > @@ -1260,6 +1260,8 @@ static int cdns_uart_console_setup(struct > console *co, char *options) > int bits = 8; > int parity = 'n'; > int flow = 'n'; > + unsigned long time_out = jiffies + usecs_to_jiffies(TX_TIMEOUT); > + int status; > > if (!port->membase) { > pr_debug("console on " CDNS_UART_TTY_NAME "%i not present\n", > @@ -1270,6 +1272,14 @@ 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 */ > + while (time_before(jiffies, time_out)) { > + status = cdns_uart_tx_empty(port); > + if (status == TIOCSER_TEMT) > + break; > + cpu_relax(); > + } > + > return uart_set_options(port, co, baud, parity, bits, flow); > } > #endif /* CONFIG_SERIAL_XILINX_PS_UART_CONSOLE */ You could do without the status variable. You could even combine the while and if conditions. And while you're at it, you might as well also rewrite the lines 1236-1238 to also use cdns_uart_tx_empty() for clarity. Maarten