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 1/2] serial: sh-sci: Fix TX DMA buffer flushing and workqueue races
Date: Fri, 28 Jun 2019 14:53:19 +0200 [thread overview]
Message-ID: <20190628125319.GB10962@vmlxhi-102.adit-jv.com> (raw)
In-Reply-To: <20190624123540.20629-2-geert+renesas@glider.be>
Hi Geert,
One bikeshedding below.
On Mon, Jun 24, 2019 at 02:35:39PM +0200, Geert Uytterhoeven wrote:
[..]
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index abc705716aa094fd..d4504daff99263f5 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -1398,6 +1398,7 @@ static void sci_dma_tx_work_fn(struct work_struct *work)
> struct circ_buf *xmit = &port->state->xmit;
> unsigned long flags;
> dma_addr_t buf;
> + int head, tail;
>
> /*
> * DMA is idle now.
> @@ -1407,16 +1408,23 @@ static void sci_dma_tx_work_fn(struct work_struct *work)
> * consistent xmit buffer state.
> */
> spin_lock_irq(&port->lock);
> - buf = s->tx_dma_addr + (xmit->tail & (UART_XMIT_SIZE - 1));
> + head = xmit->head;
> + tail = xmit->tail;
> + buf = s->tx_dma_addr + (tail & (UART_XMIT_SIZE - 1));
> s->tx_dma_len = min_t(unsigned int,
> - CIRC_CNT(xmit->head, xmit->tail, UART_XMIT_SIZE),
> - CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE));
> - spin_unlock_irq(&port->lock);
> + CIRC_CNT(head, tail, UART_XMIT_SIZE),
> + CIRC_CNT_TO_END(head, tail, UART_XMIT_SIZE));
> + if (!s->tx_dma_len) {
> + /* Transmit buffer has been flushed */
> + spin_unlock_irq(&port->lock);
> + return;
Since we can now return before using the result stored in 'buf', we
could relocate the 'buf' calculation next to the return statement, just
before calling dmaengine_prep_slave_single(), as micro-optimization.
> + }
>
> desc = dmaengine_prep_slave_single(chan, buf, s->tx_dma_len,
> DMA_MEM_TO_DEV,
> DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
Otherwise:
Reviewed-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Tested-by: Eugeniu Rosca <erosca@de.adit-jv.com>
--
Best Regards,
Eugeniu.
next prev parent reply other threads:[~2019-06-28 12:53 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 [this message]
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
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=20190628125319.GB10962@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).