diff --git a/rpcs3/Emu/Cell/lv2/sys_cond.cpp b/rpcs3/Emu/Cell/lv2/sys_cond.cpp index 3c999257d5..393e11ada3 100644 --- a/rpcs3/Emu/Cell/lv2/sys_cond.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_cond.cpp @@ -9,6 +9,8 @@ #include "Emu/Cell/ErrorCodes.h" #include "Emu/Cell/PPUThread.h" +#include "util/asm.hpp" + LOG_CHANNEL(sys_cond); lv2_cond::lv2_cond(utils::serial& ar) @@ -374,6 +376,16 @@ error_code sys_cond_wait(ppu_thread& ppu, u32 cond_id, u64 timeout) return {}; } + for (usz i = 0; cpu_flag::signal - ppu.state && i < 50; i++) + { + busy_wait(500); + } + + if (ppu.state & cpu_flag::signal) + { + continue; + } + if (timeout) { if (lv2_obj::wait_timeout(timeout, &ppu)) diff --git a/rpcs3/Emu/Cell/lv2/sys_event.cpp b/rpcs3/Emu/Cell/lv2/sys_event.cpp index 4c8ac60385..cee800eca3 100644 --- a/rpcs3/Emu/Cell/lv2/sys_event.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_event.cpp @@ -10,6 +10,8 @@ #include "Emu/Cell/SPUThread.h" #include "sys_process.h" +#include "util/asm.hpp" + LOG_CHANNEL(sys_event); lv2_event_queue::lv2_event_queue(u32 protocol, s32 type, s32 size, u64 name, u64 ipc_key) noexcept @@ -471,6 +473,16 @@ error_code sys_event_queue_receive(ppu_thread& ppu, u32 equeue_id, vm::ptr +#include "util/asm.hpp" + LOG_CHANNEL(sys_event_flag); lv2_event_flag::lv2_event_flag(utils::serial& ar) @@ -211,6 +213,16 @@ error_code sys_event_flag_wait(ppu_thread& ppu, u32 id, u64 bitptn, u32 mode, vm return {}; } + for (usz i = 0; cpu_flag::signal - ppu.state && i < 50; i++) + { + busy_wait(500); + } + + if (ppu.state & cpu_flag::signal) + { + continue; + } + if (timeout) { if (lv2_obj::wait_timeout(timeout, &ppu)) diff --git a/rpcs3/Emu/Cell/lv2/sys_lwcond.cpp b/rpcs3/Emu/Cell/lv2/sys_lwcond.cpp index e0bd40cef7..65dd839f37 100644 --- a/rpcs3/Emu/Cell/lv2/sys_lwcond.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_lwcond.cpp @@ -1,4 +1,4 @@ -#include "stdafx.h" +#include "stdafx.h" #include "sys_lwcond.h" #include "Emu/IdManager.h" @@ -7,6 +7,8 @@ #include "Emu/Cell/PPUThread.h" #include "sys_lwmutex.h" +#include "util/asm.hpp" + LOG_CHANNEL(sys_lwcond); lv2_lwcond::lv2_lwcond(utils::serial& ar) @@ -425,6 +427,16 @@ error_code _sys_lwcond_queue_wait(ppu_thread& ppu, u32 lwcond_id, u32 lwmutex_id break; } + for (usz i = 0; cpu_flag::signal - ppu.state && i < 50; i++) + { + busy_wait(500); + } + + if (ppu.state & cpu_flag::signal) + { + continue; + } + if (timeout) { if (lv2_obj::wait_timeout(timeout, &ppu)) diff --git a/rpcs3/Emu/Cell/lv2/sys_lwmutex.cpp b/rpcs3/Emu/Cell/lv2/sys_lwmutex.cpp index 0e56c7e6a6..2b3f11018a 100644 --- a/rpcs3/Emu/Cell/lv2/sys_lwmutex.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_lwmutex.cpp @@ -6,6 +6,8 @@ #include "Emu/Cell/ErrorCodes.h" #include "Emu/Cell/PPUThread.h" +#include "util/asm.hpp" + LOG_CHANNEL(sys_lwmutex); lv2_lwmutex::lv2_lwmutex(utils::serial& ar) @@ -204,6 +206,16 @@ error_code _sys_lwmutex_lock(ppu_thread& ppu, u32 lwmutex_id, u64 timeout) return {}; } + for (usz i = 0; cpu_flag::signal - ppu.state && i < 50; i++) + { + busy_wait(500); + } + + if (ppu.state & cpu_flag::signal) + { + continue; + } + if (timeout) { if (lv2_obj::wait_timeout(timeout, &ppu)) diff --git a/rpcs3/Emu/Cell/lv2/sys_mutex.cpp b/rpcs3/Emu/Cell/lv2/sys_mutex.cpp index b41c53d2c1..4f76f0f589 100644 --- a/rpcs3/Emu/Cell/lv2/sys_mutex.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_mutex.cpp @@ -7,6 +7,8 @@ #include "Emu/Cell/ErrorCodes.h" #include "Emu/Cell/PPUThread.h" +#include "util/asm.hpp" + LOG_CHANNEL(sys_mutex); lv2_mutex::lv2_mutex(utils::serial& ar) @@ -195,6 +197,16 @@ error_code sys_mutex_lock(ppu_thread& ppu, u32 mutex_id, u64 timeout) return {}; } + for (usz i = 0; cpu_flag::signal - ppu.state && i < 50; i++) + { + busy_wait(500); + } + + if (ppu.state & cpu_flag::signal) + { + continue; + } + if (timeout) { if (lv2_obj::wait_timeout(timeout, &ppu)) diff --git a/rpcs3/Emu/Cell/lv2/sys_rwlock.cpp b/rpcs3/Emu/Cell/lv2/sys_rwlock.cpp index 67d06a3021..f09cb9be8d 100644 --- a/rpcs3/Emu/Cell/lv2/sys_rwlock.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_rwlock.cpp @@ -7,6 +7,8 @@ #include "Emu/Cell/ErrorCodes.h" #include "Emu/Cell/PPUThread.h" +#include "util/asm.hpp" + LOG_CHANNEL(sys_rwlock); lv2_rwlock::lv2_rwlock(utils::serial& ar) @@ -170,9 +172,14 @@ error_code sys_rwlock_rlock(ppu_thread& ppu, u32 rw_lock_id, u64 timeout) break; } - if (state & cpu_flag::signal) + for (usz i = 0; cpu_flag::signal - ppu.state && i < 50; i++) { - break; + busy_wait(500); + } + + if (ppu.state & cpu_flag::signal) + { + continue; } if (timeout) @@ -398,6 +405,16 @@ error_code sys_rwlock_wlock(ppu_thread& ppu, u32 rw_lock_id, u64 timeout) break; } + for (usz i = 0; cpu_flag::signal - ppu.state && i < 50; i++) + { + busy_wait(500); + } + + if (ppu.state & cpu_flag::signal) + { + continue; + } + if (timeout) { if (lv2_obj::wait_timeout(timeout, &ppu)) diff --git a/rpcs3/Emu/Cell/lv2/sys_semaphore.cpp b/rpcs3/Emu/Cell/lv2/sys_semaphore.cpp index a1f62c08aa..29f2508bc2 100644 --- a/rpcs3/Emu/Cell/lv2/sys_semaphore.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_semaphore.cpp @@ -7,6 +7,8 @@ #include "Emu/Cell/ErrorCodes.h" #include "Emu/Cell/PPUThread.h" +#include "util/asm.hpp" + LOG_CHANNEL(sys_semaphore); lv2_sema::lv2_sema(utils::serial& ar) @@ -167,6 +169,16 @@ error_code sys_semaphore_wait(ppu_thread& ppu, u32 sem_id, u64 timeout) return {}; } + for (usz i = 0; cpu_flag::signal - ppu.state && i < 50; i++) + { + busy_wait(500); + } + + if (ppu.state & cpu_flag::signal) + { + continue; + } + if (timeout) { if (lv2_obj::wait_timeout(timeout, &ppu))