This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 8f113d68e90757ff60b0f961ea13693a7757b433
Author: yukangzhi <[email protected]>
AuthorDate: Thu Dec 18 11:58:11 2025 +0800

    irq: Modify the behavior of irq_unexpected_isr.
    
    Whether an unexpected irq caused by software or hardware, sometimes we
    don't want the system to panic immediately. Instead, we try to output
    an error log and close this irq.
    
    Add CONFIG_IRQ_UNEXPECTED_PANIC. It defaults to y, which keeps the
    current behavior (panic). Architectures with CONFIG_ARCH_NOINTC have no
    up_disable_irq(), so they always panic.
    
    Signed-off-by: yukangzhi <[email protected]>
---
 sched/Kconfig                 | 10 ++++++++++
 sched/irq/irq_unexpectedisr.c |  8 +++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/sched/Kconfig b/sched/Kconfig
index f3686ae84ce..59a712e616f 100644
--- a/sched/Kconfig
+++ b/sched/Kconfig
@@ -396,6 +396,16 @@ config PREALLOC_IRQCHAIN
 
 endif # IRQCHAIN
 
+config IRQ_UNEXPECTED_PANIC
+       bool "Panic when an unexpected IRQ occurs"
+       default y
+       depends on !ARCH_NOINTC
+       ---help---
+               An unexpected IRQ is an interrupt with no handler attached.  If
+               selected, the system panics when one occurs (the default 
behavior).
+               If not selected, the error is logged and the IRQ is disabled 
with
+               up_disable_irq() so that the system keeps running.
+
 config IRQ_NWORKS
        int "Max num of active irq wqueue"
        default 8
diff --git a/sched/irq/irq_unexpectedisr.c b/sched/irq/irq_unexpectedisr.c
index 9b889280357..59b59707341 100644
--- a/sched/irq/irq_unexpectedisr.c
+++ b/sched/irq/irq_unexpectedisr.c
@@ -51,8 +51,14 @@ int irq_unexpected_isr(int irq, FAR void *context, FAR void 
*arg)
   UNUSED(context);
   UNUSED(arg);
 
+#if defined(CONFIG_IRQ_UNEXPECTED_PANIC) || defined(CONFIG_ARCH_NOINTC)
   irq_save();
   _err("ERROR irq: %d\n", irq);
   PANIC();
-  return OK; /* Won't get here */
+#else
+  _err("ERROR irq: %d\n", irq);
+  up_disable_irq(irq);
+#endif
+
+  return OK;
 }

Reply via email to