mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 04:52:02 +08:00
arch: Disable priority inheritance on all semaphores used for signaling in all RNG drivers
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user