Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4591370pxj; Wed, 12 May 2021 08:50:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqaqvWzAqycc/Xq4rjYe/jTV6XHGpFCoVV4WSAQGKBPLAPnfngKM1KVXtj6J1SfHQpBzFz X-Received: by 2002:aa7:cb84:: with SMTP id r4mr44137307edt.187.1620834623418; Wed, 12 May 2021 08:50:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620834623; cv=none; d=google.com; s=arc-20160816; b=PRHY1b+Dp5glXlN0mkYVBh2cYTIyP+m3NkGsjSfrLBf+lLqANp3j7lQ43wbx5EVzD0 GKwl3pdDlnZSXKwihsnFiSEKleNsNscekk1iCtBV4dY/ECm10SRosCk6/TvMaGUI9pC7 /TelqlUT73Q6dkzzhbw98cpyj05hV9upzDtdRrr+rqiwSoYMfwgBZ2DwboXQ+Sa25OfE dGgircjpdFN87PIuqenCg/qe+jFXzrZezh4wnYlO0RZ/1UWDA894pgYxjIhFGY8jQp8/ WMYl7FBV2DZWi/N8BTFLPS73r7p1HIojmvKVxA/yKDZHQJIMJMWcBQd1OwQju4fKeRq/ mVvw== 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=+S8ptqXrglsk4I5m1Pn0dk28Y7EDXfmJoQgFTwXOzY0=; b=SudCmkLbQtiUkPkLmRKB+dELLNBoAw2roF41+gtB1D6W4R702IrV+nUGTkyfmVhsyT h8ijLs4LboXgGV1UPv1nnSW907Z078jXjD1dZgYcC0R6Hbn23l7p1MfAM+37MpuYnqbN BIeM35Dqg6o2Ms9h58oMQChHGeLnGDNFrYQ7EduffS2+MWzpZo+UIL/9kAEps+cTcfzE VAPDo3SJrx48OSLBgUUasq8p9h9TAQJtlCGLoAEi2rAzWcpG3KvvEloVZtL0ZPrHO2xi TZRDIzPLBdmy7x4iEP2orqSN5Ufd+tXfaC2zBjXpT1srKHQ7zMGSvpZpfGWLjXqUjF5l N0wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kiZ1bFjv; 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 jo9si289635ejb.552.2021.05.12.08.49.58; Wed, 12 May 2021 08:50:23 -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=kiZ1bFjv; 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 S236656AbhELPpi (ORCPT + 99 others); Wed, 12 May 2021 11:45:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:57684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234684AbhELPUX (ORCPT ); Wed, 12 May 2021 11:20:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4B403619A0; Wed, 12 May 2021 15:08:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832101; bh=LcztlVqMIhmWJjoDruzZwUsYIlHKjCofS74neo4ix3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kiZ1bFjvq2X2QotXRXWQLT6+v89fgPFEX/88kRR4OAN78YRlU92P/rS236RvlgjI4 ijyoDTecyKfHMQZn75brPGmSluj9Ia7mCYhRC5o9EVEyQuz7G7H5JDJ7L87hK8Z7Sq pOuGtvBWcAxq80Ivhu6OKYfDVNq9MlOPBBQULK3A= 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 141/530] serial: stm32: add FIFO flush when port is closed Date: Wed, 12 May 2021 16:44:11 +0200 Message-Id: <20210512144824.454313666@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 9f77d19207a0e8ba814c8ceb22e90ce7cb2aef64 ] Transmission complete error is sent when ISR_TC is not set. If port closure is requested despite data in TDR / TX FIFO has not been sent (because of flow control), ISR_TC is not set and error message is sent on port closure but also when a new port is opened. Flush the data when port is closed, so the error isn't printed twice upon next port opening. Fixes: 64c32eab6603 ("serial: stm32: Add support of TC bit status check") Signed-off-by: Erwan Le Ray Link: https://lore.kernel.org/r/20210304162308.8984-12-erwan.leray@foss.st.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/stm32-usart.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index 6788fb3af6cb..cb8c2bece6d6 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -689,6 +689,11 @@ static void stm32_usart_shutdown(struct uart_port *port) if (ret) dev_err(port->dev, "transmission complete not set\n"); + /* flush RX & TX FIFO */ + if (ofs->rqr != UNDEF_REG) + writel_relaxed(USART_RQR_TXFRQ | USART_RQR_RXFRQ, + port->membase + ofs->rqr); + stm32_usart_clr_bits(port, ofs->cr1, val); free_irq(port->irq, port); -- 2.30.2