From 34b033d41d711c56fe0ea4029d4a815e03e01f0e Mon Sep 17 00:00:00 2001 From: Wayne Ren Date: Mon, 3 Feb 2020 20:54:36 +0800 Subject: [PATCH] arch: arc: fix the bug of "wait for switch" sychronization after applying commit 3235451880, arc's arch_switch also need's corresponding fix. Signed-off-by: Wayne Ren --- arch/arc/core/switch.S | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/arch/arc/core/switch.S b/arch/arc/core/switch.S index 08d4b2210d4..5fce3b30622 100644 --- a/arch/arc/core/switch.S +++ b/arch/arc/core/switch.S @@ -67,15 +67,12 @@ SECTION_FUNC(TEXT, arch_switch) #endif /* * r0 = new_thread->switch_handle = switch_to thread, - * r1 = &old_thread->switch_handle = &switch_from thread + * r1 = &old_thread->switch_handle + * get old_thread from r1 */ - ld_s r2, [r1] - /* - * r2 may be dummy_thread in z_cstart, dummy_thread->switch_handle - * must be 0 - */ - breq r2, 0, _switch_to_target_thread + sub r2, r1, ___thread_t_switch_handle_OFFSET + st _CAUSE_COOP, [r2, _thread_offset_to_relinquish_cause] @@ -99,6 +96,13 @@ SECTION_FUNC(TEXT, arch_switch) _save_callee_saved_regs +#ifdef CONFIG_SMP + /* save old thread into switch handle which is required by + * wait_for_switch + */ + st r2, [r2, ___thread_t_switch_handle_OFFSET] +#endif + #ifdef CONFIG_ARC_STACK_CHECKING /* disable stack checking here, as sp will be changed to target * thread'sp @@ -112,8 +116,6 @@ SECTION_FUNC(TEXT, arch_switch) #endif #endif -_switch_to_target_thread: - mov_s r2, r0 /* entering here, r2 contains the new current thread */