diff mbox series

serial: sh-sci: Stop dmaengine transfer in sci_stop_tx()

Message ID 20210602114108.510527-1-yoshihiro.shimoda.uh@renesas.com (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show
Series serial: sh-sci: Stop dmaengine transfer in sci_stop_tx() | expand

Commit Message

Yoshihiro Shimoda June 2, 2021, 11:41 a.m. UTC
Stop dmaengine transfer in sci_stop_tx(). Otherwise, the following
message is possible output when system enters suspend and while
transferring data, because clearing TIE bit in SCSCR is not able to
stop any dmaengine transfer.

    sh-sci e6550000.serial: ttySC1: Unable to drain transmitter

Notes that this patch uses dmaengine_terminate_async() so that
we can apply this patch into longterm kernel v4.9.x or later.

Fixes: 73a19e4c0301 ("serial: sh-sci: Add DMA support.")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/tty/serial/sh-sci.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Greg KH June 2, 2021, 11:57 a.m. UTC | #1
On Wed, Jun 02, 2021 at 08:41:08PM +0900, Yoshihiro Shimoda wrote:
> Stop dmaengine transfer in sci_stop_tx(). Otherwise, the following
> message is possible output when system enters suspend and while
> transferring data, because clearing TIE bit in SCSCR is not able to
> stop any dmaengine transfer.
> 
>     sh-sci e6550000.serial: ttySC1: Unable to drain transmitter
> 
> Notes that this patch uses dmaengine_terminate_async() so that
> we can apply this patch into longterm kernel v4.9.x or later.
> 
> Fixes: 73a19e4c0301 ("serial: sh-sci: Add DMA support.")
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
>  drivers/tty/serial/sh-sci.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index 4baf1316ea72..e7130be48946 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -600,6 +600,9 @@ static void sci_start_tx(struct uart_port *port)
>  static void sci_stop_tx(struct uart_port *port)
>  {
>  	unsigned short ctrl;
> +#ifdef CONFIG_SERIAL_SH_SCI_DMA
> +	struct sci_port *s = to_sci_port(port);
> +#endif

Please do not put #ifdef in .c files, this should be possible without
that.

thanks,

greg k-h
Yoshihiro Shimoda June 3, 2021, 1:47 a.m. UTC | #2
Hi Greg,

> From: Greg KH, Sent: Wednesday, June 2, 2021 8:57 PM
> 
> On Wed, Jun 02, 2021 at 08:41:08PM +0900, Yoshihiro Shimoda wrote:
> > Stop dmaengine transfer in sci_stop_tx(). Otherwise, the following
> > message is possible output when system enters suspend and while
> > transferring data, because clearing TIE bit in SCSCR is not able to
> > stop any dmaengine transfer.
> >
> >     sh-sci e6550000.serial: ttySC1: Unable to drain transmitter
> >
> > Notes that this patch uses dmaengine_terminate_async() so that
> > we can apply this patch into longterm kernel v4.9.x or later.
> >
> > Fixes: 73a19e4c0301 ("serial: sh-sci: Add DMA support.")
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > ---
> >  drivers/tty/serial/sh-sci.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> >
> > diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> > index 4baf1316ea72..e7130be48946 100644
> > --- a/drivers/tty/serial/sh-sci.c
> > +++ b/drivers/tty/serial/sh-sci.c
> > @@ -600,6 +600,9 @@ static void sci_start_tx(struct uart_port *port)
> >  static void sci_stop_tx(struct uart_port *port)
> >  {
> >  	unsigned short ctrl;
> > +#ifdef CONFIG_SERIAL_SH_SCI_DMA
> > +	struct sci_port *s = to_sci_port(port);
> > +#endif
> 
> Please do not put #ifdef in .c files, this should be possible without
> that.

This #ifdef could avoid a compile warning if CONFIG_SERIAL_SH_SCI_DMA was not defined:

drivers/tty/serial/sh-sci.c: In function 'sci_stop_tx':
drivers/tty/serial/sh-sci.c:603:19: warning: unused variable 's' [-Wunused-variable]
  struct sci_port *s = to_sci_port(port);

Anyway, I'll avoid to use #ifdef in .c file. Thank you for your review!

Best regards,
Yoshihiro Shimoda

> thanks,
> 
> greg k-h
diff mbox series

Patch

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 4baf1316ea72..e7130be48946 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -600,6 +600,9 @@  static void sci_start_tx(struct uart_port *port)
 static void sci_stop_tx(struct uart_port *port)
 {
 	unsigned short ctrl;
+#ifdef CONFIG_SERIAL_SH_SCI_DMA
+	struct sci_port *s = to_sci_port(port);
+#endif
 
 	/* Clear TIE (Transmit Interrupt Enable) bit in SCSCR */
 	ctrl = serial_port_in(port, SCSCR);
@@ -610,6 +613,13 @@  static void sci_stop_tx(struct uart_port *port)
 	ctrl &= ~SCSCR_TIE;
 
 	serial_port_out(port, SCSCR, ctrl);
+
+#ifdef CONFIG_SERIAL_SH_SCI_DMA
+	if (s->chan_tx && !dma_submit_error(s->cookie_tx)) {
+		dmaengine_terminate_async(s->chan_tx);
+		s->cookie_tx = -EINVAL;
+	}
+#endif
 }
 
 static void sci_start_rx(struct uart_port *port)