arch: Disable priority inheritance on all semaphores used for signaling in all RNG drivers

This commit is contained in:
Gregory Nutt
2016-11-03 17:19:51 -06:00
parent 77a0b6c26a
commit d8fecba333
3 changed files with 26 additions and 2 deletions
+10
View File
@@ -52,6 +52,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/semaphore.h>
#include <nuttx/fs/fs.h>
#include <nuttx/drivers/drivers.h>
@@ -352,9 +353,18 @@ static int sam_rng_initialize(void)
/* Initialize the device structure */
memset(&g_trngdev, 0, sizeof(struct trng_dev_s));
/* Initialize semphores */
sem_init(&g_trngdev.exclsem, 0, 1);
sem_init(&g_trngdev.waitsem, 0, 0);
/* The waitsem semaphore is used for signaling and, hence, should not have
* priority inheritance enabled.
*/
sem_setprotocol(&g_trngdev.waitsem, SEM_PRIO_NONE);
/* Enable clocking to the TRNG */
sam_trng_enableclk();
+10
View File
@@ -53,6 +53,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/semaphore.h>
#include <nuttx/fs/fs.h>
#include <nuttx/drivers/drivers.h>
@@ -353,9 +354,18 @@ static int sam_rng_initialize(void)
/* Initialize the device structure */
memset(&g_trngdev, 0, sizeof(struct trng_dev_s));
/* Initialize semaphores */
sem_init(&g_trngdev.exclsem, 0, 1);
sem_init(&g_trngdev.waitsem, 0, 0);
/* The waitsem semaphore is used for signaling and, hence, should not have
* priority inheritance enabled.
*/
sem_setprotocol(&g_trngdev.waitsem, SEM_PRIO_NONE);
/* Enable clocking to the TRNG */
sam_trng_enableclk();
+6 -2
View File
@@ -47,6 +47,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <nuttx/semaphore.h>
#include <nuttx/fs/fs.h>
#include <nuttx/drivers/drivers.h>
@@ -259,11 +260,14 @@ static ssize_t stm32l4_rngread(struct file *filep, char *buffer, size_t buflen)
{
/* We've got the device semaphore, proceed with reading */
/* Initialize the operation semaphore with 0 for blocking until
* the buffer is filled from interrupts.
/* Initialize the operation semaphore with 0 for blocking until the
* buffer is filled from interrupts. The waitsem semaphore is used
* for signaling and, hence, should not have priority inheritance
* enabled.
*/
sem_init(&g_rngdev.rd_readsem, 0, 0);
sem_setprotocol(&g_rngdev.rd_readsem, SEM_PRIO_NONE);
g_rngdev.rd_buflen = buflen;
g_rngdev.rd_buf = buffer;