All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tty: serial: imx: clear RTSD status before suspend
@ 2021-11-23  7:03 Sherry Sun
  2021-11-23  7:42 ` Uwe Kleine-König
  0 siblings, 1 reply; 5+ messages in thread
From: Sherry Sun @ 2021-11-23  7:03 UTC (permalink / raw)
  To: gregkh, jirislaby; +Cc: linux-serial, linux-kernel, linux-imx

From: Fugang Duan <fugang.duan@nxp.com>

Clear RTSD status before suspend due to the port also
use RTS pin as wakeup source, need to clear the flag first.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
---
 drivers/tty/serial/imx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 90f82e6c54e4..fb75e3e0d828 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -2482,10 +2482,12 @@ static void imx_uart_enable_wakeup(struct imx_port *sport, bool on)
 
 	if (sport->have_rtscts) {
 		u32 ucr1 = imx_uart_readl(sport, UCR1);
-		if (on)
+		if (on) {
+			imx_uart_writel(sport, USR1_RTSD, USR1);
 			ucr1 |= UCR1_RTSDEN;
-		else
+		} else {
 			ucr1 &= ~UCR1_RTSDEN;
+		}
 		imx_uart_writel(sport, ucr1, UCR1);
 	}
 }
-- 
2.17.1


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

* Re: [PATCH] tty: serial: imx: clear RTSD status before suspend
  2021-11-23  7:03 [PATCH] tty: serial: imx: clear RTSD status before suspend Sherry Sun
@ 2021-11-23  7:42 ` Uwe Kleine-König
  2021-11-23  8:41   ` Sherry Sun
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2021-11-23  7:42 UTC (permalink / raw)
  To: Sherry Sun; +Cc: gregkh, jirislaby, linux-serial, linux-kernel, linux-imx

[-- Attachment #1: Type: text/plain, Size: 1360 bytes --]

On Tue, Nov 23, 2021 at 03:03:49PM +0800, Sherry Sun wrote:
> From: Fugang Duan <fugang.duan@nxp.com>
> 
> Clear RTSD status before suspend due to the port also
> use RTS pin as wakeup source, need to clear the flag first.

I'd write:

	Clear RTSD status before enabling the irq event for RTSD.

That this happens in the context of suspend isn't that important.

> Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
> Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> ---
>  drivers/tty/serial/imx.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> index 90f82e6c54e4..fb75e3e0d828 100644
> --- a/drivers/tty/serial/imx.c
> +++ b/drivers/tty/serial/imx.c
> @@ -2482,10 +2482,12 @@ static void imx_uart_enable_wakeup(struct imx_port *sport, bool on)
>  
>  	if (sport->have_rtscts) {
>  		u32 ucr1 = imx_uart_readl(sport, UCR1);
> -		if (on)
> +		if (on) {
> +			imx_uart_writel(sport, USR1_RTSD, USR1);
>  			ucr1 |= UCR1_RTSDEN;
> -		else
> +		} else {
>  			ucr1 &= ~UCR1_RTSDEN;
> +		}
>  		imx_uart_writel(sport, ucr1, UCR1);
>  	}

The change looks fine.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* RE: [PATCH] tty: serial: imx: clear RTSD status before suspend
  2021-11-23  7:42 ` Uwe Kleine-König
@ 2021-11-23  8:41   ` Sherry Sun
  2021-11-23  9:51     ` Uwe Kleine-König
  0 siblings, 1 reply; 5+ messages in thread
From: Sherry Sun @ 2021-11-23  8:41 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: gregkh, jirislaby, linux-serial, linux-kernel, dl-linux-imx

Hi Uwe,

> -----Original Message-----
> From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Sent: 2021年11月23日 15:42
> To: Sherry Sun <sherry.sun@nxp.com>
> Cc: gregkh@linuxfoundation.org; jirislaby@kernel.org; linux-
> serial@vger.kernel.org; linux-kernel@vger.kernel.org; dl-linux-imx <linux-
> imx@nxp.com>
> Subject: Re: [PATCH] tty: serial: imx: clear RTSD status before suspend
> 
> On Tue, Nov 23, 2021 at 03:03:49PM +0800, Sherry Sun wrote:
> > From: Fugang Duan <fugang.duan@nxp.com>
> >
> > Clear RTSD status before suspend due to the port also use RTS pin as
> > wakeup source, need to clear the flag first.
> 
> I'd write:
> 
> 	Clear RTSD status before enabling the irq event for RTSD.

Thanks for the suggestion, I will reorganize the commit message and send V2.

> 
> That this happens in the context of suspend isn't that important.

Sorry I didn't get the point here, can you please explain more?
Per my understanding, the wakeup source interrupt is handled in the suspend context, so clear the flag in the suspend context is also necessary.

Best regards
Sherry

> 
> > Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
> > Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> > ---
> >  drivers/tty/serial/imx.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index
> > 90f82e6c54e4..fb75e3e0d828 100644
> > --- a/drivers/tty/serial/imx.c
> > +++ b/drivers/tty/serial/imx.c
> > @@ -2482,10 +2482,12 @@ static void imx_uart_enable_wakeup(struct
> > imx_port *sport, bool on)
> >
> >  	if (sport->have_rtscts) {
> >  		u32 ucr1 = imx_uart_readl(sport, UCR1);
> > -		if (on)
> > +		if (on) {
> > +			imx_uart_writel(sport, USR1_RTSD, USR1);
> >  			ucr1 |= UCR1_RTSDEN;
> > -		else
> > +		} else {
> >  			ucr1 &= ~UCR1_RTSDEN;
> > +		}
> >  		imx_uart_writel(sport, ucr1, UCR1);
> >  	}
> 
> The change looks fine.
> 
> Best regards
> Uwe
> 
> --
> Pengutronix e.K.                           | Uwe Kleine-König            |
> Industrial Linux Solutions                 | https://www.pengutronix.de/ |

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

* Re: [PATCH] tty: serial: imx: clear RTSD status before suspend
  2021-11-23  8:41   ` Sherry Sun
@ 2021-11-23  9:51     ` Uwe Kleine-König
  2021-11-23 10:20       ` Sherry Sun
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2021-11-23  9:51 UTC (permalink / raw)
  To: Sherry Sun; +Cc: gregkh, jirislaby, linux-serial, linux-kernel, dl-linux-imx

[-- Attachment #1: Type: text/plain, Size: 1922 bytes --]

On Tue, Nov 23, 2021 at 08:41:18AM +0000, Sherry Sun wrote:
> Hi Uwe,
> 
> > -----Original Message-----
> > From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > Sent: 2021年11月23日 15:42
> > To: Sherry Sun <sherry.sun@nxp.com>
> > Cc: gregkh@linuxfoundation.org; jirislaby@kernel.org; linux-
> > serial@vger.kernel.org; linux-kernel@vger.kernel.org; dl-linux-imx <linux-
> > imx@nxp.com>
> > Subject: Re: [PATCH] tty: serial: imx: clear RTSD status before suspend
> > 
> > On Tue, Nov 23, 2021 at 03:03:49PM +0800, Sherry Sun wrote:
> > > From: Fugang Duan <fugang.duan@nxp.com>
> > >
> > > Clear RTSD status before suspend due to the port also use RTS pin as
> > > wakeup source, need to clear the flag first.
> > 
> > I'd write:
> > 
> > 	Clear RTSD status before enabling the irq event for RTSD.
> 
> Thanks for the suggestion, I will reorganize the commit message and send V2.
> 
> > 
> > That this happens in the context of suspend isn't that important.
> 
> Sorry I didn't get the point here, can you please explain more?
> Per my understanding, the wakeup source interrupt is handled in the
> suspend context, so clear the flag in the suspend context is also
> necessary.

But the actual problem is that RTSD is enabled without first clearing it
and not that RTSD isn't cleared in suspend.

So my initial reaction after reading the commit log header "clear RTSD
status before suspend" was: WTH, why do we need clearing RTSD before
suspend. Shouldn't the RTSD state kept over suspend?

In contrast clearing an event before the respecive irq is enabled is
more obviously correct. And if the irq source is enabled as part of
suspend or open isn't that relevant for the subject line.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* RE: [PATCH] tty: serial: imx: clear RTSD status before suspend
  2021-11-23  9:51     ` Uwe Kleine-König
@ 2021-11-23 10:20       ` Sherry Sun
  0 siblings, 0 replies; 5+ messages in thread
From: Sherry Sun @ 2021-11-23 10:20 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: gregkh, jirislaby, linux-serial, linux-kernel, dl-linux-imx

Hi Uwe,

> 
> On Tue, Nov 23, 2021 at 08:41:18AM +0000, Sherry Sun wrote:
> > Hi Uwe,
> >
> > > -----Original Message-----
> > > From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > > Sent: 2021年11月23日 15:42
> > > To: Sherry Sun <sherry.sun@nxp.com>
> > > Cc: gregkh@linuxfoundation.org; jirislaby@kernel.org; linux-
> > > serial@vger.kernel.org; linux-kernel@vger.kernel.org; dl-linux-imx
> > > <linux- imx@nxp.com>
> > > Subject: Re: [PATCH] tty: serial: imx: clear RTSD status before
> > > suspend
> > >
> > > On Tue, Nov 23, 2021 at 03:03:49PM +0800, Sherry Sun wrote:
> > > > From: Fugang Duan <fugang.duan@nxp.com>
> > > >
> > > > Clear RTSD status before suspend due to the port also use RTS pin
> > > > as wakeup source, need to clear the flag first.
> > >
> > > I'd write:
> > >
> > > 	Clear RTSD status before enabling the irq event for RTSD.
> >
> > Thanks for the suggestion, I will reorganize the commit message and send
> V2.
> >
> > >
> > > That this happens in the context of suspend isn't that important.
> >
> > Sorry I didn't get the point here, can you please explain more?
> > Per my understanding, the wakeup source interrupt is handled in the
> > suspend context, so clear the flag in the suspend context is also
> > necessary.
> 
> But the actual problem is that RTSD is enabled without first clearing it and
> not that RTSD isn't cleared in suspend.
> 
> So my initial reaction after reading the commit log header "clear RTSD status
> before suspend" was: WTH, why do we need clearing RTSD before suspend.
> Shouldn't the RTSD state kept over suspend?
> 
> In contrast clearing an event before the respecive irq is enabled is more
> obviously correct. And if the irq source is enabled as part of suspend or open
> isn't that relevant for the subject line.
> 

Got your point now, thanks for the explanation.
The patch subject is indeed ambiguous, I will fix it in V2.

Best regards
Sherry

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

end of thread, other threads:[~2021-11-23 10:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-23  7:03 [PATCH] tty: serial: imx: clear RTSD status before suspend Sherry Sun
2021-11-23  7:42 ` Uwe Kleine-König
2021-11-23  8:41   ` Sherry Sun
2021-11-23  9:51     ` Uwe Kleine-König
2021-11-23 10:20       ` Sherry Sun

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.