]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
serial: imx: Grab port lock in imx_uart_enable_wakeup()
authorEsben Haabendal <esben@geanix.com>
Fri, 13 Sep 2024 08:39:49 +0000 (10:39 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 11 Oct 2024 06:13:35 +0000 (08:13 +0200)
The port lock needs to be held when doing read-modify-write on UCR1 and
UCR3.

Signed-off-by: Esben Haabendal <esben@geanix.com>
Link: https://lore.kernel.org/r/20240913-serial-imx-lockfix-v1-1-4d102746c89d@geanix.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/imx.c

index f7367969a42ad671c42e9e63d89828c6233722bc..1e6a785b02be06ed6f8c4f0c3a6990383a127668 100644 (file)
@@ -2580,10 +2580,13 @@ static void imx_uart_save_context(struct imx_port *sport)
        uart_port_unlock_irqrestore(&sport->port, flags);
 }
 
+/* called with irq off */
 static void imx_uart_enable_wakeup(struct imx_port *sport, bool on)
 {
        u32 ucr3;
 
+       uart_port_lock(&sport->port);
+
        ucr3 = imx_uart_readl(sport, UCR3);
        if (on) {
                imx_uart_writel(sport, USR1_AWAKE, USR1);
@@ -2603,6 +2606,8 @@ static void imx_uart_enable_wakeup(struct imx_port *sport, bool on)
                }
                imx_uart_writel(sport, ucr1, UCR1);
        }
+
+       uart_port_unlock(&sport->port);
 }
 
 static int imx_uart_suspend_noirq(struct device *dev)