All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eugeniu Rosca <erosca@de.adit-jv.com>
To: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
	Vinod Koul <vkoul@kernel.org>,
	Dan Williams <dan.j.williams@intel.com>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	<linux-serial@vger.kernel.org>,
	<linux-renesas-soc@vger.kernel.org>, <dmaengine@vger.kernel.org>,
	Eugeniu Rosca <erosca@de.adit-jv.com>,
	Eugeniu Rosca <roscaeugeniu@gmail.com>
Subject: Re: [PATCH 2/2] serial: sh-sci: Terminate TX DMA during buffer flushing
Date: Fri, 28 Jun 2019 16:04:25 +0200	[thread overview]
Message-ID: <20190628140425.GB11231@vmlxhi-102.adit-jv.com> (raw)
In-Reply-To: <20190624123540.20629-3-geert+renesas@glider.be>

On Mon, Jun 24, 2019 at 02:35:40PM +0200, Geert Uytterhoeven wrote:
[..]
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index d4504daff99263f5..d18c680aa64b3427 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -1656,11 +1656,18 @@ static void sci_free_dma(struct uart_port *port)
>  
>  static void sci_flush_buffer(struct uart_port *port)
>  {
> +	struct sci_port *s = to_sci_port(port);
> +
>  	/*
>  	 * In uart_flush_buffer(), the xmit circular buffer has just been
> -	 * cleared, so we have to reset tx_dma_len accordingly.
> +	 * cleared, so we have to reset tx_dma_len accordingly, and stop any
> +	 * pending transfers
>  	 */
> -	to_sci_port(port)->tx_dma_len = 0;
> +	s->tx_dma_len = 0;
> +	if (s->chan_tx) {
> +		dmaengine_terminate_async(s->chan_tx);
> +		s->cookie_tx = -EINVAL;
> +	}

I am seeing a similar solution being employed by other tty/serial
drivers [1]. One major difference is that those drivers make use of
dmaengine_terminate_all(). Since the latter is deprecated starting
with commit [2], the API choice looks reasonable to me.

Reviewed-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Tested-by: Eugeniu Rosca <erosca@de.adit-jv.com>

[1] git grep -W "static void.*flush_buffer" -- drivers/tty/serial/ | grep dmaengine_terminate
drivers/tty/serial/fsl_lpuart.c-		dmaengine_terminate_all(sport->dma_tx_chan);
drivers/tty/serial/imx.c-	dmaengine_terminate_all(sport->dma_chan_tx);
drivers/tty/serial/serial-tegra.c-		dmaengine_terminate_all(tup->tx_dma_chan);

[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b36f09c3c441a6
    ("dmaengine: Add transfer termination synchronization support")

-- 
Best Regards,
Eugeniu.

  reply	other threads:[~2019-06-28 14:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-24 12:35 [PATCH 0/2] serial: sh-sci: Fix .flush_buffer() issues Geert Uytterhoeven
2019-06-24 12:35 ` [PATCH 1/2] serial: sh-sci: Fix TX DMA buffer flushing and workqueue races Geert Uytterhoeven
2019-06-28 12:53   ` Eugeniu Rosca
2019-06-24 12:35 ` [PATCH 2/2] serial: sh-sci: Terminate TX DMA during buffer flushing Geert Uytterhoeven
2019-06-28 14:04   ` Eugeniu Rosca [this message]
2019-06-26 17:34 ` [PATCH 0/2] serial: sh-sci: Fix .flush_buffer() issues Eugeniu Rosca
2019-06-28 11:51   ` Geert Uytterhoeven
2019-06-28 12:39     ` Eugeniu Rosca
2019-06-28 12:55       ` Wolfram Sang
2019-06-28 13:02         ` Eugeniu Rosca
2019-06-28 13:14           ` Wolfram Sang
2019-07-03 17:30           ` Greg Kroah-Hartman
2019-07-03 18:15             ` Eugeniu Rosca
2019-07-03 18:44               ` Greg Kroah-Hartman
2019-07-03 21:08                 ` Wolfram Sang
2019-06-28 16:29     ` George G. Davis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190628140425.GB11231@vmlxhi-102.adit-jv.com \
    --to=erosca@de.adit-jv.com \
    --cc=dan.j.williams@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=roscaeugeniu@gmail.com \
    --cc=vkoul@kernel.org \
    --cc=wsa+renesas@sang-engineering.com \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.