Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp310168pxj; Thu, 20 May 2021 09:49:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9PwQSaTGSEFC+rfwjEAmp2BWuP956p29DZOury1ONyNMy1ZCIW+CZ86caV/mCdeocxATD X-Received: by 2002:a05:6402:268f:: with SMTP id w15mr5846600edd.321.1621529381037; Thu, 20 May 2021 09:49:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621529381; cv=none; d=google.com; s=arc-20160816; b=hGrcF/YEpPWKQHjn2N28e81hQlxqeRLlm76t8VrQq0Dc5VkmPEIO2Ipm4mcNbbRNLj fFfiKhVWg7ykyvsIbJIXLBoeQilZDB/wy6SollTZAzaEal9B59SpbuvsM7+p0Fvm70I6 L83tanwCLuEEEiM50I72v0lOhblCpPmu4AvIpSumld7CO7GCGUr7tqbtx15/8CcDjPOP nIBViCH8tDOoxNBAEa9rgDdhULyb20twxGQ6cB1UzTxN1ir3eUlF/+D3Bfr9SfSh64zK 4SPe5U8oSnNRcwF7dcd+GVEp4PaiuW6+NuRJK77qbeqcmV4by7hIZl7ycGBL7CdA063b KiQg== 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=0PeOYS+NNNtst4lnsJUjz6nj9+ZhcMHe8l/Ohl5GeK4=; b=LIVzOA33Mv80nXRCIRNV8r+MMoiArNm6/U5/WCw3no7G+HNdBrkp3S6Xj14Lk6ZUgK Woganzj0hW72L4Aa+rhpYVXQDbCzCw18LMFfO6O/W5X3qBk24BZ66CjGhFy7gw16fCS9 WbynCymIxdwPeRJQEMdGN1ChLPrIDjyNbx8Yw3XphVsf0a8tJlqQT7CIWQmRdVoqBeK7 r6vEwyAlPyDljcmRXht1LX/6Z3eDYXMKavg4IAEyTyc+0qMiooeHH67lVdQ8hRlkvWzX gsSMdq5wFy15RjPqJK4QKii6yK4ccY53blgV0U+E/7XD7+Dt/MOideTlDdGs+caXKVnF g+3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KMxAySGm; 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 s18si3686721eji.59.2021.05.20.09.49.17; Thu, 20 May 2021 09:49:41 -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=KMxAySGm; 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 S233990AbhETJwz (ORCPT + 99 others); Thu, 20 May 2021 05:52:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:53918 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233428AbhETJuR (ORCPT ); Thu, 20 May 2021 05:50:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C080F61401; Thu, 20 May 2021 09:35:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503323; bh=9xo3PwEAnNuInzrq8LRdVlfmE4VQDzqDqcIX+H90MJk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KMxAySGmPYAOrVues2SZWHJYnnd89k8zujm3Dc/3MB3cpggyJNll5vJwEGH+UI64X QAXspMY4rKtzgO7UBIAMH8xA0135vc6WNdlDWqzU3wJXAkiA/9Rm/HFrrKDpV6JSFn IGsgvMCYd/Dli5on2pMEujLxFxmUUz2UAqnpPr/M= 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.19 169/425] serial: stm32: fix incorrect characters on console Date: Thu, 20 May 2021 11:18:58 +0200 Message-Id: <20210520092137.002764002@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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 bce4ac1787ad..09cecd34d13e 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -637,8 +637,9 @@ static void stm32_set_termios(struct uart_port *port, struct ktermios *termios, 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; @@ -647,6 +648,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