From: Sasha Levin Date: Tue, 8 Apr 2025 00:42:40 +0000 (-0400) Subject: Fixes for 5.10 X-Git-Tag: v5.4.292~69 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1c56f32411d0e4e698ab4a843ef183364ba83d95;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.10 Signed-off-by: Sasha Levin --- 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 index 0000000000..395f776d3f --- /dev/null +++ b/queue-5.10/can-flexcan-only-change-can-state-when-link-up-in-sy.patch @@ -0,0 +1,75 @@ +From 6312b3cd839c49951d79fa010a8320207bf7e6c4 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +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 + +[ 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: 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: 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 +Link: https://patch.msgid.link/20250314110145.899179-1-haibo.chen@nxp.com +Reported-by: Marc Kleine-Budde +Closes: https://lore.kernel.org/all/20250314-married-polar-elephant-b15594-mkl@pengutronix.de +[mkl: add newlines] +Signed-off-by: Marc Kleine-Budde +Signed-off-by: Sasha Levin +--- + 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 + diff --git a/queue-5.10/series b/queue-5.10/series index b6de974b1e..2a6710d792 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -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 index 0000000000..74545ef553 --- /dev/null +++ b/queue-5.10/tty-serial-fsl_lpuart-disable-transmitter-before-cha.patch @@ -0,0 +1,64 @@ +From 33b02d4f5d9b380df4518037bf4b72ca585d66b9 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 12 Mar 2025 10:25:03 +0800 +Subject: tty: serial: fsl_lpuart: disable transmitter before changing RS485 + related registers + +From: Sherry Sun + +[ 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 +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 +Signed-off-by: Sasha Levin +--- + 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 index 0000000000..adaf1d9ec0 --- /dev/null +++ b/queue-5.10/tty-serial-fsl_lpuart-use-uartmodir-register-bits-fo.patch @@ -0,0 +1,64 @@ +From e44581d68b6d9dc1464b5c76de18fe400e3ccb20 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +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 + +[ 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 +Signed-off-by: Sherry Sun +Link: https://lore.kernel.org/r/20230414022111.20896-1-sherry.sun@nxp.com +Signed-off-by: Greg Kroah-Hartman +Stable-dep-of: f5cb528d6441 ("tty: serial: fsl_lpuart: disable transmitter before changing RS485 related registers") +Signed-off-by: Sasha Levin +--- + 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 +