All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] serial: 8250_bcm7271: Save/restore RTS in suspend/resume
@ 2022-06-28 21:59 Florian Fainelli
  2022-06-29  6:09 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Fainelli @ 2022-06-28 21:59 UTC (permalink / raw)
  To: linux-serial
  Cc: Doug Berger, Florian Fainelli, Al Cooper,
	Broadcom internal kernel review list, Greg Kroah-Hartman,
	Jiri Slaby, open list

From: Doug Berger <opendmb@gmail.com>

The previous patch prevented an early enabling of RTS during
resume, but it did not actively restore the RTS state after
resume.

Fixes: 9cabe26e65a8 ("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>
---
 drivers/tty/serial/8250/8250_bcm7271.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_bcm7271.c b/drivers/tty/serial/8250/8250_bcm7271.c
index 9b878d023dac..b9cea38c8aff 100644
--- a/drivers/tty/serial/8250/8250_bcm7271.c
+++ b/drivers/tty/serial/8250/8250_bcm7271.c
@@ -1139,16 +1139,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;
 }
@@ -1158,6 +1161,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);
@@ -1180,7 +1184,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;
+		spin_unlock_irqrestore(&port->lock, flags);
+		port->ops->set_mctrl(port, port->mctrl);
+	}
+
 	return 0;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] serial: 8250_bcm7271: Save/restore RTS in suspend/resume
  2022-06-28 21:59 [PATCH] serial: 8250_bcm7271: Save/restore RTS in suspend/resume Florian Fainelli
@ 2022-06-29  6:09 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2022-06-29  6:09 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: linux-serial, Doug Berger, Al Cooper,
	Broadcom internal kernel review list, Jiri Slaby, open list

On Tue, Jun 28, 2022 at 02:59:01PM -0700, Florian Fainelli wrote:
> From: Doug Berger <opendmb@gmail.com>
> 
> The previous patch prevented an early enabling of RTS during
> resume, but it did not actively restore the RTS state after
> resume.

There is no "previous patch" here, please be specific and explain why
you are doing what you are doing here.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-29  6:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-28 21:59 [PATCH] serial: 8250_bcm7271: Save/restore RTS in suspend/resume Florian Fainelli
2022-06-29  6:09 ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.