aboutsummaryrefslogtreecommitdiff
path: root/drivers/tty
diff options
context:
space:
mode:
authorGravatar Wolfram Sang <wsa+renesas@sang-engineering.com> 2024-05-06 13:40:19 +0200
committerGravatar Greg Kroah-Hartman <gregkh@linuxfoundation.org> 2024-05-10 11:48:33 +0100
commit0c9c1ea583f1b9887d248dc26f6921c4ae826b96 (patch)
tree67200e17f0736c7f8138416764aebf408c529637 /drivers/tty
parentserial: sh-sci: describe locking requirements for invalidating RXDMA (diff)
downloadlinux-0c9c1ea583f1b9887d248dc26f6921c4ae826b96.tar.gz
linux-0c9c1ea583f1b9887d248dc26f6921c4ae826b96.tar.bz2
linux-0c9c1ea583f1b9887d248dc26f6921c4ae826b96.zip
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>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/sh-sci.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 7a7bc18e4705..d31b3aca5987 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1324,14 +1324,14 @@ static void sci_dma_rx_complete(void *arg)
dev_dbg(port->dev, "%s(%d) active cookie %d\n", __func__, port->line,
s->active_rx);
+ hrtimer_cancel(&s->rx_timer);
+
uart_port_lock_irqsave(port, &flags);
active = sci_dma_rx_find_active(s);
if (active >= 0)
count = sci_dma_rx_push(s, s->rx_buf[active], s->buf_len_rx);
- start_hrtimer_us(&s->rx_timer, s->rx_timeout);
-
if (count)
tty_flip_buffer_push(&port->state->port);
@@ -1354,6 +1354,9 @@ static void sci_dma_rx_complete(void *arg)
uart_port_unlock_irqrestore(port, flags);
dev_dbg(port->dev, "%s: cookie %d #%d, new active cookie %d\n",
__func__, s->cookie_rx[active], active, s->active_rx);
+
+ start_hrtimer_us(&s->rx_timer, s->rx_timeout);
+
return;
fail: