diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 0dc50b260e..31eb41ebfd 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -3352,10 +3352,22 @@ bool spu_thread::stop_and_signal(u32 code) for (auto& thread : group->threads) { - if (thread && thread.get() != this) + if (thread) { - thread->state += cpu_flag::stop + cpu_flag::ret; - thread_ctrl::raw_notify(*thread); + thread->state.fetch_op([](bs_t& flags) + { + if (flags & cpu_flag::stop) + { + // In case the thread raised the ret flag itself at some point do not raise it again + return false; + } + + flags += cpu_flag::stop + cpu_flag::ret; + return true; + }); + + if (thread.get() != this) + thread_ctrl::raw_notify(*thread); } } @@ -3365,7 +3377,6 @@ bool spu_thread::stop_and_signal(u32 code) break; } - state += cpu_flag::stop + cpu_flag::ret; check_state(); return true; } diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.cpp b/rpcs3/Emu/Cell/lv2/sys_spu.cpp index db8768240f..04939aecb7 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_spu.cpp @@ -1005,7 +1005,17 @@ error_code sys_spu_thread_group_terminate(ppu_thread& ppu, u32 id, s32 value) { if (thread) { - thread->state += cpu_flag::stop + cpu_flag::ret; + thread->state.fetch_op([](bs_t& flags) + { + if (flags & cpu_flag::stop) + { + // In case the thread raised the ret flag itself at some point do not raise it again + return false; + } + + flags += cpu_flag::stop + cpu_flag::ret; + return true; + }); } }