mirror of
https://github.com/apache/nuttx.git
synced 2026-10-06 22:05:21 +00:00
sched/irq: Reject worked IRQs without a work queue.
Return ENOMEM and leave the IRQ detached when no custom work queue can be created or all queue slots are occupied. Also release the queue mutex on the full-table path and avoid caching a failed queue creation. Assisted-by: OpenAI Codex Signed-off-by: yushuailong <yyyusl@qq.com>
This commit is contained in:
parent
6d2443924f
commit
4621d75e2d
1 changed files with 18 additions and 8 deletions
|
|
@ -88,7 +88,6 @@ inline_function FAR struct kwork_wqueue_s *irq_get_wqueue(int priority)
|
|||
|
||||
if (wqueue_priority == priority)
|
||||
{
|
||||
nxmutex_unlock(&irq_wqueue_lock);
|
||||
queue = irq_wqueue[i];
|
||||
break;
|
||||
}
|
||||
|
|
@ -99,10 +98,13 @@ inline_function FAR struct kwork_wqueue_s *irq_get_wqueue(int priority)
|
|||
queue = work_queue_create("isrwork", priority, irq_work_stack[i],
|
||||
CONFIG_IRQ_WORK_STACKSIZE, 1);
|
||||
|
||||
irq_wqueue[i] = queue;
|
||||
nxmutex_unlock(&irq_wqueue_lock);
|
||||
if (queue != NULL)
|
||||
{
|
||||
irq_wqueue[i] = queue;
|
||||
}
|
||||
}
|
||||
|
||||
nxmutex_unlock(&irq_wqueue_lock);
|
||||
return queue;
|
||||
}
|
||||
|
||||
|
|
@ -176,6 +178,7 @@ int irq_attach_wqueue(int irq, xcpt_t isr, xcpt_t isrwork,
|
|||
int ret = OK;
|
||||
#if NR_IRQS > 0
|
||||
int ndx = IRQ_TO_NDX(irq);
|
||||
|
||||
if (ndx < 0)
|
||||
{
|
||||
ret = ndx;
|
||||
|
|
@ -196,16 +199,23 @@ int irq_attach_wqueue(int irq, xcpt_t isr, xcpt_t isrwork,
|
|||
}
|
||||
else
|
||||
{
|
||||
info->isrwork = isrwork;
|
||||
info->handler = isr;
|
||||
info->arg = arg;
|
||||
info->irq = irq;
|
||||
if (info->wqueue == NULL)
|
||||
{
|
||||
info->wqueue = irq_get_wqueue(priority);
|
||||
}
|
||||
|
||||
irq_attach(irq, irq_default_handler, info);
|
||||
if (info->wqueue == NULL)
|
||||
{
|
||||
ret = -ENOMEM;
|
||||
}
|
||||
else
|
||||
{
|
||||
info->isrwork = isrwork;
|
||||
info->handler = isr;
|
||||
info->arg = arg;
|
||||
info->irq = irq;
|
||||
ret = irq_attach(irq, irq_default_handler, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* NR_IRQS */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue