mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
arch: Disable priority inheritance on all semaphores used for signaling in all SPI drivers
This commit is contained in:
@@ -53,6 +53,7 @@
|
|||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/wdog.h>
|
#include <nuttx/wdog.h>
|
||||||
#include <nuttx/clock.h>
|
#include <nuttx/clock.h>
|
||||||
|
#include <nuttx/semaphore.h>
|
||||||
#include <nuttx/spi/spi.h>
|
#include <nuttx/spi/spi.h>
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
@@ -1640,6 +1641,13 @@ static int spi_portinitialize(struct efm32_spidev_s *priv)
|
|||||||
|
|
||||||
(void)sem_init(&priv->rxdmasem, 0, 0);
|
(void)sem_init(&priv->rxdmasem, 0, 0);
|
||||||
(void)sem_init(&priv->txdmasem, 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
|
#endif
|
||||||
|
|
||||||
/* Enable SPI */
|
/* Enable SPI */
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
#include <nuttx/spi/spi.h>
|
#include <nuttx/spi/spi.h>
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
#include <nuttx/semaphore.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
@@ -1116,7 +1117,13 @@ FAR struct spi_dev_s *imx_spibus_initialize(int port)
|
|||||||
/* Initialize the state structure */
|
/* Initialize the state structure */
|
||||||
|
|
||||||
#ifndef CONFIG_SPI_POLLWAIT
|
#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_init(&priv->waitsem, 0, 0);
|
||||||
|
sem_setprotocol(&priv->waitsem, SEM_PRIO_NONE);
|
||||||
#endif
|
#endif
|
||||||
sem_init(&priv->exclsem, 0, 1);
|
sem_init(&priv->exclsem, 0, 1);
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,7 @@
|
|||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/wdog.h>
|
#include <nuttx/wdog.h>
|
||||||
#include <nuttx/clock.h>
|
#include <nuttx/clock.h>
|
||||||
|
#include <nuttx/semaphore.h>
|
||||||
#include <nuttx/spi/spi.h>
|
#include <nuttx/spi/spi.h>
|
||||||
|
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
@@ -1882,10 +1883,12 @@ struct spi_dev_s *sam_spibus_initialize(int port)
|
|||||||
|
|
||||||
#ifdef CONFIG_SAM34_SPI_DMA
|
#ifdef CONFIG_SAM34_SPI_DMA
|
||||||
/* Initialize the SPI semaphore that is used to wake up the waiting
|
/* 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_init(&spics->dmawait, 0, 0);
|
||||||
|
sem_setprotocol(&spics->dmawait, SEM_PRIO_NONE);
|
||||||
|
|
||||||
/* Create a watchdog time to catch DMA timeouts */
|
/* Create a watchdog time to catch DMA timeouts */
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,7 @@
|
|||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/wdog.h>
|
#include <nuttx/wdog.h>
|
||||||
#include <nuttx/clock.h>
|
#include <nuttx/clock.h>
|
||||||
|
#include <nuttx/semaphore.h>
|
||||||
#include <nuttx/spi/spi.h>
|
#include <nuttx/spi/spi.h>
|
||||||
|
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
@@ -1810,10 +1811,12 @@ struct spi_dev_s *sam_spibus_initialize(int port)
|
|||||||
|
|
||||||
#ifdef CONFIG_SAMA5_SPI_DMA
|
#ifdef CONFIG_SAMA5_SPI_DMA
|
||||||
/* Initialize the SPI semaphore that is used to wake up the waiting
|
/* 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_init(&spics->dmawait, 0, 0);
|
||||||
|
sem_setprotocol(&spics->dmawait, SEM_PRIO_NONE);
|
||||||
|
|
||||||
/* Create a watchdog time to catch DMA timeouts */
|
/* Create a watchdog time to catch DMA timeouts */
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@
|
|||||||
#include <nuttx/wdog.h>
|
#include <nuttx/wdog.h>
|
||||||
#include <nuttx/clock.h>
|
#include <nuttx/clock.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/semaphore.h>
|
||||||
#include <nuttx/spi/qspi.h>
|
#include <nuttx/spi/qspi.h>
|
||||||
|
|
||||||
#include "up_internal.h"
|
#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
|
/* 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_init(&priv->dmawait, 0, 0);
|
||||||
|
sem_setprotocol(&priv->dmawait, SEM_PRIO_NONE);
|
||||||
|
|
||||||
/* Create a watchdog time to catch DMA timeouts */
|
/* Create a watchdog time to catch DMA timeouts */
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,7 @@
|
|||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/wdog.h>
|
#include <nuttx/wdog.h>
|
||||||
#include <nuttx/clock.h>
|
#include <nuttx/clock.h>
|
||||||
|
#include <nuttx/semaphore.h>
|
||||||
#include <nuttx/spi/spi.h>
|
#include <nuttx/spi/spi.h>
|
||||||
|
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
@@ -2164,10 +2165,12 @@ FAR struct spi_dev_s *sam_spibus_initialize(int port)
|
|||||||
|
|
||||||
#ifdef CONFIG_SAMV7_SPI_DMA
|
#ifdef CONFIG_SAMV7_SPI_DMA
|
||||||
/* Initialize the SPI semaphore that is used to wake up the waiting
|
/* 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_init(&spics->dmawait, 0, 0);
|
||||||
|
sem_setprotocol(&spics->dmawait, SEM_PRIO_NONE);
|
||||||
|
|
||||||
/* Create a watchdog time to catch DMA timeouts */
|
/* Create a watchdog time to catch DMA timeouts */
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,7 @@
|
|||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/semaphore.h>
|
||||||
#include <nuttx/spi/spi.h>
|
#include <nuttx/spi/spi.h>
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
@@ -1719,12 +1720,18 @@ static void spi_bus_initialize(FAR struct stm32_spidev_s *priv)
|
|||||||
|
|
||||||
sem_init(&priv->exclsem, 0, 1);
|
sem_init(&priv->exclsem, 0, 1);
|
||||||
|
|
||||||
/* Initialize the SPI semaphores that is used to wait for DMA completion */
|
|
||||||
|
|
||||||
#ifdef CONFIG_STM32_SPI_DMA
|
#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->rxsem, 0, 0);
|
||||||
sem_init(&priv->txsem, 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.
|
/* 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
|
* 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
|
* until the channel becomes available. WARNING: If you have another device sharing
|
||||||
|
|||||||
@@ -72,6 +72,7 @@
|
|||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/semaphore.h>
|
||||||
#include <nuttx/spi/spi.h>
|
#include <nuttx/spi/spi.h>
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
@@ -1665,16 +1666,22 @@ static void spi_bus_initialize(FAR struct stm32_spidev_s *priv)
|
|||||||
|
|
||||||
spi_putreg(priv, STM32_SPI_CRCPR_OFFSET, 7);
|
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);
|
sem_init(&priv->exclsem, 0, 1);
|
||||||
|
|
||||||
/* Initialize the SPI semaphores that is used to wait for DMA completion */
|
|
||||||
|
|
||||||
#ifdef CONFIG_STM32F7_SPI_DMA
|
#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->rxsem, 0, 0);
|
||||||
sem_init(&priv->txsem, 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.
|
/* 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
|
* 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
|
* until the channel becomes available. WARNING: If you have another device sharing
|
||||||
|
|||||||
@@ -55,6 +55,7 @@
|
|||||||
#include <nuttx/wdog.h>
|
#include <nuttx/wdog.h>
|
||||||
#include <nuttx/clock.h>
|
#include <nuttx/clock.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/semaphore.h>
|
||||||
#include <nuttx/spi/qspi.h>
|
#include <nuttx/spi/qspi.h>
|
||||||
|
|
||||||
#include "up_internal.h"
|
#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
|
/* 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_init(&priv->dmawait, 0, 0);
|
||||||
|
sem_setprotocol(&priv->dmawait, SEM_PRIO_NONE);
|
||||||
|
|
||||||
/* Create a watchdog time to catch DMA timeouts */
|
/* 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;
|
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_init(&priv->op_sem, 0, 0);
|
||||||
|
sem_setprotocol(&priv->op_sem, SEM_PRIO_NONE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Perform hardware initialization. Puts the QSPI into an active
|
/* Perform hardware initialization. Puts the QSPI into an active
|
||||||
|
|||||||
@@ -76,6 +76,7 @@
|
|||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/semaphore.h>
|
||||||
#include <nuttx/spi/spi.h>
|
#include <nuttx/spi/spi.h>
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
@@ -1517,6 +1518,13 @@ static void spi_bus_initialize(FAR struct stm32l4_spidev_s *priv)
|
|||||||
sem_init(&priv->rxsem, 0, 0);
|
sem_init(&priv->rxsem, 0, 0);
|
||||||
sem_init(&priv->txsem, 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.
|
/* 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
|
* 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
|
* until the channel becomes available. WARNING: If you have another device sharing
|
||||||
|
|||||||
Reference in New Issue
Block a user