From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F7901CA8F; Mon, 1 Apr 2024 16:25:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711988710; cv=none; b=lCuyDzcq0Phw9d1bg7Gm7PiIGJl3G6tW5chZyX/hOFR7fk6yFYaTikkEYd7eqqAgqaMMRqU3+cVaRBocNFMZlWbx1uDZK4xRHLEEf8V8T7SaRpLlOEeU3LbwVKXgqNM/Mp7wieRJbjlERquQbdlsqKOFsOxvPXLRQgm3wl96Wvs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711988710; c=relaxed/simple; bh=WvTJ3H/JwHWYlyDOoL/I6gKjhTxPO4AjO0mTOoQMdqM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BjLS3vmytwkj9SO1UNt1POjnLvMMCQxNAraQ0XkTcvD2JJp82QCkZb9yiiB2a0he1qyD36hM1OwxlHIUb7rFJmKTW98tZ01jPZz5Mv2d17Mu2hQldNxSyAmfWunceJk88DeM7Eih+gEJKK/NChzPG1FkyyFHz/iRr89e2zlxzHw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uBBgdOKU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="uBBgdOKU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 724A9C433F1; Mon, 1 Apr 2024 16:25:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1711988709; bh=WvTJ3H/JwHWYlyDOoL/I6gKjhTxPO4AjO0mTOoQMdqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uBBgdOKU6+y9vqtuFwHkv+nYwVlpT/L18yj/4NtcXDcxdTUSpdnqFbwpjYKUYwvqf CFCq+ixqUqD8tKfYlnHtr9YW4deQU2b+4eVgCyZaqbIahnOiYKOX/JGaSQHyz6XKLG l4vupGbHU2RsAf0oaPNsvBdueUHSexXaUZWNoehM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Sherry Sun , Alexander Sverdlin Subject: [PATCH 6.7 266/432] tty: serial: fsl_lpuart: avoid idle preamble pending if CTS is enabled Date: Mon, 1 Apr 2024 17:44:13 +0200 Message-ID: <20240401152601.083874643@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240401152553.125349965@linuxfoundation.org> References: <20240401152553.125349965@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.7-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sherry Sun commit 74cb7e0355fae9641f825afa389d3fba3b617714 upstream. If the remote uart device is not connected or not enabled after booting up, the CTS line is high by default. At this time, if we enable the flow control when opening the device(for example, using “stty -F /dev/ttyLP4 crtscts” command), there will be a pending idle preamble(first writing 0 and then writing 1 to UARTCTRL_TE will queue an idle preamble) that cannot be sent out, resulting in the uart port fail to close(waiting for TX empty), so the user space stty will have to wait for a long time or forever. This is an LPUART IP bug(idle preamble has higher priority than CTS), here add a workaround patch to enable TX CTS after enabling UARTCTRL_TE, so that the idle preamble does not get stuck due to CTS is deasserted. Fixes: 380c966c093e ("tty: serial: fsl_lpuart: add 32-bit register interface support") Cc: stable Signed-off-by: Sherry Sun Reviewed-by: Alexander Sverdlin Link: https://lore.kernel.org/r/20240305015706.1050769-1-sherry.sun@nxp.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/fsl_lpuart.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -2345,9 +2345,12 @@ lpuart32_set_termios(struct uart_port *p lpuart32_write(&sport->port, bd, UARTBAUD); lpuart32_serial_setbrg(sport, baud); - lpuart32_write(&sport->port, modem, UARTMODIR); - lpuart32_write(&sport->port, ctrl, UARTCTRL); + /* disable CTS before enabling UARTCTRL_TE to avoid pending idle preamble */ + lpuart32_write(&sport->port, modem & ~UARTMODIR_TXCTSE, UARTMODIR); /* restore control register */ + lpuart32_write(&sport->port, ctrl, UARTCTRL); + /* re-enable the CTS if needed */ + lpuart32_write(&sport->port, modem, UARTMODIR); if ((ctrl & (UARTCTRL_PE | UARTCTRL_M)) == UARTCTRL_PE) sport->is_cs7 = true;