Skip to content

Commit 0907c10

Browse files
KAZUMIZUgregkh
authored andcommitted
serial: sh-sci: Fix exclusion of work_fn_rx and sci_dma_rx_complete
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> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 47aceb9 commit 0907c10

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/tty/serial/sh-sci.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,23 +1433,24 @@ static void work_fn_rx(struct work_struct *work)
14331433
struct dma_async_tx_descriptor *desc;
14341434
struct dma_tx_state state;
14351435
enum dma_status status;
1436+
unsigned long flags;
14361437
int new;
14371438

1439+
spin_lock_irqsave(&port->lock, flags);
14381440
if (s->active_rx == s->cookie_rx[0]) {
14391441
new = 0;
14401442
} else if (s->active_rx == s->cookie_rx[1]) {
14411443
new = 1;
14421444
} else {
14431445
dev_err(port->dev, "%s: Rx cookie %d not found!\n", __func__,
14441446
s->active_rx);
1445-
return;
1447+
goto out;
14461448
}
14471449

14481450
status = dmaengine_tx_status(s->chan_rx, s->active_rx, &state);
14491451
if (status != DMA_COMPLETE) {
14501452
/* Handle incomplete DMA receive */
14511453
struct dma_chan *chan = s->chan_rx;
1452-
unsigned long flags;
14531454
unsigned int read;
14541455
int count;
14551456

@@ -1458,16 +1459,14 @@ static void work_fn_rx(struct work_struct *work)
14581459
dev_dbg(port->dev, "Read %u bytes with cookie %d\n", read,
14591460
s->active_rx);
14601461

1461-
spin_lock_irqsave(&port->lock, flags);
14621462
count = sci_dma_rx_push(s, read);
1463-
spin_unlock_irqrestore(&port->lock, flags);
14641463

14651464
if (count)
14661465
tty_flip_buffer_push(&port->state->port);
14671466

14681467
sci_submit_rx(s);
14691468

1470-
return;
1469+
goto out;
14711470
}
14721471

14731472
desc = dmaengine_prep_slave_sg(s->chan_rx, &s->sg_rx[new], 1,
@@ -1486,11 +1485,14 @@ static void work_fn_rx(struct work_struct *work)
14861485

14871486
dev_dbg(port->dev, "%s: cookie %d #%d, new active cookie %d\n",
14881487
__func__, s->cookie_rx[new], new, s->active_rx);
1488+
out:
1489+
spin_unlock_irqrestore(&port->lock, flags);
14891490
return;
14901491

14911492
fail:
14921493
dev_warn(port->dev, "Failed submitting Rx DMA descriptor\n");
14931494
sci_rx_dma_release(s, true);
1495+
spin_unlock_irqrestore(&port->lock, flags);
14941496
}
14951497

14961498
static void work_fn_tx(struct work_struct *work)

0 commit comments

Comments
 (0)