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 2921A24EF65 for ; Thu, 3 Apr 2025 14:38:06 +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=1743691087; cv=none; b=aU/qiqUwp3T6vlSJ7eKoz60OSNkov5ArdFyyzDYqD3v8OnKS3qDPeYX5eUNVWH9ySX4Su97z5vFgXJQybfSx5WowEEuqy9LC20ItQyQLkFHbefsLfH3HGeMBP3UThZwd9PcoU/N1MqEQToE0VmBEA8wwlETOgV9ZDdKXt7FGHdA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743691087; c=relaxed/simple; bh=M/oH7NK3q34XbVyMSbvTOslh0bgFzUKg0JDR22qNhQY=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=PTCJ1C8Puguc6KEYiyIulFqJuniucICd+yk4sctdOEUUYpPTeupW7rkPoDb/zz0TGTE22rohqqfev8UKpBZGYoweb10S2nIDbzCvboyiDl3tMs1idFu2ESi6f0XjbC/x1w/jKehZKY79Zn9eB5bWmraDPrnqMfgOqp0ItRO6k+k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Wt9fJ/U/; 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="Wt9fJ/U/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54181C4CEE3; Thu, 3 Apr 2025 14:38:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1743691086; bh=M/oH7NK3q34XbVyMSbvTOslh0bgFzUKg0JDR22qNhQY=; h=Subject:To:Cc:From:Date:From; b=Wt9fJ/U/CAKnM3OdOX9rl9lJaSXEziwPlajWdU64xo8dF86FBnpxxEEtnAjZK/1ud 6iPohT0cpt3qoLPrm0pVQQua8H27aILAjnQq7BvKr/EylQ4acj3f+A32AAOiT6BhY1 0pfIihhRJpHeyHFHy3yIr7mJZGIv3g6UKntNWJjs= Subject: FAILED: patch "[PATCH] tty: serial: fsl_lpuart: disable transmitter before changing" failed to apply to 5.10-stable tree To: sherry.sun@nxp.com,Frank.Li@nxp.com,gregkh@linuxfoundation.org,stable@kernel.org Cc: From: Date: Thu, 03 Apr 2025 15:36:31 +0100 Message-ID: <2025040331-drivable-partake-4157@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.10-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y git checkout FETCH_HEAD git cherry-pick -x f5cb528d6441eb860250a2f085773aac4f44085e # git commit -s git send-email --to '' --in-reply-to '2025040331-drivable-partake-4157@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From f5cb528d6441eb860250a2f085773aac4f44085e Mon Sep 17 00:00:00 2001 From: Sherry Sun Date: Wed, 12 Mar 2025 10:25:03 +0800 Subject: [PATCH] tty: serial: fsl_lpuart: disable transmitter before changing RS485 related registers According to the LPUART reference manual, TXRTSE and TXRTSPOL of MODIR register only can be changed when the transmitter is disabled. So disable the transmitter before changing RS485 related registers and re-enable it after the change is done. Fixes: 67b01837861c ("tty: serial: lpuart: Add RS485 support for 32-bit uart flavour") Cc: stable Signed-off-by: Sherry Sun Reviewed-by: Frank Li Link: https://lore.kernel.org/r/20250312022503.1342990-1-sherry.sun@nxp.com Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 91d02c55c470..203ec3b46304 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -1484,6 +1484,19 @@ static int lpuart32_config_rs485(struct uart_port *port, struct ktermios *termio unsigned long modem = lpuart32_read(&sport->port, UARTMODIR) & ~(UARTMODIR_TXRTSPOL | UARTMODIR_TXRTSE); + u32 ctrl; + + /* TXRTSE and TXRTSPOL only can be changed when transmitter is disabled. */ + ctrl = lpuart32_read(&sport->port, UARTCTRL); + if (ctrl & UARTCTRL_TE) { + /* wait for the transmit engine to complete */ + lpuart32_wait_bit_set(&sport->port, UARTSTAT, UARTSTAT_TC); + lpuart32_write(&sport->port, ctrl & ~UARTCTRL_TE, UARTCTRL); + + while (lpuart32_read(&sport->port, UARTCTRL) & UARTCTRL_TE) + cpu_relax(); + } + lpuart32_write(&sport->port, modem, UARTMODIR); if (rs485->flags & SER_RS485_ENABLED) { @@ -1503,6 +1516,10 @@ static int lpuart32_config_rs485(struct uart_port *port, struct ktermios *termio } lpuart32_write(&sport->port, modem, UARTMODIR); + + if (ctrl & UARTCTRL_TE) + lpuart32_write(&sport->port, ctrl, UARTCTRL); + return 0; }