Hi Geert-san, Sergei-san, > From: Geert Uytterhoeven, Sent: Thursday, June 10, 2021 12:30 AM > On Wed, Jun 9, 2021 at 5:09 PM Sergei Shtylyov > <sergei.shtylyov@xxxxxxxxx> wrote: > > On 6/9/21 4:49 AM, 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 > > > > > > Note 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@xxxxxxxxxxx> > > > --- > > > > > > drivers/tty/serial/sh-sci.c | 8 ++++++++ > > > 1 file changed, 8 insertions(+) > > > > > > diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c > > > index 4baf1316ea72..2d5487bf6855 100644 > > > --- a/drivers/tty/serial/sh-sci.c > > > +++ b/drivers/tty/serial/sh-sci.c > > > @@ -610,6 +610,14 @@ static void sci_stop_tx(struct uart_port *port) > > > ctrl &= ~SCSCR_TIE; > > > > > > serial_port_out(port, SCSCR, ctrl); > > > + > > > +#ifdef CONFIG_SERIAL_SH_SCI_DMA > > > > Why not use IS_ENABLED() instead? Gets rid of #ifdef. :-) > > > > > + if (to_sci_port(port)->chan_tx && > > > + !dma_submit_error(to_sci_port(port)->cookie_tx)) { > > > + dmaengine_terminate_async(to_sci_port(port)->chan_tx); > > > + to_sci_port(port)->cookie_tx = -EINVAL; > > Because chan_tx and cookie_tx do not exist if CONFIG_SERIAL_SH_SCI_DMA > is disabled. This is a nit though, chan_tx always exists. > Yes, that's why all the DMA code in this driver (.c file) is protected by > #ifdef CONFIG_SERIAL_SH_SCI_DMA. I'm thinking we have to remove #ifdef from sh-sci.c file at first... Best regards, Yoshihiro Shimoda