Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp861572pxk; Thu, 17 Sep 2020 19:28:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyN1jZCJKNJUlZdiz8q1Z8+50ZdkwIwWfbZJDa0IBo1F1K7naj5RDndvO76bdCq3ubbfNmM X-Received: by 2002:a50:fb15:: with SMTP id d21mr37652491edq.150.1600396094231; Thu, 17 Sep 2020 19:28:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600396094; cv=none; d=google.com; s=arc-20160816; b=JEYO0nJuPMaAy0P+dBVH9SyJMS+uYNYjX3MbNElTrHbY2HTw7ln4qs4f14gC+PBtOt g+gSU+BvkOj4ynJfSkNQLFWvaWebt8fm6FBKJ8y2A74V6P6auMAAh08OFNKjxkKcf2Vk mbJtHRfLLL0AMh5kfRnukO8Tt3iDgtnVhwNkEY71rT+LzfkMA/BkUsSJwAqct1i/9Xt1 hGbFL4h3xg+WNkeMcWoyPie8lsNS545WS6c1IIJw0yuQzqLJ3yzOZLzOjXvv/KkYnrLN VZIsLQIWqPFrQfnwSeoVNQON6BDg1B0k+8wO0MVhkPkLP15GjZbHFEsgxTukYV+7qLY0 sG8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=a8JE1Q1DeLJUSOspG1h4D5rSLAxJ45g+hHwZhkURID4=; b=iIfQlYkeLqgt5cyfiY7ukafg0zBB8b/JQjaXQH8UeHvajlvII7r1V6zLpkfNkYoK8u lOgcFxhH3jvfAs5jipp52pU4lNlZ9hYiMMT9u71Y0EtrYo8J3hQpzaJGcRbzo8GJf+2A nFJEI7uaNsWP1p62gYzhUf0x1nO4HFlCCjgTMOz+uCde2V1Z+8kyRmyDDFa7kquDAYTB D3FX7GXUbeHrspYNnq+0BRU76fiItmrzR/GS/S5Bhjj9Y7zBuiGPmC7F5WGDwpCKns+a AuJJmaJKopLtK6Nuq/8pX5MFHiyvR5iKnLVCzQANIole16nwpugO/1CTjn75755n+eif nVEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hUCUxGlD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t23si1242731ejf.457.2020.09.17.19.27.51; Thu, 17 Sep 2020 19:28:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hUCUxGlD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729823AbgIRCZh (ORCPT + 99 others); Thu, 17 Sep 2020 22:25:37 -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-kernel@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