From 83ea0f7f80dec52a93afcc7374cd461881bf240f Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Tue, 18 Mar 2025 20:06:14 +1000 Subject: [PATCH] serial: stm32: fix dropped `UART_TX_DONE` events Fix dropped `UART_TX_DONE` events when poll out and async APIs are used on the same port. Clearing `tx_poll_stream_on` is required to prevent `uart_stm32_isr` from prematurely clearing the TC status bit. Signed-off-by: Jordan Yates --- drivers/serial/uart_stm32.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/serial/uart_stm32.c b/drivers/serial/uart_stm32.c index 13c85a5066d..191e4ebe5c0 100644 --- a/drivers/serial/uart_stm32.c +++ b/drivers/serial/uart_stm32.c @@ -1163,6 +1163,9 @@ static inline void async_evt_tx_done(struct uart_stm32_data *data) /* Reset tx buffer */ data->dma_tx.buffer_length = 0; data->dma_tx.counter = 0; +#ifdef CONFIG_PM + data->tx_int_stream_on = false; +#endif async_user_callback(data, &event); } @@ -1180,6 +1183,9 @@ static inline void async_evt_tx_abort(struct uart_stm32_data *data) /* Reset tx buffer */ data->dma_tx.buffer_length = 0; data->dma_tx.counter = 0; +#ifdef CONFIG_PM + data->tx_int_stream_on = false; +#endif async_user_callback(data, &event); } @@ -1603,6 +1609,10 @@ static int uart_stm32_async_tx(const struct device *dev, } #endif /* CONFIG_DCACHE */ +#ifdef CONFIG_PM + data->tx_poll_stream_on = false; + data->tx_int_stream_on = true; +#endif data->dma_tx.buffer = (uint8_t *)tx_data; data->dma_tx.buffer_length = buf_size; data->dma_tx.timeout = timeout;