This is an automated email from the ASF dual-hosted git repository.

davids5 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 660ac63b92 stm32h7/serial: Do not wait on TXDMA semaphore
660ac63b92 is described below

commit 660ac63b9244372e9fc5aeca10677aabc8f5e0db
Author: Niklas Hauser <[email protected]>
AuthorDate: Wed Nov 8 14:52:59 2023 +0100

    stm32h7/serial: Do not wait on TXDMA semaphore
    
    If using flow control with a high CTS the thread may be blocked forever
    on the second transmit attempt due to waiting on the txdma semaphore.
    The calling thread can then never make progress and release any
    resources it has taken, thus may cause a deadlock in other parts of the
    system.
    
    The implementation differs in behavior from interrupt-driven TX and the
    STM32F7 TXDMA . It should not implicitly wait on a taken semaphore but
    return immediately and let the upper layers decide on what to do next.
---
 arch/arm/src/stm32h7/stm32_serial.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/arm/src/stm32h7/stm32_serial.c 
b/arch/arm/src/stm32h7/stm32_serial.c
index 4b8048ed58..75971f1a11 100644
--- a/arch/arm/src/stm32h7/stm32_serial.c
+++ b/arch/arm/src/stm32h7/stm32_serial.c
@@ -3369,9 +3369,11 @@ static void up_dma_txavailable(struct uart_dev_s *dev)
 
   /* Only send when the DMA is idle */
 
-  nxsem_wait(&priv->txdmasem);
-
-  uart_xmitchars_dma(dev);
+  int rv = nxsem_trywait(&priv->txdmasem);
+  if (rv == OK)
+    {
+      uart_xmitchars_dma(dev);
+    }
 }
 #endif
 

Reply via email to