diff --git a/arch/xtensa/src/common/xtensa_cpupause.c b/arch/xtensa/src/common/xtensa_cpupause.c index 245706ebe2..370054d5c7 100644 --- a/arch/xtensa/src/common/xtensa_cpupause.c +++ b/arch/xtensa/src/common/xtensa_cpupause.c @@ -229,9 +229,6 @@ int up_cpu_pause(int cpu) * handler from returning until up_cpu_resume() is called; g_cpu_paused * is a handshake that will prefent this function from returning until * the CPU is actually paused. - * - * REVISIT: OR should there be logic to just skip this if the other CPU - * is already paused. */ DEBUGASSERT(!spin_islocked(&g_cpu_wait[cpu]) && @@ -300,9 +297,6 @@ int up_cpu_resume(int cpu) /* Release the spinlock. Releasing the spinlock will cause the SGI2 * handler on 'cpu' to continue and return from interrupt to the newly * established thread. - * - * REVISIT: Should there be a more positive handshake to assure that the - * resumption is complete before returning. */ DEBUGASSERT(spin_islocked(&g_cpu_wait[cpu]) && diff --git a/arch/xtensa/src/common/xtensa_releasepending.c b/arch/xtensa/src/common/xtensa_releasepending.c index 125d7237f8..cae473243f 100644 --- a/arch/xtensa/src/common/xtensa_releasepending.c +++ b/arch/xtensa/src/common/xtensa_releasepending.c @@ -39,7 +39,6 @@ #include -#include #include #include @@ -69,112 +68,92 @@ void up_release_pending(void) { struct tcb_s *rtcb = this_task(); -#ifdef CONFIG_SMP - static bool busy = false; -#endif sinfo("From TCB=%p\n", rtcb); - /* In SMP configurations, this function will be called as part of leaving - * the critical section. In that case, it may be re-entered as part of - * the sched_addreadytorun() processing. We have to guard against that - * case. - */ + /* Merge the g_pendingtasks list into the ready-to-run task list */ -#ifdef CONFIG_SMP - if (!busy) + /* sched_lock(); */ + if (sched_mergepending()) { - busy = true; -#endif + /* The currently active task has changed! We will need to + * switch contexts. + */ - /* Merge the g_pendingtasks list into the ready-to-run task list */ + /* Update scheduler parameters */ - /* sched_lock(); */ - if (sched_mergepending()) + sched_suspend_scheduler(rtcb); + + /* Are we operating in interrupt context? */ + + if (CURRENT_REGS) { - /* The currently active task has changed! We will need to - * switch contexts. + /* Yes, then we have to do things differently. + * Just copy the CURRENT_REGS into the OLD rtcb. */ + xtensa_savestate(rtcb->xcp.regs); + + /* Restore the exception context of the rtcb at the (new) head + * of the ready-to-run task list. + */ + + rtcb = this_task(); + /* Update scheduler parameters */ - sched_suspend_scheduler(rtcb); + sched_resume_scheduler(rtcb); - /* Are we operating in interrupt context? */ - - if (CURRENT_REGS) - { - /* Yes, then we have to do things differently. - * Just copy the CURRENT_REGS into the OLD rtcb. - */ - - xtensa_savestate(rtcb->xcp.regs); - - /* Restore the exception context of the rtcb at the (new) head - * of the ready-to-run task list. - */ - - rtcb = this_task(); - - /* Update scheduler parameters */ - - sched_resume_scheduler(rtcb); - - /* Then switch contexts. Any necessary address environment - * changes will be made when the interrupt returns. - */ - - xtensa_restorestate(rtcb->xcp.regs); - } - - /* Copy the exception context into the TCB of the task that - * was currently active. if up_saveusercontext returns a non-zero - * value, then this is really the previously running task - * restarting! + /* Then switch contexts. Any necessary address environment + * changes will be made when the interrupt returns. */ - else if (!xtensa_context_save(rtcb->xcp.regs)) - { -#if XCHAL_CP_NUM > 0 - /* Save the co-processor state in in the suspended thread's co- - * processor save area. - */ + xtensa_restorestate(rtcb->xcp.regs); + } - xtensa_coproc_savestate(&rtcb->xcp.cpstate); + /* Copy the exception context into the TCB of the task that + * was currently active. if up_saveusercontext returns a non-zero + * value, then this is really the previously running task + * restarting! + */ + + else if (!xtensa_context_save(rtcb->xcp.regs)) + { +#if XCHAL_CP_NUM > 0 + /* Save the co-processor state in in the suspended thread's co- + * processor save area. + */ + + xtensa_coproc_savestate(&rtcb->xcp.cpstate); #endif - /* Restore the exception context of the rtcb at the (new) head - * of the ready-to-run task list. - */ + /* Restore the exception context of the rtcb at the (new) head + * of the ready-to-run task list. + */ - rtcb = this_task(); + rtcb = this_task(); #if XCHAL_CP_NUM > 0 - /* Set up the co-processor state for the newly started thread. */ + /* Set up the co-processor state for the newly started thread. */ - xtensa_coproc_restorestate(&rtcb->xcp.cpstate); + xtensa_coproc_restorestate(&rtcb->xcp.cpstate); #endif #ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ + /* Make sure that the address environment for the previously + * running task is closed down gracefully (data caches dump, + * MMU flushed) and set up the address environment for the new + * thread at the head of the ready-to-run list. + */ - (void)group_addrenv(rtcb); + (void)group_addrenv(rtcb); #endif - /* Update scheduler parameters */ + /* Update scheduler parameters */ - sched_resume_scheduler(rtcb); + sched_resume_scheduler(rtcb); - /* Then switch contexts */ + /* Then switch contexts */ - xtensa_context_restore(rtcb->xcp.regs); - } + xtensa_context_restore(rtcb->xcp.regs); } - -#ifdef CONFIG_SMP - busy = false; } -#endif }