mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-05 22:41:25 +12:00
Fix cpu_flag::temp, make sure it removes cpu_flag::wait
This commit is contained in:
parent
86785dffa4
commit
d6daa0d05b
4 changed files with 19 additions and 24 deletions
|
@ -578,10 +578,11 @@ bool cpu_thread::check_state() noexcept
|
||||||
susp_ctr = -1;
|
susp_ctr = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & cpu_flag::temp)
|
if (flags & cpu_flag::temp) [[unlikely]]
|
||||||
{
|
{
|
||||||
// Sticky flag, indicates check_state() is not allowed to return true
|
// Sticky flag, indicates check_state() is not allowed to return true
|
||||||
flags -= cpu_flag::temp;
|
flags -= cpu_flag::temp;
|
||||||
|
flags -= cpu_flag::wait;
|
||||||
cpu_can_stop = false;
|
cpu_can_stop = false;
|
||||||
store = true;
|
store = true;
|
||||||
}
|
}
|
||||||
|
@ -619,7 +620,7 @@ bool cpu_thread::check_state() noexcept
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!(flags & cpu_flag::wait))
|
if (cpu_can_stop && !(flags & cpu_flag::wait))
|
||||||
{
|
{
|
||||||
flags += cpu_flag::wait;
|
flags += cpu_flag::wait;
|
||||||
store = true;
|
store = true;
|
||||||
|
@ -649,6 +650,8 @@ bool cpu_thread::check_state() noexcept
|
||||||
s_tls_thread_slot = g_fxo->get<cpu_counter>()->add(this, true);
|
s_tls_thread_slot = g_fxo->get<cpu_counter>()->add(this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
verify(HERE), cpu_can_stop || !retval;
|
||||||
|
verify(HERE), cpu_can_stop || !(state & cpu_flag::wait);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,7 +660,7 @@ bool cpu_thread::check_state() noexcept
|
||||||
cpu_sleep();
|
cpu_sleep();
|
||||||
cpu_sleep_called = true;
|
cpu_sleep_called = true;
|
||||||
|
|
||||||
if (s_tls_thread_slot != umax)
|
if (cpu_can_stop && s_tls_thread_slot != umax)
|
||||||
{
|
{
|
||||||
// Exclude inactive threads from the suspend list (optimization)
|
// Exclude inactive threads from the suspend list (optimization)
|
||||||
std::lock_guard lock(g_fxo->get<cpu_counter>()->cpu_suspend_lock);
|
std::lock_guard lock(g_fxo->get<cpu_counter>()->cpu_suspend_lock);
|
||||||
|
|
|
@ -1219,9 +1219,9 @@ static T ppu_load_acquire_reservation(ppu_thread& ppu, u32 addr)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ppu.state += cpu_flag::wait + cpu_flag::temp;
|
ppu.state += cpu_flag::wait;
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
verify(HERE), !ppu.check_state();
|
ppu.check_state();
|
||||||
}
|
}
|
||||||
}())
|
}())
|
||||||
{
|
{
|
||||||
|
|
|
@ -2650,18 +2650,10 @@ bool spu_thread::process_mfc_cmd()
|
||||||
busy_wait(300);
|
busy_wait(300);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
if (g_use_rtm)
|
|
||||||
{
|
{
|
||||||
state += cpu_flag::wait + cpu_flag::temp;
|
state += cpu_flag::wait + cpu_flag::temp;
|
||||||
}
|
|
||||||
|
|
||||||
std::this_thread::yield();
|
std::this_thread::yield();
|
||||||
|
!check_state();
|
||||||
if (g_use_rtm)
|
|
||||||
{
|
|
||||||
verify(HERE), !check_state();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}())
|
}())
|
||||||
{
|
{
|
||||||
|
|
|
@ -261,13 +261,15 @@ namespace vm
|
||||||
|
|
||||||
void passive_lock(cpu_thread& cpu)
|
void passive_lock(cpu_thread& cpu)
|
||||||
{
|
{
|
||||||
|
bool ok = true;
|
||||||
|
|
||||||
if (!g_tls_locked || *g_tls_locked != &cpu) [[unlikely]]
|
if (!g_tls_locked || *g_tls_locked != &cpu) [[unlikely]]
|
||||||
{
|
{
|
||||||
_register_lock(&cpu);
|
_register_lock(&cpu);
|
||||||
|
|
||||||
if (cpu.state) [[likely]]
|
if (cpu.state & cpu_flag::memory) [[likely]]
|
||||||
{
|
{
|
||||||
cpu.state -= cpu_flag::wait + cpu_flag::memory;
|
cpu.state -= cpu_flag::memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_mutex.is_lockable())
|
if (g_mutex.is_lockable())
|
||||||
|
@ -275,22 +277,20 @@ namespace vm
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cpu.state += cpu_flag::wait;
|
ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cpu.state & cpu_flag::wait)
|
if (!ok || cpu.state & cpu_flag::memory)
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
g_mutex.lock_unlock();
|
g_mutex.lock_unlock();
|
||||||
cpu.state -= cpu_flag::wait + cpu_flag::memory;
|
cpu.state -= cpu_flag::memory;
|
||||||
|
|
||||||
if (g_mutex.is_lockable()) [[likely]]
|
if (g_mutex.is_lockable()) [[likely]]
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cpu.state += cpu_flag::wait;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -345,7 +345,7 @@ namespace vm
|
||||||
|
|
||||||
if (cpu)
|
if (cpu)
|
||||||
{
|
{
|
||||||
if (!g_tls_locked || *g_tls_locked != cpu)
|
if (!g_tls_locked || *g_tls_locked != cpu || cpu->state & cpu_flag::wait)
|
||||||
{
|
{
|
||||||
cpu = nullptr;
|
cpu = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -392,7 +392,7 @@ namespace vm
|
||||||
|
|
||||||
if (cpu)
|
if (cpu)
|
||||||
{
|
{
|
||||||
if (!g_tls_locked || *g_tls_locked != cpu)
|
if (!g_tls_locked || *g_tls_locked != cpu || cpu->state & cpu_flag::wait)
|
||||||
{
|
{
|
||||||
cpu = nullptr;
|
cpu = nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue