Skip to content

Commit 4da6a49

Browse files
claudiubezneaopsiff
authored andcommitted
serial: sh-sci: Check that the DMA cookie is valid
mainline inclusion from mainline-v6.19-rc3 category: bugfix The driver updates struct sci_port::tx_cookie to zero right before the TX work is scheduled, or to -EINVAL when DMA is disabled. dma_async_is_complete(), called through dma_cookie_status() (and possibly through dmaengine_tx_status()), considers cookies valid only if they have values greater than or equal to 1. Passing zero or -EINVAL to dmaengine_tx_status() before any TX DMA transfer has started leads to an incorrect TX status being reported, as the cookie is invalid for the DMA subsystem. This may cause long wait times when the serial device is opened for configuration before any TX activity has occurred. Check that the TX cookie is valid before passing it to dmaengine_tx_status(). Fixes: 7cc0e0a ("serial: sh-sci: Check if TX data was written to device in .tx_empty()") Cc: stable <stable@kernel.org> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> Link: https://patch.msgid.link/20251217135759.402015-1-claudiu.beznea.uj@bp.renesas.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit c3ca8a0aac832fe8047608bb2ae2cca314c6d717) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 0d3594d commit 4da6a49

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/tty/serial/sh-sci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,7 @@ static void sci_dma_check_tx_occurred(struct sci_port *s)
17311731
struct dma_tx_state state;
17321732
enum dma_status status;
17331733

1734-
if (!s->chan_tx)
1734+
if (!s->chan_tx || s->cookie_tx <= 0)
17351735
return;
17361736

17371737
status = dmaengine_tx_status(s->chan_tx, s->cookie_tx, &state);

0 commit comments

Comments
 (0)