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

raiden00 pushed a commit to branch releases/12.7
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit a9df7f0d1efcf85914b73ed2c2db07d3b74a8be4
Author: ligd <[email protected]>
AuthorDate: Fri Sep 27 13:24:10 2024 +0800

    xtesa: fix lost save & restore states caused by merge code
    
    this is caused by:
    35c8c80a00a99ff0e19d51eaa74165bd830a36f8
    
    Signed-off-by: ligd <[email protected]>
---
 arch/xtensa/src/common/xtensa_switchcontext.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/arch/xtensa/src/common/xtensa_switchcontext.c 
b/arch/xtensa/src/common/xtensa_switchcontext.c
index a98e3e1069..ad84e86ef0 100644
--- a/arch/xtensa/src/common/xtensa_switchcontext.c
+++ b/arch/xtensa/src/common/xtensa_switchcontext.c
@@ -59,7 +59,24 @@ void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
 {
   /* Are we in an interrupt handler? */
 
-  if (!up_current_regs())
+  if (up_current_regs())
+    {
+      /* Yes, then we have to do things differently.
+       * Just copy the current_regs into the OLD rtcb.
+       */
+
+      xtensa_savestate(rtcb->xcp.regs);
+
+      /* Then switch contexts.  Any necessary address environment
+       * changes will be made when the interrupt returns.
+       */
+
+      xtensa_restorestate(tcb->xcp.regs);
+    }
+
+  /* No, then we will need to perform the user context switch */
+
+  else
     {
       /* Switch context to the context of the task at the head of the
        * ready to run list.

Reply via email to