Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4586057pxj; Wed, 12 May 2021 08:43:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMalabzS85ou1j/az9yL3/DSwlh4vYB4iTVl4vzJYklvcP7g6DpeK77XP6bPZx5eMwiJbc X-Received: by 2002:a5d:4947:: with SMTP id r7mr45737543wrs.217.1620834207610; Wed, 12 May 2021 08:43:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620834207; cv=none; d=google.com; s=arc-20160816; b=vKEd5TTcbwbwZM7Q1MPs/IsnENT0kKQWTJ3Qenf75efWAyoXcCnfvV2LPBgRY2pghu 6/6FwiH2XjQdu7ukqV2qB0BGo1aqFGhxW0BtgiM/fCOAJDMfpF270BZ0zIn/zf7tuiV2 7PKH4YHz3zHXjLTIspIfscC4kn/fBqeEaaKpEHIXrcAy2y6wj/dI1r3cDuZEimaUvki5 qG5qi3pmZK/B9+R5tR3ihQRCyS/iFkOplRuC2BYm7zvCk7Wy2h6SiT/WMUJ1OBOVqUKk +dr60GR35mUS/xKsnn5TL7W5bGvwU87h2iBUKKRKCp0cBlpsDNZf3x8QQMQatQ0TZoRa 3D0Q== 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=eNMnoJ91MfscdLVftgH0FT9RddYXJr1Cbwn3cYh2T80=; b=OXwzunDRH+7rChYGPWP4eYOts0jURYFw86Q46JVCsJmGbV0Hq13TDQNI1+D10ts1WJ GfMwTSUe3B3wustHkz+StNe9YfTDNHXeRCOOXxN+eNcHdTzzpvs2Jx/LqzvwISgBmEe8 wTR/B9TidSKWCznYCiNnOBqyuS2ljY4MJf5ZeNt6AUw6pofMFa758trHGugph3WzVu1u tc3JsgAiWkWYGNeAXoAAHbRxhXJJ6MEmMCnlVPRDnQPDyMfLjNQ5yNujslTTEfMXxiwj 6mhejMIuNwlYmkKc+KrQgInsXMF4Y6XkDW16XEG+pCtXU24m3Og85NYt37jdlUuL+9tT 6upw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ACqMXBs9; 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 r12si768775wmq.5.2021.05.12.08.43.02; Wed, 12 May 2021 08:43:27 -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=ACqMXBs9; 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 S235179AbhELPnP (ORCPT + 99 others); Wed, 12 May 2021 11:43:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:55148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233859AbhELPTH (ORCPT ); Wed, 12 May 2021 11:19:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6CEB361447; Wed, 12 May 2021 15:07:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832079; bh=cD7bC3DzVTH0Lq3cBh5vjAOyt2ka2dk3/JE/h8oWKic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ACqMXBs9UZzZ3kg5ma7L03t05t6HOKY5h/tkhPLYTBSS1Ukw+TQb/Vi/nn++Klao7 u90Klj7yqJxLGJOKVPXbUEP6RmLGZk8fXloo+dG0Nm6LRPLTrqQ48+TvmNBJo5hl5I gXBwpHSFEiQqkeK7tc0pC5QoJkpM1WcW9YGRNoaM= 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 5.10 133/530] serial: stm32: fix incorrect characters on console Date: Wed, 12 May 2021 16:44:03 +0200 Message-Id: <20210512144824.187154428@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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 909a0d991ba1..70155e0c3b02 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -736,8 +736,9 @@ static void stm32_usart_set_termios(struct uart_port *port, unsigned int baud, bits; 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; @@ -746,6 +747,15 @@ static void stm32_usart_set_termios(struct uart_port *port, 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