diff --git a/include/nuttx/spinlock.h b/include/nuttx/spinlock.h index 544352ef53..4d77b8611f 100644 --- a/include/nuttx/spinlock.h +++ b/include/nuttx/spinlock.h @@ -390,6 +390,16 @@ irqstate_t spin_lock_irqsave(spinlock_t *lock); # define spin_lock_irqsave(l) ((void)(l), up_irq_save()) #endif +/**************************************************************************** + * Name: spin_lock_irqsave_wo_note + ****************************************************************************/ + +#if defined(CONFIG_SMP) +irqstate_t spin_lock_irqsave_wo_note(spinlock_t *lock); +#else +# define spin_lock_irqsave_wo_note(l) ((void)(l), up_irq_save()) +#endif + /**************************************************************************** * Name: spin_unlock_irqrestore * @@ -425,4 +435,14 @@ void spin_unlock_irqrestore(spinlock_t *lock, irqstate_t flags); # define spin_unlock_irqrestore(l, f) up_irq_restore(f) #endif +/**************************************************************************** + * Name: spin_unlock_irqrestore_wo_note + ****************************************************************************/ + +#if defined(CONFIG_SMP) +void spin_unlock_irqrestore_wo_note(spinlock_t *lock, irqstate_t flags); +#else +# define spin_unlock_irqrestore_wo_note(l, f) up_irq_restore(f) +#endif + #endif /* __INCLUDE_NUTTX_SPINLOCK_H */ diff --git a/sched/irq/irq_spinlock.c b/sched/irq/irq_spinlock.c index c828b57ca5..8c4f11eb68 100644 --- a/sched/irq/irq_spinlock.c +++ b/sched/irq/irq_spinlock.c @@ -106,6 +106,34 @@ irqstate_t spin_lock_irqsave(spinlock_t *lock) return ret; } +/**************************************************************************** + * Name: spin_lock_irqsave_wo_note + ****************************************************************************/ + +irqstate_t spin_lock_irqsave_wo_note(spinlock_t *lock) +{ + irqstate_t ret; + ret = up_irq_save(); + + if (NULL == lock) + { + int me = this_cpu(); + if (0 == g_irq_spin_count[me]) + { + spin_lock_wo_note(&g_irq_spin); + } + + g_irq_spin_count[me]++; + DEBUGASSERT(0 != g_irq_spin_count[me]); + } + else + { + spin_lock_wo_note(lock); + } + + return ret; +} + /**************************************************************************** * Name: spin_unlock_irqrestore * @@ -156,4 +184,29 @@ void spin_unlock_irqrestore(spinlock_t *lock, irqstate_t flags) up_irq_restore(flags); } +/**************************************************************************** + * Name: spin_lock_irqsave_wo_note + ****************************************************************************/ + +void spin_unlock_irqrestore_wo_note(spinlock_t *lock, irqstate_t flags) +{ + if (NULL == lock) + { + int me = this_cpu(); + DEBUGASSERT(0 < g_irq_spin_count[me]); + g_irq_spin_count[me]--; + + if (0 == g_irq_spin_count[me]) + { + spin_unlock_wo_note(&g_irq_spin); + } + } + else + { + spin_unlock_wo_note(lock); + } + + up_irq_restore(flags); +} + #endif /* CONFIG_SMP */