]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Fixes for 5.10
authorSasha Levin <sashal@kernel.org>
Tue, 8 Apr 2025 00:42:40 +0000 (20:42 -0400)
committerSasha Levin <sashal@kernel.org>
Tue, 8 Apr 2025 00:42:40 +0000 (20:42 -0400)
Signed-off-by: Sasha Levin <sashal@kernel.org>
queue-5.10/can-flexcan-only-change-can-state-when-link-up-in-sy.patch [new file with mode: 0644]
queue-5.10/series
queue-5.10/tty-serial-fsl_lpuart-disable-transmitter-before-cha.patch [new file with mode: 0644]
queue-5.10/tty-serial-fsl_lpuart-use-uartmodir-register-bits-fo.patch [new file with mode: 0644]

diff --git a/queue-5.10/can-flexcan-only-change-can-state-when-link-up-in-sy.patch b/queue-5.10/can-flexcan-only-change-can-state-when-link-up-in-sy.patch
new file mode 100644 (file)
index 0000000..395f776
--- /dev/null
@@ -0,0 +1,75 @@
+From 6312b3cd839c49951d79fa010a8320207bf7e6c4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 14 Mar 2025 19:01:44 +0800
+Subject: can: flexcan: only change CAN state when link up in system PM
+
+From: Haibo Chen <haibo.chen@nxp.com>
+
+[ Upstream commit fd99d6ed20234b83d65b9c5417794343577cf3e5 ]
+
+After a suspend/resume cycle on a down interface, it will come up as
+ERROR-ACTIVE.
+
+$ ip -details -s -s a s dev flexcan0
+3: flexcan0: <NOARP,ECHO> mtu 16 qdisc pfifo_fast state DOWN group default qlen 10
+    link/can  promiscuity 0 allmulti 0 minmtu 0 maxmtu 0
+    can state STOPPED (berr-counter tx 0 rx 0) restart-ms 1000
+
+$ sudo systemctl suspend
+
+$ ip -details -s -s a s dev flexcan0
+3: flexcan0: <NOARP,ECHO> mtu 16 qdisc pfifo_fast state DOWN group default qlen 10
+    link/can  promiscuity 0 allmulti 0 minmtu 0 maxmtu 0
+    can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 1000
+
+And only set CAN state to CAN_STATE_ERROR_ACTIVE when resume process
+has no issue, otherwise keep in CAN_STATE_SLEEPING as suspend did.
+
+Fixes: 4de349e786a3 ("can: flexcan: fix resume function")
+Cc: stable@vger.kernel.org
+Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
+Link: https://patch.msgid.link/20250314110145.899179-1-haibo.chen@nxp.com
+Reported-by: Marc Kleine-Budde <mkl@pengutronix.de>
+Closes: https://lore.kernel.org/all/20250314-married-polar-elephant-b15594-mkl@pengutronix.de
+[mkl: add newlines]
+Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/can/flexcan.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
+index 429950241de32..586c13d855e09 100644
+--- a/drivers/net/can/flexcan.c
++++ b/drivers/net/can/flexcan.c
+@@ -2113,8 +2113,9 @@ static int __maybe_unused flexcan_suspend(struct device *device)
+               }
+               netif_stop_queue(dev);
+               netif_device_detach(dev);
++
++              priv->can.state = CAN_STATE_SLEEPING;
+       }
+-      priv->can.state = CAN_STATE_SLEEPING;
+       return 0;
+ }
+@@ -2125,7 +2126,6 @@ static int __maybe_unused flexcan_resume(struct device *device)
+       struct flexcan_priv *priv = netdev_priv(dev);
+       int err;
+-      priv->can.state = CAN_STATE_ERROR_ACTIVE;
+       if (netif_running(dev)) {
+               netif_device_attach(dev);
+               netif_start_queue(dev);
+@@ -2143,6 +2143,8 @@ static int __maybe_unused flexcan_resume(struct device *device)
+                       if (err)
+                               return err;
+               }
++
++              priv->can.state = CAN_STATE_ERROR_ACTIVE;
+       }
+       return 0;
+-- 
+2.39.5
+
index b6de974b1e649584f58f5a36fb6518ae7608eb2c..2a6710d792aa8fef73c6e4d6c9829caa8e0bd957 100644 (file)
@@ -203,3 +203,6 @@ ipv6-fix-omitted-netlink-attributes-when-using-rtext.patch
 net-dsa-mv88e6xxx-propperly-shutdown-ppu-re-enable-t.patch
 net-fix-geneve_opt-length-integer-overflow.patch
 arcnet-add-null-check-in-com20020pci_probe.patch
+can-flexcan-only-change-can-state-when-link-up-in-sy.patch
+tty-serial-fsl_lpuart-use-uartmodir-register-bits-fo.patch
+tty-serial-fsl_lpuart-disable-transmitter-before-cha.patch
diff --git a/queue-5.10/tty-serial-fsl_lpuart-disable-transmitter-before-cha.patch b/queue-5.10/tty-serial-fsl_lpuart-disable-transmitter-before-cha.patch
new file mode 100644 (file)
index 0000000..74545ef
--- /dev/null
@@ -0,0 +1,64 @@
+From 33b02d4f5d9b380df4518037bf4b72ca585d66b9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 12 Mar 2025 10:25:03 +0800
+Subject: tty: serial: fsl_lpuart: disable transmitter before changing RS485
+ related registers
+
+From: Sherry Sun <sherry.sun@nxp.com>
+
+[ Upstream commit f5cb528d6441eb860250a2f085773aac4f44085e ]
+
+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 <stable@kernel.org>
+Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
+Reviewed-by: Frank Li <Frank.Li@nxp.com>
+Link: https://lore.kernel.org/r/20250312022503.1342990-1-sherry.sun@nxp.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/tty/serial/fsl_lpuart.c | 17 +++++++++++++++++
+ 1 file changed, 17 insertions(+)
+
+diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
+index 5135cdc0b6644..110d98fed7260 100644
+--- a/drivers/tty/serial/fsl_lpuart.c
++++ b/drivers/tty/serial/fsl_lpuart.c
+@@ -1352,6 +1352,19 @@ static int lpuart32_config_rs485(struct uart_port *port,
+       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);
+       /* clear unsupported configurations */
+@@ -1392,6 +1405,10 @@ static int lpuart32_config_rs485(struct uart_port *port,
+       sport->port.rs485 = *rs485;
+       lpuart32_write(&sport->port, modem, UARTMODIR);
++
++      if (ctrl & UARTCTRL_TE)
++              lpuart32_write(&sport->port, ctrl, UARTCTRL);
++
+       return 0;
+ }
+-- 
+2.39.5
+
diff --git a/queue-5.10/tty-serial-fsl_lpuart-use-uartmodir-register-bits-fo.patch b/queue-5.10/tty-serial-fsl_lpuart-use-uartmodir-register-bits-fo.patch
new file mode 100644 (file)
index 0000000..adaf1d9
--- /dev/null
@@ -0,0 +1,64 @@
+From e44581d68b6d9dc1464b5c76de18fe400e3ccb20 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 14 Apr 2023 10:21:11 +0800
+Subject: tty: serial: fsl_lpuart: use UARTMODIR register bits for lpuart32
+ platform
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Sherry Sun <sherry.sun@nxp.com>
+
+[ Upstream commit d57d56e4dddfb5c92cd81abf8922055bf0fb85a4 ]
+
+For lpuart32 platforms, UARTMODIR register is used instead of UARTMODEM.
+So here should configure the corresponding UARTMODIR register bits to
+avoid confusion.
+
+Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
+Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
+Link: https://lore.kernel.org/r/20230414022111.20896-1-sherry.sun@nxp.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Stable-dep-of: f5cb528d6441 ("tty: serial: fsl_lpuart: disable transmitter before changing RS485 related registers")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/tty/serial/fsl_lpuart.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
+index b16ad6db1ef8e..5135cdc0b6644 100644
+--- a/drivers/tty/serial/fsl_lpuart.c
++++ b/drivers/tty/serial/fsl_lpuart.c
+@@ -1351,7 +1351,7 @@ static int lpuart32_config_rs485(struct uart_port *port,
+                       struct lpuart_port, port);
+       unsigned long modem = lpuart32_read(&sport->port, UARTMODIR)
+-                              & ~(UARTMODEM_TXRTSPOL | UARTMODEM_TXRTSE);
++                              & ~(UARTMODIR_TXRTSPOL | UARTMODIR_TXRTSE);
+       lpuart32_write(&sport->port, modem, UARTMODIR);
+       /* clear unsupported configurations */
+@@ -1361,7 +1361,7 @@ static int lpuart32_config_rs485(struct uart_port *port,
+       if (rs485->flags & SER_RS485_ENABLED) {
+               /* Enable auto RS-485 RTS mode */
+-              modem |= UARTMODEM_TXRTSE;
++              modem |= UARTMODIR_TXRTSE;
+               /*
+                * RTS needs to be logic HIGH either during transfer _or_ after
+@@ -1383,9 +1383,9 @@ static int lpuart32_config_rs485(struct uart_port *port,
+                * Note: UART is assumed to be active high.
+                */
+               if (rs485->flags & SER_RS485_RTS_ON_SEND)
+-                      modem |= UARTMODEM_TXRTSPOL;
++                      modem |= UARTMODIR_TXRTSPOL;
+               else if (rs485->flags & SER_RS485_RTS_AFTER_SEND)
+-                      modem &= ~UARTMODEM_TXRTSPOL;
++                      modem &= ~UARTMODIR_TXRTSPOL;
+       }
+       /* Store the new configuration */
+-- 
+2.39.5
+