Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp853953pxk; Thu, 17 Sep 2020 19:09:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6ZMP3gRoYeqrELDrWnF95e/BFG6pzdHoAtheR7JVICd4PvaIuKtNiLPAPW+9X/nPZmeLx X-Received: by 2002:a05:6402:393:: with SMTP id o19mr36370819edv.34.1600394983205; Thu, 17 Sep 2020 19:09:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600394983; cv=none; d=google.com; s=arc-20160816; b=gGDJ3SY3UUfpzRM8zpcBKnVP5WBuCKi5LcvH0r8tT7CBLJppV0eyw/BtLsY6gaUH/b CAL/9ujAmrpZyvasei7umrLUXfM+waMyRxcHzT/m3cw3iWZtkqNDYNd1N+EsfwCmVYno bDJW0zo1VmoELTkmBTc0lRiB+BBWjrGCKEcJpZoXxMcKOvaaTmv3DTwR3jRf4Zqx3m31 yzKQxGlLQhjKFouxwFx93PEKuKjT2MRkuGFZw6kVBBG92bFnMo4zmFJMiLRvzb3wOkF2 M5Yk5+/x2ydWRqI6hKW8l+s1fY4BYlqRiVoJlhyCv/oR7F67IZtjVn+Ri+75zKWK8ETb rt9g== 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=VnoWfNaqqUvFKz11hQxR/PphFR0FykBAfP6CWtPDbSA=; b=rThn17Q6kc4gVbLoLAc+sM8fydRbze1m61JUyP3LV247xpg5oaeuJEQVUH6qUWaJ68 u5OjT0kw7DTn0QEKbvedf/HUEts0nk8IKj0EomCsrsf7MF2XX0oS39w5qhhZSNOr9ITE GhVQ1Xy+mLro2td9TxupwxWyA4ETp+Twjf9XF7Z5A24g3d/RvaOO0oIJEmmba/VkPz92 urCy/br1XrNc3YRgW+IKPY0cLw79yeAyU2TdDvKVSKJv//YWaYXkWRxuPumBIYHinkwl EvQ5MqmS5pqX6FCxExscS6gvsu4xfy8SGowloLSWH+iPyx4Butjkw3POOVoNP7889M+v MG1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PHp9AgTf; 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 s14si1199639ejx.304.2020.09.17.19.09.19; Thu, 17 Sep 2020 19:09:43 -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=PHp9AgTf; 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 S1726666AbgIRCGL (ORCPT + 99 others); Thu, 17 Sep 2020 22:06:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:54904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727001AbgIRCGA (ORCPT ); Thu, 17 Sep 2020 22:06:00 -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 BD48F2388B; Fri, 18 Sep 2020 02:05:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394759; bh=m+xSef4FwMZXVWA4SuamimpYJjfqv4oVJa3zM60QY7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PHp9AgTfUF/wViKMV4uDRiyqn8+K4rDQ3//Qz6CjbuGSE0seMVOmw2r9tqfb/lFX6 1CW2pD5UlgJ0mVfN/5hgC01DeVQ+gyspFV8k9cQbrrAQf9R6nTRhxY57HMep+G9gui Y7o4z9wMgycOO6wV6t5IUL/HDyj/WXmY2I+TatHg= 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 5.4 236/330] serial: uartps: Wait for tx_empty in console setup Date: Thu, 17 Sep 2020 21:59:36 -0400 Message-Id: <20200918020110.2063155-236-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-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 8948970f795e6..9359c80fbb9f5 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1248,6 +1248,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 (!port->membase) { pr_debug("console on " CDNS_UART_TTY_NAME "%i not present\n", @@ -1258,6 +1259,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