Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp432811pxj; Thu, 20 May 2021 12:45:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx18xtRKCXSqyo87AL+9Syrulkzyy9vewwRGzamP3HBA4UyCN/L3HTf4/cFRJri/z/UlJLv X-Received: by 2002:a17:906:1f54:: with SMTP id d20mr6264842ejk.94.1621539953564; Thu, 20 May 2021 12:45:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621539953; cv=none; d=google.com; s=arc-20160816; b=yNA8dOu7K3/Wxt6EGzW0I1fCEog0EzomalHxJ2gwMQhnshkBQHyedgWKTNonBrlrpx 1y1KQWQsh4kmEXo1asxstS5feFu/qj0uA/JCWtDfairK349UmPIoycMcvpbpBwHobclD wvQELkH0NDw10d6YljrakANu1TPLrBP1rgqOkAIYAUDUpVxhyqmERzqeiYKK7X/xnweB Y9+U41DWHMmP9VK0qyV2/BVYx6CEwb1lPhvwULTeUAwWnqA2ux+qwbVp0SQ5mHql/y/B JLqI0dk+c8C3mKvqfLBUcvQfH3Rf4REyISF7UV5sxcYeQ+u5hhsOotyGSArrMWuU/rVY S9jw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fVFiH2iOdkvHyk3yHjY8TAWCZxXSKF3VAteMMtRs2Aw=; b=K7YbD4w64ydxO1GFmGtVeUot8bzwH64x4gZ+TOBTzy4a98ua+Ohm5kESInT528G97w F0ihwU97z9FCNYKwRKnvuN8vC9/xx8W0+1V0onfJW2DuGPZIdhb58o5QUleZ7ldXq02F nWb00eKgDK5RtAXuVwqoeWNkxJkL4SMvmbgbN9T02i6abqoCgdkvgz42c8Jmt/AUTBAl o+5MLyVDsKgB5ccv+HBR9Cqh3J/gYOtEJCUctSsDZ8nr/hn/JRgvbCGEOXKkJCxpt1+y IBvrGKg81vXOnV+qf4J+gGIZH6Lbc+ZSDNJNBOEF9NYwJHym2LusM2wLHzWnFpgFxl16 pulQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tLBUxliz; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i19si1892335edc.501.2021.05.20.12.45.29; Thu, 20 May 2021 12:45:53 -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=@linuxfoundation.org header.s=korg header.b=tLBUxliz; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237600AbhETKlt (ORCPT + 99 others); Thu, 20 May 2021 06:41:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:55788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236375AbhETK0V (ORCPT ); Thu, 20 May 2021 06:26:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 649B261C23; Thu, 20 May 2021 09:50:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504208; bh=NNagmpoOcTBcNOeRt/xwnkAT/BbevfPqH4FZ1vQeS8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tLBUxlizpyTp2wZPZNYMM6w+6llDV78Hddud+2/mAh5TSWWZdRVLfAMIo8cUGPePt Plj10fazn1M1EuZ9l+vyzpd5cV7oZf9BoJ0PLMqTkGf4O1kDW3Y3ILkHi911vnue5Q KqBs532DSVdVc24c2PrwrpQ634Dn0qvl4cjkP9wM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Erwan Le Ray , Sasha Levin Subject: [PATCH 4.14 142/323] serial: stm32: fix incorrect characters on console Date: Thu, 20 May 2021 11:20:34 +0200 Message-Id: <20210520092124.968262608@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Erwan Le Ray [ Upstream commit f264c6f6aece81a9f8fbdf912b20bd3feb476a7a ] Incorrect characters are observed on console during boot. This issue occurs when init/main.c is modifying termios settings to open /dev/console on the rootfs. This patch adds a waiting loop in set_termios to wait for TX shift register empty (and TX FIFO if any) before stopping serial port. Fixes: 48a6092fb41f ("serial: stm32-usart: Add STM32 USART Driver") Signed-off-by: Erwan Le Ray Link: https://lore.kernel.org/r/20210304162308.8984-4-erwan.leray@foss.st.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/stm32-usart.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index 1e854e1851fb..6ad982cf31fc 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -499,8 +499,9 @@ static void stm32_set_termios(struct uart_port *port, struct ktermios *termios, unsigned int baud; u32 usartdiv, mantissa, fraction, oversampling; tcflag_t cflag = termios->c_cflag; - u32 cr1, cr2, cr3; + u32 cr1, cr2, cr3, isr; unsigned long flags; + int ret; if (!stm32_port->hw_flow_control) cflag &= ~CRTSCTS; @@ -509,6 +510,15 @@ static void stm32_set_termios(struct uart_port *port, struct ktermios *termios, spin_lock_irqsave(&port->lock, flags); + ret = readl_relaxed_poll_timeout_atomic(port->membase + ofs->isr, + isr, + (isr & USART_SR_TC), + 10, 100000); + + /* Send the TC error message only when ISR_TC is not set. */ + if (ret) + dev_err(port->dev, "Transmission is not complete\n"); + /* Stop serial port and reset value */ writel_relaxed(0, port->membase + ofs->cr1); -- 2.30.2