From: Yoshihiro Kaneko <ykaneko0929@gmail.com>
To: linux-serial@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Simon Horman <horms@verge.net.au>,
Magnus Damm <magnus.damm@gmail.com>,
linux-sh@vger.kernel.org
Subject: [PATCH/RFC] serial: sh-sci: Fix exclusion of work_fn_rx and sci_dma_rx_complete
Date: Sun, 14 Jun 2015 17:27:19 +0000 [thread overview]
Message-ID: <1434302839-31216-1-git-send-email-ykaneko0929@gmail.com> (raw)
From: Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>
There is a problem when the sci_dma_rx_complete() is processed
before cancel process of work_fn_rx() completes by rx_timer_fn().
This patch locks work_fn_rx().
Signed-off-by: Kazuya Mizuguchi <kazuya.mizuguchi.ks@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
---
This patch is based on the tty-next branch of Greg Kroah-Hartman's tty
tree.
drivers/tty/serial/sh-sci.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index b74a644..ef59842 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1423,14 +1423,16 @@ static void work_fn_rx(struct work_struct *work)
struct uart_port *port = &s->port;
struct dma_async_tx_descriptor *desc;
int new;
+ unsigned long flags;
+ spin_lock_irqsave(&port->lock, flags);
if (s->active_rx = s->cookie_rx[0]) {
new = 0;
} else if (s->active_rx = s->cookie_rx[1]) {
new = 1;
} else {
dev_err(port->dev, "cookie %d not found!\n", s->active_rx);
- return;
+ goto out;
}
desc = s->desc_rx[new];
@@ -1440,36 +1442,35 @@ static void work_fn_rx(struct work_struct *work)
struct dma_chan *chan = s->chan_rx;
struct shdma_desc *sh_desc = container_of(desc,
struct shdma_desc, async_tx);
- unsigned long flags;
int count;
dmaengine_terminate_all(chan);
dev_dbg(port->dev, "Read %zu bytes with cookie %d\n",
sh_desc->partial, sh_desc->cookie);
- spin_lock_irqsave(&port->lock, flags);
count = sci_dma_rx_push(s, sh_desc->partial);
- spin_unlock_irqrestore(&port->lock, flags);
if (count)
tty_flip_buffer_push(&port->state->port);
sci_submit_rx(s);
- return;
+ goto out;
}
s->cookie_rx[new] = desc->tx_submit(desc);
if (s->cookie_rx[new] < 0) {
dev_warn(port->dev, "Failed submitting Rx DMA descriptor\n");
sci_rx_dma_release(s, true);
- return;
+ goto out;
}
s->active_rx = s->cookie_rx[!new];
dev_dbg(port->dev, "%s: cookie %d #%d, new active #%d\n",
__func__, s->cookie_rx[new], new, s->active_rx);
+out:
+ spin_unlock_irqrestore(&port->lock, flags);
}
static void work_fn_tx(struct work_struct *work)
--
1.9.1
next reply other threads:[~2015-06-14 17:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-14 17:27 Yoshihiro Kaneko [this message]
2015-07-15 12:53 ` [PATCH/RFC] serial: sh-sci: Fix exclusion of work_fn_rx and sci_dma_rx_complete Geert Uytterhoeven
2015-07-20 17:06 ` Yoshihiro Kaneko
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=1434302839-31216-1-git-send-email-ykaneko0929@gmail.com \
--to=ykaneko0929@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=horms@verge.net.au \
--cc=linux-serial@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=magnus.damm@gmail.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).