Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp859941pxk; Thu, 17 Sep 2020 19:23:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrJPbiHMYbS5X14F5RKJYCjfOGuuiwaNL5ek6FjFlVq6MVNAIGhe/uL69LVmzo9es3oGVT X-Received: by 2002:aa7:cb92:: with SMTP id r18mr36259993edt.158.1600395831895; Thu, 17 Sep 2020 19:23:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600395831; cv=none; d=google.com; s=arc-20160816; b=LyQnNpwsGbPyOJNpmFSEc6X+bj6UDlXYwFMFI44h5K1UMSEHOC4hyddLLpz6HaMEsj G8KqpfOCYdcsNlkCIt+qcI9p2YAoGP+d9qOwU3lff+kpg5s9g/DZsKyFbzd11mlEXGjk 0k3CmSk1mAbUXR3v4giVo7dBcWaU0mSKGMcerZ45IxfBqPS7mYkQs69UzFVF3pYulgwv 19XMyTTWf7QgmnH3Se7Dh9J2mqbVbhjtKKJ2jSi9cJahJEf0XL+dNA4XxKBGCHzRg6D5 PRaATN43+K9MRNKjrMRIdA2Mb94MxOyQp2VIpa9Wj+nrikQL9jobKJSc6l3HJs8Xfw/A zPdg== 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=Sub6J6v6/OkAvhPaFiaIBP98N4I7+CpVWrvAbw2xrtE=; b=0tgapY/BoS6F3N2d4vRoUhu31+nilso7s2HKpwOD/KF8LFb+bWuHjNLpQduv1A0lSH FQupCPNXClpGV9/GakXFRrAEi+CAK8x6pSosFRKX5WfkDx5S8Rr3oyoEqFsLa+Oam5Yu PEV0XlP9avlcTBxk/MwBzNxcv8ypWv2x9X2yChDUOqLFHH8ltH/20us48CnuZr6Jb0Lu mLMleXuFkD160X+zJXA+FzgvXcJL8MxnvudMcJ5YLhlg8xArb4rl6eeRTl+4x9YVqy57 FznSt8XS8q8p8Hjy6MKMiRvOHbdWKvAWViPcLPnEuRSAXh8ASh5SIvlOb6qFtMPxz60V RALg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=liphfWw7; 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 y22si1111123edo.147.2020.09.17.19.23.28; Thu, 17 Sep 2020 19:23:51 -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=liphfWw7; 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 S1726219AbgIRCUy (ORCPT + 99 others); Thu, 17 Sep 2020 22:20:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:48398 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729553AbgIRCRg (ORCPT ); Thu, 17 Sep 2020 22:17:36 -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 EF13923998; Fri, 18 Sep 2020 02:17:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600395455; bh=HOJCFmhew8Uv0EmppdcZWnzPC9d77TXAn0Ux69ECHvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=liphfWw7B5ENXlNsBLofW0AZ5a0R9mYQsQ6KldI6AfmIlMR7DQUpk4E6Jpf6ZZjNM OusND6DZKMDhaQkL+mwFSVxjV9DnSBbeQqXmPjO2omElYqbp6U7wGaEBeCie8pwAGY 9fUCZbOGaRPQp4zuPWRJFvO9cWCe4hFfCU0CClEU= 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.4 42/64] serial: uartps: Wait for tx_empty in console setup Date: Thu, 17 Sep 2020 22:16:21 -0400 Message-Id: <20200918021643.2067895-42-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918021643.2067895-1-sashal@kernel.org> References: <20200918021643.2067895-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 06efcef1b4953..5b4469098888a 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c @@ -1152,6 +1152,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; @@ -1165,6 +1166,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