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

From: Doug Berger <opendmb@gmail.com>

Commit 9cabe26e65a8 ("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: 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] 4+ messages in thread

* Re: [PATCH v2] serial: 8250_bcm7271: Save/restore RTS in suspend/resume
  2022-06-29 16:02 [PATCH v2] serial: 8250_bcm7271: Save/restore RTS in suspend/resume Florian Fainelli
@ 2022-06-29 16:51 ` Greg Kroah-Hartman
  2022-07-04  6:40 ` Jiri Slaby
  1 sibling, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2022-06-29 16:51 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: linux-serial, linux-kernel, Doug Berger, Al Cooper,
	Broadcom internal kernel review list, Jiri Slaby

On Wed, Jun 29, 2022 at 09:02:08AM -0700, Florian Fainelli wrote:
> From: Doug Berger <opendmb@gmail.com>
> 
> Commit 9cabe26e65a8 ("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: 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
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- This looks like a new version of a previously submitted patch, but you
  did not list below the --- line any changes from the previous version.
  Please read the section entitled "The canonical patch format" in the
  kernel file, Documentation/SubmittingPatches for what needs to be done
  here to properly describe this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

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

* Re: [PATCH v2] serial: 8250_bcm7271: Save/restore RTS in suspend/resume
  2022-06-29 16:02 [PATCH v2] serial: 8250_bcm7271: Save/restore RTS in suspend/resume Florian Fainelli
  2022-06-29 16:51 ` Greg Kroah-Hartman
@ 2022-07-04  6:40 ` Jiri Slaby
  2022-07-04 15:35   ` Florian Fainelli
  1 sibling, 1 reply; 4+ messages in thread
From: Jiri Slaby @ 2022-07-04  6:40 UTC (permalink / raw)
  To: Florian Fainelli, linux-serial
  Cc: linux-kernel, Doug Berger, Al Cooper,
	Broadcom internal kernel review list, Greg Kroah-Hartman

On 29. 06. 22, 18:02, Florian Fainelli wrote:
> From: Doug Berger <opendmb@gmail.com>
> 
> Commit 9cabe26e65a8 ("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: 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
...
> @@ -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);

Calling ->set_mctrl w/o port->lock doesn't look really safe.

regards,
-- 
js
suse labs

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

* Re: [PATCH v2] serial: 8250_bcm7271: Save/restore RTS in suspend/resume
  2022-07-04  6:40 ` Jiri Slaby
@ 2022-07-04 15:35   ` Florian Fainelli
  0 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2022-07-04 15:35 UTC (permalink / raw)
  To: Jiri Slaby, Florian Fainelli, linux-serial
  Cc: linux-kernel, Doug Berger, Al Cooper,
	Broadcom internal kernel review list, Greg Kroah-Hartman



On 7/3/2022 11:40 PM, Jiri Slaby wrote:
> On 29. 06. 22, 18:02, Florian Fainelli wrote:
>> From: Doug Berger <opendmb@gmail.com>
>>
>> Commit 9cabe26e65a8 ("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: 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
> ...
>> @@ -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);
> 
> Calling ->set_mctrl w/o port->lock doesn't look really safe.

Good point, I will check with Doug whether this was intentional and if 
so, why, and if not why should we move it up under the spinlock.

Thanks!
-- 
Florian

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

end of thread, other threads:[~2022-07-04 15:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-29 16:02 [PATCH v2] serial: 8250_bcm7271: Save/restore RTS in suspend/resume Florian Fainelli
2022-06-29 16:51 ` Greg Kroah-Hartman
2022-07-04  6:40 ` Jiri Slaby
2022-07-04 15:35   ` Florian Fainelli

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.