Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reapply "sched/spinlock: remove nesting spinlock support" #14203

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 6 additions & 29 deletions include/nuttx/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,6 @@ void sched_note_spinlock_unlock(FAR volatile spinlock_t *spinlock);

extern volatile spinlock_t g_irq_spin;

/* Handles nested calls to spin_lock_irqsave and spin_unlock_irqrestore */

extern volatile uint8_t g_irq_spin_count[CONFIG_SMP_NCPUS];

/****************************************************************************
* Name: up_testset
*
Expand Down Expand Up @@ -531,14 +527,7 @@ irqstate_t spin_lock_irqsave_wo_note(FAR volatile spinlock_t *lock)

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]);
spin_lock_wo_note(&g_irq_spin);
}
else
{
Expand All @@ -557,10 +546,7 @@ irqstate_t spin_lock_irqsave_wo_note(FAR volatile spinlock_t *lock)
* Description:
* If SMP is enabled:
* If the argument lock is not specified (i.e. NULL),
* disable local interrupts and take the global spinlock (g_irq_spin)
* if the call counter (g_irq_spin_count[cpu]) equals to 0. Then the
* counter on the CPU is incremented to allow nested calls and return
* the interrupt state.
* disable local interrupts and take the global spinlock (g_irq_spin).
*
* If the argument lock is specified,
* disable local interrupts and take the lock spinlock and return
Expand Down Expand Up @@ -698,14 +684,7 @@ void spin_unlock_irqrestore_wo_note(FAR volatile spinlock_t *lock,
{
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);
}
spin_unlock_wo_note(&g_irq_spin);
}
else
{
Expand All @@ -723,11 +702,9 @@ void spin_unlock_irqrestore_wo_note(FAR volatile spinlock_t *lock,
*
* Description:
* If SMP is enabled:
* If the argument lock is not specified (i.e. NULL),
* decrement the call counter (g_irq_spin_count[cpu]) and if it
* decrements to zero then release the spinlock (g_irq_spin) and
* restore the interrupt state as it was prior to the previous call to
* spin_lock_irqsave(NULL).
* If the argument lock is not specified (i.e. NULL), release the
* spinlock (g_irq_spin) and restore the interrupt state as it was
* prior to the previous call to spin_lock_irqsave(NULL).
*
* If the argument lock is specified, release the lock and
* restore the interrupt state as it was prior to the previous call to
Expand Down
4 changes: 0 additions & 4 deletions sched/irq/irq_spinlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@

volatile spinlock_t g_irq_spin = SP_UNLOCKED;

/* Handles nested calls to spin_lock_irqsave and spin_unlock_irqrestore */

volatile uint8_t g_irq_spin_count[CONFIG_SMP_NCPUS];

#ifdef CONFIG_RW_SPINLOCK
/* Used for access control */

Expand Down
Loading