From 3c639ff8e1d0ce7a81fd64a8e167cf5cf4169039 Mon Sep 17 00:00:00 2001 From: Eladash Date: Sat, 31 Oct 2020 19:27:28 +0200 Subject: [PATCH] SPU: Fix Accurate DMA edge case --- rpcs3/Emu/Cell/PPUThread.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index fcfefecc10..2857240d20 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -1796,6 +1796,8 @@ static bool ppu_store_reservation(ppu_thread& ppu, u32 addr, u64 reg_value) // Aligned 8-byte reservations will be used here addr &= -8; + const u64 lock_bits = g_cfg.core.spu_accurate_dma ? vm::rsrv_unique_lock : 1; + auto [_oldd, _ok] = res.fetch_op([&](u64& r) { if ((r & -128) != rtime || (r & 127)) @@ -1804,7 +1806,7 @@ static bool ppu_store_reservation(ppu_thread& ppu, u32 addr, u64 reg_value) } // Despite using shared lock, doesn't allow other shared locks (TODO) - r += 1; + r += lock_bits; return true; }); @@ -1818,11 +1820,11 @@ static bool ppu_store_reservation(ppu_thread& ppu, u32 addr, u64 reg_value) // Store previous value in old_data on failure if (data.compare_exchange(old_data, new_data)) { - res += 127; + res += 128 - lock_bits; return true; } - const u64 old_rtime = res.fetch_sub(1); + const u64 old_rtime = res.fetch_sub(lock_bits); // TODO: disabled with this setting on, since it's dangerous to mix if (!g_cfg.core.ppu_128_reservations_loop_max_length)