sched: remove all spin_lock_irqsave(NULL)

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5
2025-01-06 11:15:45 +08:00
committed by Xiang Xiao
parent 4e563e3a86
commit 57e54b399b
24 changed files with 97 additions and 60 deletions
+6 -5
View File
@@ -36,6 +36,7 @@
* Private Data
****************************************************************************/
static spinlock_t g_irqlock = SP_UNLOCKED;
#ifdef CONFIG_ARCH_MINIMAL_VECTORTABLE_DYNAMIC
static int g_irqmap_count = 1;
#endif
@@ -67,13 +68,13 @@ int irq_to_ndx(int irq)
{
DEBUGASSERT(g_irqmap_count < CONFIG_ARCH_NUSER_INTERRUPTS);
irqstate_t flags = spin_lock_irqsave(NULL);
irqstate_t flags = spin_lock_irqsave(&g_irqlock);
if (g_irqmap[irq] == 0)
{
g_irqmap[irq] = g_irqmap_count++;
}
spin_unlock_irqrestore(NULL, flags);
spin_unlock_irqrestore(&g_irqlock, flags);
return g_irqmap[irq];
}
#endif
@@ -107,7 +108,7 @@ int irq_attach(int irq, xcpt_t isr, FAR void *arg)
* to the unexpected interrupt handler.
*/
flags = spin_lock_irqsave(NULL);
flags = spin_lock_irqsave(&g_irqlock);
if (isr == NULL)
{
/* Disable the interrupt if we can before detaching it. We might
@@ -141,7 +142,7 @@ int irq_attach(int irq, xcpt_t isr, FAR void *arg)
if (is_irqchain(ndx, isr))
{
ret = irqchain_attach(ndx, isr, arg);
spin_unlock_irqrestore(NULL, flags);
spin_unlock_irqrestore(&g_irqlock, flags);
return ret;
}
#endif
@@ -156,7 +157,7 @@ int irq_attach(int irq, xcpt_t isr, FAR void *arg)
g_irqvector[ndx].count = 0;
#endif
spin_unlock_irqrestore(NULL, flags);
spin_unlock_irqrestore(&g_irqlock, flags);
ret = OK;
}
+8 -2
View File
@@ -57,6 +57,7 @@ static struct irqchain_s g_irqchainpool[CONFIG_PREALLOC_IRQCHAIN];
*/
static sq_queue_t g_irqchainfreelist;
static spinlock_t g_irqchainlock = SP_UNLOCKED;
/****************************************************************************
* Private Functions
@@ -146,13 +147,16 @@ int irqchain_attach(int ndx, xcpt_t isr, FAR void *arg)
{
FAR struct irqchain_s *node;
FAR struct irqchain_s *curr;
irqstate_t flags;
flags = spin_lock_irqsave(&g_irqchainlock);
if (isr != irq_unexpected_isr)
{
if (g_irqvector[ndx].handler != irqchain_dispatch)
{
if (sq_count(&g_irqchainfreelist) < 2)
{
spin_unlock_irqrestore(&g_irqchainlock, flags);
return -ENOMEM;
}
@@ -170,6 +174,7 @@ int irqchain_attach(int ndx, xcpt_t isr, FAR void *arg)
node = (FAR struct irqchain_s *)sq_remfirst(&g_irqchainfreelist);
if (node == NULL)
{
spin_unlock_irqrestore(&g_irqchainlock, flags);
return -ENOMEM;
}
@@ -190,6 +195,7 @@ int irqchain_attach(int ndx, xcpt_t isr, FAR void *arg)
irqchain_detach_all(ndx);
}
spin_unlock_irqrestore(&g_irqchainlock, flags);
return OK;
}
@@ -211,7 +217,7 @@ int irqchain_detach(int irq, xcpt_t isr, FAR void *arg)
return ndx;
}
flags = spin_lock_irqsave(NULL);
flags = spin_lock_irqsave(&g_irqchainlock);
if (g_irqvector[ndx].handler == irqchain_dispatch)
{
@@ -257,7 +263,7 @@ int irqchain_detach(int irq, xcpt_t isr, FAR void *arg)
ret = irq_detach(irq);
}
spin_unlock_irqrestore(NULL, flags);
spin_unlock_irqrestore(&g_irqchainlock, flags);
}
return ret;