From da7d220d98dd7c231cc342cb3b1c510350c22439 Mon Sep 17 00:00:00 2001 From: Elad Ashkenazi Date: Mon, 8 Aug 2022 15:03:32 +0300 Subject: [PATCH] sys_mutex/lwmutex: Regression fixes after #12378 --- rpcs3/Emu/Cell/lv2/sys_lwmutex.h | 9 +++++++-- rpcs3/Emu/Cell/lv2/sys_mutex.h | 14 ++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_lwmutex.h b/rpcs3/Emu/Cell/lv2/sys_lwmutex.h index 86552aa32b03..34a19d028507 100644 --- a/rpcs3/Emu/Cell/lv2/sys_lwmutex.h +++ b/rpcs3/Emu/Cell/lv2/sys_lwmutex.h @@ -123,6 +123,11 @@ struct lv2_lwmutex final : lv2_obj lwcond_waiters.notify_all(); } + if (signal) + { + cpu->next_cpu = nullptr; + } + return signal; } @@ -158,8 +163,9 @@ struct lv2_lwmutex final : lv2_obj res = nullptr; } - if (auto sq = data.sq) + if (auto sq = static_cast(data.sq)) { + restore_next = sq->next_cpu; res = schedule(data.sq, protocol); if (sq == data.sq) @@ -167,7 +173,6 @@ struct lv2_lwmutex final : lv2_obj return false; } - restore_next = res->next_cpu; return true; } else diff --git a/rpcs3/Emu/Cell/lv2/sys_mutex.h b/rpcs3/Emu/Cell/lv2/sys_mutex.h index 4c668625cc89..2565dfe7eaf2 100644 --- a/rpcs3/Emu/Cell/lv2/sys_mutex.h +++ b/rpcs3/Emu/Cell/lv2/sys_mutex.h @@ -101,7 +101,7 @@ struct lv2_mutex final : lv2_obj template bool try_own(T& cpu) { - return control.atomic_op([&](control_data_t& data) + if (control.atomic_op([&](control_data_t& data) { if (data.owner) { @@ -114,7 +114,13 @@ struct lv2_mutex final : lv2_obj data.owner = cpu.id; return true; } - }); + })) + { + cpu.next_cpu = nullptr; + return true; + } + + return false; } template @@ -161,8 +167,9 @@ struct lv2_mutex final : lv2_obj res = nullptr; } - if (auto sq = data.sq) + if (auto sq = static_cast(data.sq)) { + restore_next = sq->next_cpu; res = schedule(data.sq, protocol); if (sq == data.sq) @@ -171,7 +178,6 @@ struct lv2_mutex final : lv2_obj return false; } - restore_next = res->next_cpu; data.owner = res->id; return true; }