From patchwork Tue Sep 29 11:00:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 263324 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=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, 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 24329C4741F for ; Tue, 29 Sep 2020 11:17:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B3928208B8 for ; Tue, 29 Sep 2020 11:17:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601378222; bh=l7eZ+IuUZr3FsHWocPjrOiHuzqlDZdcZ2YFLBf3I80U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=QtPq6KVCHkJ3snfp5fcR5qVFJEDv5U7ds7GMf3eqEw5vDLQivLwptmV6o3Nl8JeR0 4FK+w+S+NRAxuuWEdiujKXz/XXZcTE3D7Y8K9o4jdvjNUnT1YWjjIzIjgKsN7zt98W idwXmo2E4EJlCWT9KlMAj4AfpswFYorg0bnx4hJQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729344AbgI2LQ5 (ORCPT ); Tue, 29 Sep 2020 07:16:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:33718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729204AbgI2LQ4 (ORCPT ); Tue, 29 Sep 2020 07:16:56 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 20B82206DB; Tue, 29 Sep 2020 11:16:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601378215; bh=l7eZ+IuUZr3FsHWocPjrOiHuzqlDZdcZ2YFLBf3I80U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tGxQ1bU+glqDvjY0/M5Ciwh17bA6ONMr/kOBCRUB6HrT9Gco8R7OvN8pMI+slV3jh nNJwgWzrvNbu/bopX6TzrL/bxHTnL9OuFjU9MWHt7V5w2FsBwq/MFA75LZaa4lZ7eW eo3QEAcMp2DVpwvcYFpw8ulQrugTV2L+Nt50B2fE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Raviteja Narayanam , Shubhrajyoti Datta , Sasha Levin Subject: [PATCH 4.14 103/166] serial: uartps: Wait for tx_empty in console setup Date: Tue, 29 Sep 2020 13:00:15 +0200 Message-Id: <20200929105940.350414606@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105935.184737111@linuxfoundation.org> References: <20200929105935.184737111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@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 81657f09761cd..00a740b8ad273 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1282,6 +1282,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; @@ -1295,6 +1296,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); }