]> git.baikalelectronics.ru Git - kernel.git/commitdiff
serial: 8250_bcm7271: Save/restore RTS in suspend/resume
authorDoug Berger <opendmb@gmail.com>
Thu, 14 Jul 2022 03:13:15 +0000 (20:13 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:24:07 +0000 (14:24 +0200)
[ Upstream commit 1296b1797ea1020345e5e71afc8299e775b2e855 ]

Commit 63e0f239159d ("serial: 8250_bcm7271: UART errors after resuming
from S2") prevented an early enabling of RTS during resume, but it did
not actively restore the RTS state after resume.

Fixes: 63e0f239159d ("serial: 8250_bcm7271: UART errors after resuming from S2")
Signed-off-by: Doug Berger <opendmb@gmail.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20220714031316.404918-1-f.fainelli@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/tty/serial/8250/8250_bcm7271.c

index 0877cf24f7de02a4dffe8d481ac8809f0e9003e1..711cf30e835aa5eb172d98a73f7f9f3c286b79d3 100644 (file)
@@ -1141,16 +1141,19 @@ static int __maybe_unused brcmuart_suspend(struct device *dev)
        struct brcmuart_priv *priv = dev_get_drvdata(dev);
        struct uart_8250_port *up = serial8250_get_port(priv->line);
        struct uart_port *port = &up->port;
-
-       serial8250_suspend_port(priv->line);
-       clk_disable_unprepare(priv->baud_mux_clk);
+       unsigned long flags;
 
        /*
         * This will prevent resume from enabling RTS before the
-        *  baud rate has been resored.
+        *  baud rate has been restored.
         */
+       spin_lock_irqsave(&port->lock, flags);
        priv->saved_mctrl = port->mctrl;
-       port->mctrl = 0;
+       port->mctrl &= ~TIOCM_RTS;
+       spin_unlock_irqrestore(&port->lock, flags);
+
+       serial8250_suspend_port(priv->line);
+       clk_disable_unprepare(priv->baud_mux_clk);
 
        return 0;
 }
@@ -1160,6 +1163,7 @@ static int __maybe_unused brcmuart_resume(struct device *dev)
        struct brcmuart_priv *priv = dev_get_drvdata(dev);
        struct uart_8250_port *up = serial8250_get_port(priv->line);
        struct uart_port *port = &up->port;
+       unsigned long flags;
        int ret;
 
        ret = clk_prepare_enable(priv->baud_mux_clk);
@@ -1182,7 +1186,15 @@ static int __maybe_unused brcmuart_resume(struct device *dev)
                start_rx_dma(serial8250_get_port(priv->line));
        }
        serial8250_resume_port(priv->line);
-       port->mctrl = priv->saved_mctrl;
+
+       if (priv->saved_mctrl & TIOCM_RTS) {
+               /* Restore RTS */
+               spin_lock_irqsave(&port->lock, flags);
+               port->mctrl |= TIOCM_RTS;
+               port->ops->set_mctrl(port, port->mctrl);
+               spin_unlock_irqrestore(&port->lock, flags);
+       }
+
        return 0;
 }