diff --git a/arch/arm/src/stm32/stm32_spi.c b/arch/arm/src/stm32/stm32_spi.c index 48f2e908b1a34..4c91a9b25ad28 100644 --- a/arch/arm/src/stm32/stm32_spi.c +++ b/arch/arm/src/stm32/stm32_spi.c @@ -800,7 +800,15 @@ static inline bool spi_16bitmode(FAR struct stm32_spidev_s *priv) #ifdef CONFIG_STM32_SPI_DMA static void spi_dmarxwait(FAR struct stm32_spidev_s *priv) { - nxsem_wait_uninterruptible(&priv->rxsem); + /* Take the semaphore (perhaps waiting). If the result is zero, then the DMA + * must not really have completed??? + */ + + do + { + nxsem_wait_uninterruptible(&priv->rxsem); + } + while (priv->rxresult == 0); } #endif @@ -815,7 +823,15 @@ static void spi_dmarxwait(FAR struct stm32_spidev_s *priv) #ifdef CONFIG_STM32_SPI_DMA static void spi_dmatxwait(FAR struct stm32_spidev_s *priv) { - nxsem_wait_uninterruptible(&priv->txsem); + /* Take the semaphore (perhaps waiting). If the result is zero, then the DMA + * must not really have completed??? + */ + + do + { + nxsem_wait_uninterruptible(&priv->txsem); + } + while (priv->txresult == 0); } #endif diff --git a/arch/arm/src/stm32h7/stm32_spi.c b/arch/arm/src/stm32h7/stm32_spi.c index f90578d3ebc2d..513994bd0aa4e 100644 --- a/arch/arm/src/stm32h7/stm32_spi.c +++ b/arch/arm/src/stm32h7/stm32_spi.c @@ -853,7 +853,15 @@ static void spi_dmarxwait(FAR struct stm32_spidev_s *priv) #ifdef CONFIG_STM32H7_SPI_DMA static void spi_dmatxwait(FAR struct stm32_spidev_s *priv) { - nxsem_wait_uninterruptible(&priv->txsem); + /* Take the semaphore (perhaps waiting). If the result is zero, then the DMA + * must not really have completed??? + */ + + do + { + nxsem_wait_uninterruptible(&priv->txsem); + } + while (priv->txresult == 0); } #endif diff --git a/arch/arm/src/stm32l4/stm32l4_spi.c b/arch/arm/src/stm32l4/stm32l4_spi.c index 76a37243487ee..c91218ae97add 100644 --- a/arch/arm/src/stm32l4/stm32l4_spi.c +++ b/arch/arm/src/stm32l4/stm32l4_spi.c @@ -637,7 +637,15 @@ static void spi_dmarxwait(FAR struct stm32l4_spidev_s *priv) #ifdef CONFIG_STM32L4_SPI_DMA static void spi_dmatxwait(FAR struct stm32l4_spidev_s *priv) { - nxsem_wait_uninterruptible(&priv->txsem); + /* Take the semaphore (perhaps waiting). If the result is zero, then the DMA + * must not really have completed??? + */ + + do + { + nxsem_wait_uninterruptible(&priv->txsem); + } + while (priv->txresult == 0); } #endif