sched/irq: add spin_unlock_irqsave/irqrestore_wo_note

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
yinshengkai 2022-12-28 14:30:38 +08:00 committed by Xiang Xiao
parent f33dc4df3f
commit 81448b5021
2 changed files with 73 additions and 0 deletions

View File

@ -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 */

View File

@ -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 */