Skip to content

Commit

Permalink
[BACKPORT] stm32h7/serial: Do not wait on TXDMA semaphore
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
niklaut authored and davids5 committed Nov 8, 2023
1 parent 8eb962d commit ed4814f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions arch/arm/src/stm32h7/stm32_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -3376,9 +3376,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

Expand Down

0 comments on commit ed4814f

Please sign in to comment.