mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 19:45:20 +00:00
Improve vm::reservation_update
Only respect unique lock.
This commit is contained in:
parent
2f329cf7b5
commit
1885e4345c
4 changed files with 19 additions and 18 deletions
|
@ -4487,7 +4487,7 @@ bool ppu_interpreter::STW(ppu_thread& ppu, ppu_opcode_t op)
|
|||
//Insomniac engine v3 & v4 (newer R&C, Fuse, Resitance 3)
|
||||
if (value == 0xAAAAAAAA) [[unlikely]]
|
||||
{
|
||||
vm::reservation_update(vm::cast(addr, HERE), 128);
|
||||
vm::reservation_update(vm::cast(addr, HERE));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -80,15 +80,25 @@ namespace vm
|
|||
// Memory pages
|
||||
std::array<memory_page, 0x100000000 / 4096> g_pages{};
|
||||
|
||||
void reservation_update(u32 addr, u32 size, bool lsb)
|
||||
std::pair<bool, u64> try_reservation_update(u32 addr)
|
||||
{
|
||||
// Update reservation info with new timestamp
|
||||
auto& res = reservation_acquire(addr, 1);
|
||||
const u64 rtime = res;
|
||||
|
||||
return {!(rtime & vm::rsrv_unique_lock) && res.compare_and_swap_test(rtime, rtime + 128), rtime};
|
||||
}
|
||||
|
||||
void reservation_update(u32 addr)
|
||||
{
|
||||
u64 old = UINT64_MAX;
|
||||
const auto cpu = get_current_cpu_thread();
|
||||
|
||||
while (true)
|
||||
{
|
||||
const auto [ok, rtime] = try_reservation_update(addr, size, lsb);
|
||||
if (ok || old / 128 < rtime / 128)
|
||||
const auto [ok, rtime] = try_reservation_update(addr);
|
||||
|
||||
if (ok || (old & -128) < (rtime & -128))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -25,16 +25,7 @@ namespace vm
|
|||
}
|
||||
|
||||
// Update reservation status
|
||||
inline std::pair<bool, u64> try_reservation_update(u32 addr, u32 size, bool lsb = false)
|
||||
{
|
||||
// Update reservation info with new timestamp
|
||||
auto& res = reservation_acquire(addr, size);
|
||||
const u64 rtime = res;
|
||||
|
||||
return {!(rtime & 127) && res.compare_and_swap_test(rtime, rtime + 128), rtime};
|
||||
}
|
||||
|
||||
void reservation_update(u32 addr, u32 size, bool lsb = false);
|
||||
void reservation_update(u32 addr);
|
||||
|
||||
// Get reservation sync variable
|
||||
inline atomic_t<u64>& reservation_notifier(u32 addr, u32 size)
|
||||
|
|
|
@ -240,7 +240,7 @@ void register_editor_dialog::OnOkay(const std::shared_ptr<cpu_thread>& _cpu)
|
|||
// Invalid integer
|
||||
value.clear();
|
||||
}
|
||||
|
||||
|
||||
if (!cpu || value.empty())
|
||||
{
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ void register_editor_dialog::OnOkay(const std::shared_ptr<cpu_thread>& _cpu)
|
|||
if (reg >= ppu_r0 && reg <= ppu_v31)
|
||||
{
|
||||
const u32 reg_index = reg % 32;
|
||||
|
||||
|
||||
if ((reg >= ppu_r0 && reg <= ppu_r31) || (reg >= ppu_f0 && reg <= ppu_f31))
|
||||
{
|
||||
if (u64 reg_value; check_res(std::from_chars(value.c_str() + 16, value.c_str() + 32, reg_value, 16), value.c_str() + 32))
|
||||
|
@ -306,7 +306,7 @@ void register_editor_dialog::OnOkay(const std::shared_ptr<cpu_thread>& _cpu)
|
|||
}
|
||||
else if (reg == RESERVATION_LOST)
|
||||
{
|
||||
if (u32 raddr = ppu.raddr) vm::reservation_update(raddr, 128);
|
||||
if (u32 raddr = ppu.raddr) vm::reservation_update(raddr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ void register_editor_dialog::OnOkay(const std::shared_ptr<cpu_thread>& _cpu)
|
|||
}
|
||||
else if (reg == RESERVATION_LOST)
|
||||
{
|
||||
if (u32 raddr = spu.raddr) vm::reservation_update(raddr, 128);
|
||||
if (u32 raddr = spu.raddr) vm::reservation_update(raddr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue