Skip to content

Commit

Permalink
sys_mutex/lwmutex: Regression fixes after RPCS3#12378
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Aug 9, 2022
1 parent 8476383 commit da7d220
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
9 changes: 7 additions & 2 deletions rpcs3/Emu/Cell/lv2/sys_lwmutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ struct lv2_lwmutex final : lv2_obj
lwcond_waiters.notify_all();
}

if (signal)
{
cpu->next_cpu = nullptr;
}

return signal;
}

Expand Down Expand Up @@ -158,16 +163,16 @@ struct lv2_lwmutex final : lv2_obj
res = nullptr;
}

if (auto sq = data.sq)
if (auto sq = static_cast<T*>(data.sq))
{
restore_next = sq->next_cpu;
res = schedule<T>(data.sq, protocol);

if (sq == data.sq)
{
return false;
}

restore_next = res->next_cpu;
return true;
}
else
Expand Down
14 changes: 10 additions & 4 deletions rpcs3/Emu/Cell/lv2/sys_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ struct lv2_mutex final : lv2_obj
template <typename T>
bool try_own(T& cpu)
{
return control.atomic_op([&](control_data_t& data)
if (control.atomic_op([&](control_data_t& data)
{
if (data.owner)
{
Expand All @@ -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 <typename T>
Expand Down Expand Up @@ -161,8 +167,9 @@ struct lv2_mutex final : lv2_obj
res = nullptr;
}

if (auto sq = data.sq)
if (auto sq = static_cast<T*>(data.sq))
{
restore_next = sq->next_cpu;
res = schedule<T>(data.sq, protocol);

if (sq == data.sq)
Expand All @@ -171,7 +178,6 @@ struct lv2_mutex final : lv2_obj
return false;
}

restore_next = res->next_cpu;
data.owner = res->id;
return true;
}
Expand Down

0 comments on commit da7d220

Please sign in to comment.