diff --git a/rpcs3/Emu/Cell/PPUInterpreter.cpp b/rpcs3/Emu/Cell/PPUInterpreter.cpp index b31c009e70..edaa3a6126 100644 --- a/rpcs3/Emu/Cell/PPUInterpreter.cpp +++ b/rpcs3/Emu/Cell/PPUInterpreter.cpp @@ -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; diff --git a/rpcs3/Emu/Memory/vm.cpp b/rpcs3/Emu/Memory/vm.cpp index ee19f24591..b1b5ca363b 100644 --- a/rpcs3/Emu/Memory/vm.cpp +++ b/rpcs3/Emu/Memory/vm.cpp @@ -80,15 +80,25 @@ namespace vm // Memory pages std::array g_pages{}; - void reservation_update(u32 addr, u32 size, bool lsb) + std::pair 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; } diff --git a/rpcs3/Emu/Memory/vm_reservation.h b/rpcs3/Emu/Memory/vm_reservation.h index 2b022659f6..c4493998af 100644 --- a/rpcs3/Emu/Memory/vm_reservation.h +++ b/rpcs3/Emu/Memory/vm_reservation.h @@ -25,16 +25,7 @@ namespace vm } // Update reservation status - inline std::pair 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& reservation_notifier(u32 addr, u32 size) diff --git a/rpcs3/rpcs3qt/register_editor_dialog.cpp b/rpcs3/rpcs3qt/register_editor_dialog.cpp index c85bcb115e..76f1f20f8f 100644 --- a/rpcs3/rpcs3qt/register_editor_dialog.cpp +++ b/rpcs3/rpcs3qt/register_editor_dialog.cpp @@ -240,7 +240,7 @@ void register_editor_dialog::OnOkay(const std::shared_ptr& _cpu) // Invalid integer value.clear(); } - + if (!cpu || value.empty()) { } @@ -251,7 +251,7 @@ void register_editor_dialog::OnOkay(const std::shared_ptr& _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) } 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) } 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; } }