tmedicci commented on code in PR #15815:
URL: https://github.com/apache/nuttx/pull/15815#discussion_r1953265966


##########
arch/risc-v/src/common/riscv_doirq.c:
##########
@@ -88,13 +88,24 @@ uintreg_t *riscv_doirq(int irq, uintreg_t *regs)
       (*running_task)->xcp.regs = regs;
     }
 
-  /* Nested interrupts are not supported */
+  /* Current regs non-zero indicates that we are processing an interrupt;
+   * current_regs is also used to manage interrupt level context switches.
+   *
+   * Nested interrupts are not supported. But an exception may occur while
+   * processing an interrupt. In this case, current_regs will be non-NULL.
+   */
 
-  DEBUGASSERT(!up_interrupt_context());
+  DEBUGASSERT(((irq > RISCV_MAX_EXCEPTION) && !up_interrupt_context()) ||

Review Comment:
   @xiaoxiang781216 , we are not implementing anything related to the syscall 
in irq handler.
   
   We are just allowing the exception being treated by the `irq_dispatch` when 
handling an interrupt. 
   The 
[`riscv_exception_attach`](https://github.com/apache/incubator-nuttx/blob/3a4b8edf2c77563033c0d0dd3b38100e51da6495/arch/risc-v/src/common/riscv_exception.c#L256)
 registers the handlers for each exception. Note that exceptions like 
`RISCV_IRQ_IINSTRUCTION` are treated by 
[`riscv_exception`](https://github.com/apache/incubator-nuttx/blob/3a4b8edf2c77563033c0d0dd3b38100e51da6495/arch/risc-v/src/common/riscv_exception.c#L93),
 which dumps the stack and the backtrace. This `DEBUGASSERTION` was changed 
just to allow it to occur during an interrupt handler.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to