diff --git a/arch/arm/src/efm32/efm32_spi.c b/arch/arm/src/efm32/efm32_spi.c index 0bf2c31a86..d0ae6d378a 100644 --- a/arch/arm/src/efm32/efm32_spi.c +++ b/arch/arm/src/efm32/efm32_spi.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -1640,6 +1641,13 @@ static int spi_portinitialize(struct efm32_spidev_s *priv) (void)sem_init(&priv->rxdmasem, 0, 0); (void)sem_init(&priv->txdmasem, 0, 0); + + /* These semaphores are used for signaling and, hence, should not have + * priority inheritance enabled. + */ + + sem_setprotocol(&priv->rxdmasem, SEM_PRIO_NONE); + sem_setprotocol(&priv->txdmasem, SEM_PRIO_NONE); #endif /* Enable SPI */ diff --git a/arch/arm/src/imx1/imx_spi.c b/arch/arm/src/imx1/imx_spi.c index fb58314386..d63c65ed2e 100644 --- a/arch/arm/src/imx1/imx_spi.c +++ b/arch/arm/src/imx1/imx_spi.c @@ -50,6 +50,7 @@ #include #include +#include #include #include "up_internal.h" @@ -1116,7 +1117,13 @@ FAR struct spi_dev_s *imx_spibus_initialize(int port) /* Initialize the state structure */ #ifndef CONFIG_SPI_POLLWAIT + /* Initialize the semaphore that is used to wake up the waiting + * thread when the DMA transfer completes. This semaphore is used for + * signaling and, hence, should not have priority inheritance enabled. + */ + sem_init(&priv->waitsem, 0, 0); + sem_setprotocol(&priv->waitsem, SEM_PRIO_NONE); #endif sem_init(&priv->exclsem, 0, 1); diff --git a/arch/arm/src/sam34/sam_spi.c b/arch/arm/src/sam34/sam_spi.c index 4b7f1dba7e..2cbe3614b6 100644 --- a/arch/arm/src/sam34/sam_spi.c +++ b/arch/arm/src/sam34/sam_spi.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include "up_internal.h" @@ -1882,10 +1883,12 @@ struct spi_dev_s *sam_spibus_initialize(int port) #ifdef CONFIG_SAM34_SPI_DMA /* Initialize the SPI semaphore that is used to wake up the waiting - * thread when the DMA transfer completes. + * thread when the DMA transfer completes. This semaphore is used for + * signaling and, hence, should not have priority inheritance enabled. */ sem_init(&spics->dmawait, 0, 0); + sem_setprotocol(&spics->dmawait, SEM_PRIO_NONE); /* Create a watchdog time to catch DMA timeouts */ diff --git a/arch/arm/src/sama5/sam_spi.c b/arch/arm/src/sama5/sam_spi.c index 0386fcc681..459e949cad 100644 --- a/arch/arm/src/sama5/sam_spi.c +++ b/arch/arm/src/sama5/sam_spi.c @@ -60,6 +60,7 @@ #include #include #include +#include #include #include "up_internal.h" @@ -1810,10 +1811,12 @@ struct spi_dev_s *sam_spibus_initialize(int port) #ifdef CONFIG_SAMA5_SPI_DMA /* Initialize the SPI semaphore that is used to wake up the waiting - * thread when the DMA transfer completes. + * thread when the DMA transfer completes. This semaphore is used for + * signaling and, hence, should not have priority inheritance enabled. */ sem_init(&spics->dmawait, 0, 0); + sem_setprotocol(&spics->dmawait, SEM_PRIO_NONE); /* Create a watchdog time to catch DMA timeouts */ diff --git a/arch/arm/src/samv7/sam_qspi.c b/arch/arm/src/samv7/sam_qspi.c index b90a515d8b..a37245c7e6 100644 --- a/arch/arm/src/samv7/sam_qspi.c +++ b/arch/arm/src/samv7/sam_qspi.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include "up_internal.h" @@ -1790,10 +1791,12 @@ struct qspi_dev_s *sam_qspi_initialize(int intf) } /* Initialize the QSPI semaphore that is used to wake up the waiting - * thread when the DMA transfer completes. + * thread when the DMA transfer completes. This semaphore is used for + * signaling and, hence, should not have priority inheritance enabled. */ sem_init(&priv->dmawait, 0, 0); + sem_setprotocol(&priv->dmawait, SEM_PRIO_NONE); /* Create a watchdog time to catch DMA timeouts */ diff --git a/arch/arm/src/samv7/sam_spi.c b/arch/arm/src/samv7/sam_spi.c index 959a3cd290..d0b40e8694 100644 --- a/arch/arm/src/samv7/sam_spi.c +++ b/arch/arm/src/samv7/sam_spi.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include "up_internal.h" @@ -2164,10 +2165,12 @@ FAR struct spi_dev_s *sam_spibus_initialize(int port) #ifdef CONFIG_SAMV7_SPI_DMA /* Initialize the SPI semaphore that is used to wake up the waiting - * thread when the DMA transfer completes. + * thread when the DMA transfer completes. This semaphore is used for + * signaling and, hence, should not have priority inheritance enabled. */ sem_init(&spics->dmawait, 0, 0); + sem_setprotocol(&spics->dmawait, SEM_PRIO_NONE); /* Create a watchdog time to catch DMA timeouts */ diff --git a/arch/arm/src/stm32/stm32_spi.c b/arch/arm/src/stm32/stm32_spi.c index c70bf8f6f1..ad6d2fc47c 100644 --- a/arch/arm/src/stm32/stm32_spi.c +++ b/arch/arm/src/stm32/stm32_spi.c @@ -70,6 +70,7 @@ #include #include +#include #include #include @@ -1719,12 +1720,18 @@ static void spi_bus_initialize(FAR struct stm32_spidev_s *priv) sem_init(&priv->exclsem, 0, 1); - /* Initialize the SPI semaphores that is used to wait for DMA completion */ - #ifdef CONFIG_STM32_SPI_DMA + /* Initialize the SPI semaphores that is used to wait for DMA completion. + * This semaphore is used for signaling and, hence, should not have + * priority inheritance enabled. + */ + sem_init(&priv->rxsem, 0, 0); sem_init(&priv->txsem, 0, 0); + sem_setprotocol(&priv->rxsem, SEM_PRIO_NONE); + sem_setprotocol(&priv->txsem, SEM_PRIO_NONE); + /* Get DMA channels. NOTE: stm32_dmachannel() will always assign the DMA channel. * if the channel is not available, then stm32_dmachannel() will block and wait * until the channel becomes available. WARNING: If you have another device sharing diff --git a/arch/arm/src/stm32f7/stm32_spi.c b/arch/arm/src/stm32f7/stm32_spi.c index 4b0fceba54..c00e717a09 100644 --- a/arch/arm/src/stm32f7/stm32_spi.c +++ b/arch/arm/src/stm32f7/stm32_spi.c @@ -72,6 +72,7 @@ #include #include +#include #include #include @@ -1665,16 +1666,22 @@ static void spi_bus_initialize(FAR struct stm32_spidev_s *priv) spi_putreg(priv, STM32_SPI_CRCPR_OFFSET, 7); - /* Initialize the SPI semaphore that enforces mutually exclusive access */ + /* Initialize the SPI semaphore that enforces mutually exclusive access. */ sem_init(&priv->exclsem, 0, 1); - /* Initialize the SPI semaphores that is used to wait for DMA completion */ - #ifdef CONFIG_STM32F7_SPI_DMA + /* Initialize the SPI semaphores that is used to wait for DMA completion. + * This semaphore is used for signaling and, hence, should not have + * priority inheritance enabled. + */ + sem_init(&priv->rxsem, 0, 0); sem_init(&priv->txsem, 0, 0); + sem_setprotocol(&priv->rxsem, SEM_PRIO_NONE); + sem_setprotocol(&priv->txsem, SEM_PRIO_NONE); + /* Get DMA channels. NOTE: stm32_dmachannel() will always assign the DMA channel. * if the channel is not available, then stm32_dmachannel() will block and wait * until the channel becomes available. WARNING: If you have another device sharing diff --git a/arch/arm/src/stm32l4/stm32l4_qspi.c b/arch/arm/src/stm32l4/stm32l4_qspi.c index db01e22bba..95d2da540b 100644 --- a/arch/arm/src/stm32l4/stm32l4_qspi.c +++ b/arch/arm/src/stm32l4/stm32l4_qspi.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include "up_internal.h" @@ -2501,10 +2502,12 @@ struct qspi_dev_s *stm32l4_qspi_initialize(int intf) } /* Initialize the QSPI semaphore that is used to wake up the waiting - * thread when the DMA transfer completes. + * thread when the DMA transfer completes. This semaphore is used for + * signaling and, hence, should not have priority inheritance enabled. */ sem_init(&priv->dmawait, 0, 0); + sem_setprotocol(&priv->dmawait, SEM_PRIO_NONE); /* Create a watchdog time to catch DMA timeouts */ @@ -2526,10 +2529,13 @@ struct qspi_dev_s *stm32l4_qspi_initialize(int intf) goto errout_with_dmadog; } - /* Initialize the semaphore that blocks until the operation completes */ + /* Initialize the semaphore that blocks until the operation completes. + * This semaphore is used for signaling and, hence, should not have + * priority inheritance enabled. + */ sem_init(&priv->op_sem, 0, 0); - + sem_setprotocol(&priv->op_sem, SEM_PRIO_NONE); #endif /* Perform hardware initialization. Puts the QSPI into an active diff --git a/arch/arm/src/stm32l4/stm32l4_spi.c b/arch/arm/src/stm32l4/stm32l4_spi.c index bc61ed7446..9d9db706e0 100644 --- a/arch/arm/src/stm32l4/stm32l4_spi.c +++ b/arch/arm/src/stm32l4/stm32l4_spi.c @@ -76,6 +76,7 @@ #include #include +#include #include #include @@ -1517,6 +1518,13 @@ static void spi_bus_initialize(FAR struct stm32l4_spidev_s *priv) sem_init(&priv->rxsem, 0, 0); sem_init(&priv->txsem, 0, 0); + /* These semaphores are used for signaling and, hence, should not have + * priority inheritance enabled. + */ + + sem_setprotocol(&priv->rxsem, SEM_PRIO_NONE); + sem_setprotocol(&priv->txsem, SEM_PRIO_NONE); + /* Get DMA channels. NOTE: stm32l4_dmachannel() will always assign the DMA channel. * if the channel is not available, then stm32l4_dmachannel() will block and wait * until the channel becomes available. WARNING: If you have another device sharing