Skip to content

Commit 0c9c1ea

Browse files
Wolfram Sanggregkh
authored andcommitted
serial: sh-sci: let timeout timer only run when DMA is scheduled
The hrtimer for RXDMA timeout was unconditionally restarted in the RXDMA complete handler ignoring the fact that setting up DMA may fail and PIO is used instead. Explicitly stop the timer when DMA is completed and only restart it when setting up DMA was successful. This makes the intention of the timer much clearer, the driver easier to understand and simplifies assumptions about the timer. The latter avoids race conditions if these assumptions were not met or confused. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://lore.kernel.org/r/20240506114016.30498-9-wsa+renesas@sang-engineering.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8efc440 commit 0c9c1ea

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/tty/serial/sh-sci.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,14 +1324,14 @@ static void sci_dma_rx_complete(void *arg)
13241324
dev_dbg(port->dev, "%s(%d) active cookie %d\n", __func__, port->line,
13251325
s->active_rx);
13261326

1327+
hrtimer_cancel(&s->rx_timer);
1328+
13271329
uart_port_lock_irqsave(port, &flags);
13281330

13291331
active = sci_dma_rx_find_active(s);
13301332
if (active >= 0)
13311333
count = sci_dma_rx_push(s, s->rx_buf[active], s->buf_len_rx);
13321334

1333-
start_hrtimer_us(&s->rx_timer, s->rx_timeout);
1334-
13351335
if (count)
13361336
tty_flip_buffer_push(&port->state->port);
13371337

@@ -1354,6 +1354,9 @@ static void sci_dma_rx_complete(void *arg)
13541354
uart_port_unlock_irqrestore(port, flags);
13551355
dev_dbg(port->dev, "%s: cookie %d #%d, new active cookie %d\n",
13561356
__func__, s->cookie_rx[active], active, s->active_rx);
1357+
1358+
start_hrtimer_us(&s->rx_timer, s->rx_timeout);
1359+
13571360
return;
13581361

13591362
fail:

0 commit comments

Comments
 (0)