Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4590005pxj; Wed, 12 May 2021 08:48:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYbknHghyxQKdKwwEZS0DWePhpMa5QMlW64Qw16rzDfDpt60Jvoj+TcYQSOYztWO9NK3I2 X-Received: by 2002:a9d:171d:: with SMTP id i29mr31829956ota.79.1620834523374; Wed, 12 May 2021 08:48:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620834523; cv=none; d=google.com; s=arc-20160816; b=o6dw/QNWhjXW1CEtD8lDWB0hJv7YsXNzKPY/NEIcDYX6UMb81gJ/N6UjJb9ogw/S0a ciOQHHPa7AUT3pdIIWvCJd17flkKz5ZWSHwjlcLbJ3AQwHYis/VRqgw3z6gKrbFOomRb zi0ebK5XbvM5RxG02wZyr4nCMRQ9uWoU+qkmJa/4jJ+XSzK2VMu6b3eG3BGbaP/OBlIw J9xw9oxymTDi8w37P6L02EpH9elkBVW2L7MZn3sa97EiP3DGXWbmWZBjDG3HiL/w46WO RHPrwdeYOXcOGoTmrTj+z7gCCEpUeU6tK2hript0CzXavCfjv8NPE83awurdBBOcanrB upxg== 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=8WgItX0lV9hS2AsO3uFQxN+ELHp/kUeHrEEEbPa6Qts=; b=Gc4W4s+ZFyNXigtGx/BdD1oeyrEus8qJIaR6ZX1FL6jURkO5jnByPJgsnysxTOJL4e T1kIy/Bdo+ZthL/PdUSbKBBaEDBcy3JLItdVjmVGFmKHV4oNdFucxSApgmr1+GeaDq0O zEJuOLuXtHw89oeECeqGLTP4h2rnX8kqkrH1nMhCcjk9JJr+rBwQyAwMj6atq0YRs+zf sH0fu92jYmIjNrvXMQE/ZDU/q6Y1+5j7hRgvseU+1SIgzZGifgVqeSuyiTqUp2dmvLgV 02dwcOqUbIi6kShO5n9QNtC3TxBAb5XMCWrQfbdg5QwO9f1wDZXGdTUz37PgoX+vYdAy 0G9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NQ4a6pcf; 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 m3si255448ote.193.2021.05.12.08.48.06; Wed, 12 May 2021 08:48:43 -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=NQ4a6pcf; 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 S234416AbhELPog (ORCPT + 99 others); Wed, 12 May 2021 11:44:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:59522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234451AbhELPTX (ORCPT ); Wed, 12 May 2021 11:19:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CFFC761997; Wed, 12 May 2021 15:08:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832082; bh=fB2ymC7lOVdckjRTUKLZpr28i4cAT/4LZHa3MvLFjqI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NQ4a6pcfOTRsFpN0Z/rJJ7QcdgADYYBHHqX7wP5n/Dz1az5LbxL9eMQ8mV8/77tRK 7vanV5oy995OUP15j2crxZbBhHaJtqOvJJ4Z8GreyVTdYfpHaz+ZQ/CxNhJLDLiewz OM4ENNVcGiBelnwnTRvyQ/Xfo/KGcVate/TPOW6g= 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 134/530] serial: stm32: fix TX and RX FIFO thresholds Date: Wed, 12 May 2021 16:44:04 +0200 Message-Id: <20210512144824.226900638@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 25a8e7611da5513b388165661b17173c26e12c04 ] TX and RX FIFO thresholds may be cleared after suspend/resume, depending on the low power mode. Those configurations (done in startup) are not effective for UART console, as: - the reference manual indicates that FIFOEN bit can only be written when the USART is disabled (UE=0) - a set_termios (where UE is set) is requested firstly for console enabling, before the startup. Fixes: 84872dc448fe ("serial: stm32: add RX and TX FIFO flush") Signed-off-by: Erwan Le Ray Link: https://lore.kernel.org/r/20210304162308.8984-5-erwan.leray@foss.st.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/stm32-usart.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index 70155e0c3b02..91a33ec4dbb4 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -648,19 +648,8 @@ static int stm32_usart_startup(struct uart_port *port) if (ofs->rqr != UNDEF_REG) stm32_usart_set_bits(port, ofs->rqr, USART_RQR_RXFRQ); - /* Tx and RX FIFO configuration */ - if (stm32_port->fifoen) { - val = readl_relaxed(port->membase + ofs->cr3); - val &= ~(USART_CR3_TXFTCFG_MASK | USART_CR3_RXFTCFG_MASK); - val |= USART_CR3_TXFTCFG_HALF << USART_CR3_TXFTCFG_SHIFT; - val |= USART_CR3_RXFTCFG_HALF << USART_CR3_RXFTCFG_SHIFT; - writel_relaxed(val, port->membase + ofs->cr3); - } - - /* RX FIFO enabling */ + /* RX enabling */ val = stm32_port->cr1_irq | USART_CR1_RE | BIT(cfg->uart_enable_bit); - if (stm32_port->fifoen) - val |= USART_CR1_FIFOEN; stm32_usart_set_bits(port, ofs->cr1, val); return 0; @@ -768,9 +757,15 @@ static void stm32_usart_set_termios(struct uart_port *port, if (stm32_port->fifoen) cr1 |= USART_CR1_FIFOEN; cr2 = 0; + + /* Tx and RX FIFO configuration */ cr3 = readl_relaxed(port->membase + ofs->cr3); - cr3 &= USART_CR3_TXFTIE | USART_CR3_RXFTCFG_MASK | USART_CR3_RXFTIE - | USART_CR3_TXFTCFG_MASK; + cr3 &= USART_CR3_TXFTIE | USART_CR3_RXFTIE; + if (stm32_port->fifoen) { + cr3 &= ~(USART_CR3_TXFTCFG_MASK | USART_CR3_RXFTCFG_MASK); + cr3 |= USART_CR3_TXFTCFG_HALF << USART_CR3_TXFTCFG_SHIFT; + cr3 |= USART_CR3_RXFTCFG_HALF << USART_CR3_RXFTCFG_SHIFT; + } if (cflag & CSTOPB) cr2 |= USART_CR2_STOP_2B; -- 2.30.2