diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index ef93cb4c77..9ca4bb2ab4 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -671,7 +671,6 @@ bool cpu_thread::check_state() noexcept } verify(HERE), cpu_can_stop || !retval; - verify(HERE), cpu_can_stop || Emu.IsStopped() || !(state & cpu_flag::wait); return retval; } diff --git a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp index e26978b94c..56e49ac3db 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp @@ -1749,7 +1749,7 @@ s32 cellSpursSetMaxContention(vm::ptr spurs, u32 wid, u32 maxContenti maxContention = CELL_SPURS_MAX_SPU; } - vm::reservation_light_op(spurs->wklMaxContention[wid % CELL_SPURS_MAX_WORKLOAD], [&](atomic_t& value) + vm::light_op(spurs->wklMaxContention[wid % CELL_SPURS_MAX_WORKLOAD], [&](atomic_t& value) { value &= wid < CELL_SPURS_MAX_WORKLOAD ? 0xF0 : 0x0F; value |= wid < CELL_SPURS_MAX_WORKLOAD ? maxContention : maxContention << 4; @@ -1801,9 +1801,9 @@ s32 cellSpursSetPriorities(vm::ptr spurs, u32 wid, vm::cptr pr return CELL_SPURS_CORE_ERROR_INVAL; } - vm::reservation_light_op(spurs->wklInfo(wid).prio64, [&](atomic_t& v){ v.release(prio); }); - vm::reservation_light_op(spurs->sysSrvMsgUpdateWorkload, [](atomic_t& v){ v.release(0xff); }); - vm::reservation_light_op(spurs->sysSrvMessage, [](atomic_t& v){ v.release(0xff); }); + vm::light_op(spurs->wklInfo(wid).prio64, [&](atomic_t& v){ v.release(prio); }); + vm::light_op(spurs->sysSrvMsgUpdateWorkload, [](atomic_t& v){ v.release(0xff); }); + vm::light_op(spurs->sysSrvMessage, [](atomic_t& v){ v.release(0xff); }); return CELL_OK; } @@ -1830,9 +1830,9 @@ s32 cellSpursSetPriority(vm::ptr spurs, u32 wid, u32 spuId, u32 prior if (spurs->exception) return CELL_SPURS_CORE_ERROR_STAT; - vm::reservation_light_op(spurs->wklInfo(wid).priority[spuId], [&](u8& v){ atomic_storage::release(v, priority); }); - vm::reservation_light_op(spurs->sysSrvMsgUpdateWorkload, [&](atomic_t& v){ v.bts(spuId); }); - vm::reservation_light_op(spurs->sysSrvMessage, [&](atomic_t& v){ v.bts(spuId); }); + vm::light_op(spurs->wklInfo(wid).priority[spuId], [&](u8& v){ atomic_storage::release(v, priority); }); + vm::light_op(spurs->sysSrvMsgUpdateWorkload, [&](atomic_t& v){ v.bts(spuId); }); + vm::light_op(spurs->sysSrvMessage, [&](atomic_t& v){ v.bts(spuId); }); return CELL_OK; } @@ -2319,7 +2319,7 @@ s32 _spurs::add_workload(vm::ptr spurs, vm::ptr wid, vm::cptrflags1 & SF1_32_WORKLOADS ? CELL_SPURS_MAX_WORKLOAD2 : CELL_SPURS_MAX_WORKLOAD; // TODO: check if can be changed - vm::reservation_light_op(spurs->wklEnabled, [&](atomic_be_t& value) + vm::light_op(spurs->wklEnabled, [&](atomic_be_t& value) { wnum = std::countl_one(value); // found empty position if (wnum < wmax) @@ -2402,7 +2402,7 @@ s32 _spurs::add_workload(vm::ptr spurs, vm::ptr wid, vm::cptrwklIdleSpuCountOrReadyCount2[wnum] = 0; } - vm::reservation_light_op(spurs->wklMaxContention[index], [&](atomic_t& data) + vm::light_op(spurs->wklMaxContention[index], [&](atomic_t& data) { data.atomic_op([&](u8& v) { @@ -2411,7 +2411,7 @@ s32 _spurs::add_workload(vm::ptr spurs, vm::ptr wid, vm::cptr((wnum <= 15 ? spurs->wklSignal1 : spurs->wklSignal2), [&](atomic_be_t& data) + vm::light_op((wnum <= 15 ? spurs->wklSignal1 : spurs->wklSignal2), [&](atomic_be_t& data) { data &= ~(0x8000 >> index); }); @@ -2450,8 +2450,8 @@ s32 _spurs::add_workload(vm::ptr spurs, vm::ptr wid, vm::cptrsysSrvMsgUpdateWorkload, [](atomic_t& v){ v.release(0xff); }); - vm::reservation_light_op(spurs->sysSrvMessage, [](atomic_t& v){ v.release(0xff); }); + vm::light_op(spurs->sysSrvMsgUpdateWorkload, [](atomic_t& v){ v.release(0xff); }); + vm::light_op(spurs->sysSrvMessage, [](atomic_t& v){ v.release(0xff); }); return CELL_OK; } @@ -2545,7 +2545,7 @@ s32 cellSpursShutdownWorkload(ppu_thread& ppu, vm::ptr spurs, u32 wid if (old_state == SPURS_WKL_STATE_SHUTTING_DOWN) { - vm::reservation_light_op(spurs->sysSrvMessage, [&](atomic_t& v){ v.release(0xff); }); + vm::light_op(spurs->sysSrvMessage, [&](atomic_t& v){ v.release(0xff); }); return CELL_OK; } @@ -2579,7 +2579,7 @@ s32 cellSpursWaitForWorkloadShutdown(ppu_thread& ppu, vm::ptr spurs, auto& info = spurs->wklSyncInfo(wid); - const bool ok = vm::reservation_light_op(info.x28, [](atomic_be_t& state) + const bool ok = vm::light_op(info.x28, [](atomic_be_t& state) { return state.fetch_op([](be_t& val) { @@ -2598,7 +2598,7 @@ s32 cellSpursWaitForWorkloadShutdown(ppu_thread& ppu, vm::ptr spurs, return CELL_SPURS_POLICY_MODULE_ERROR_STAT; } - const bool wait_sema = vm::reservation_light_op(spurs->wklEvent(wid), [](atomic_t& event) + const bool wait_sema = vm::light_op(spurs->wklEvent(wid), [](atomic_t& event) { return event.fetch_op([](u8& event) { @@ -2750,7 +2750,7 @@ s32 cellSpursSendWorkloadSignal(ppu_thread& ppu, vm::ptr spurs, u32 w return CELL_SPURS_POLICY_MODULE_ERROR_STAT; } - vm::reservation_light_op(wid < CELL_SPURS_MAX_WORKLOAD ? spurs->wklSignal1 : spurs->wklSignal2, [&](atomic_be_t& sig) + vm::light_op(wid < CELL_SPURS_MAX_WORKLOAD ? spurs->wklSignal1 : spurs->wklSignal2, [&](atomic_be_t& sig) { sig |= 0x8000 >> (wid % 16); }); @@ -2807,7 +2807,7 @@ s32 cellSpursReadyCountStore(ppu_thread& ppu, vm::ptr spurs, u32 wid, return CELL_SPURS_POLICY_MODULE_ERROR_STAT; } - vm::reservation_light_op(spurs->readyCount(wid), [&](atomic_t& v) + vm::light_op(spurs->readyCount(wid), [&](atomic_t& v) { v.release(static_cast(value)); }); @@ -2845,7 +2845,7 @@ s32 cellSpursReadyCountSwap(ppu_thread& ppu, vm::ptr spurs, u32 wid, return CELL_SPURS_POLICY_MODULE_ERROR_STAT; } - *old = vm::reservation_light_op(spurs->readyCount(wid), [&](atomic_t& v) + *old = vm::light_op(spurs->readyCount(wid), [&](atomic_t& v) { return v.exchange(static_cast(swap)); }); @@ -2885,7 +2885,7 @@ s32 cellSpursReadyCountCompareAndSwap(ppu_thread& ppu, vm::ptr spurs, u8 temp = static_cast(compare); - vm::reservation_light_op(spurs->readyCount(wid), [&](atomic_t& v) + vm::light_op(spurs->readyCount(wid), [&](atomic_t& v) { v.compare_exchange(temp, static_cast(swap)); }); @@ -2924,7 +2924,7 @@ s32 cellSpursReadyCountAdd(ppu_thread& ppu, vm::ptr spurs, u32 wid, v return CELL_SPURS_POLICY_MODULE_ERROR_STAT; } - *old = vm::reservation_light_op(spurs->readyCount(wid), [&](atomic_t& v) + *old = vm::light_op(spurs->readyCount(wid), [&](atomic_t& v) { return v.fetch_op([&](u8& val) { @@ -3960,7 +3960,7 @@ s32 _spurs::create_task(vm::ptr taskset, vm::ptr task_id, u32 tmp_task_id; - vm::reservation_light_op(vm::_ref>(taskset.ptr(&CellSpursTaskset::enabled).addr()), [&](atomic_be_t& ptr) + vm::light_op(vm::_ref>(taskset.ptr(&CellSpursTaskset::enabled).addr()), [&](atomic_be_t& ptr) { // NOTE: Realfw processes this using 4 32-bits atomic loops // But here its processed within a single 128-bit atomic op @@ -4008,7 +4008,7 @@ s32 _spurs::create_task(vm::ptr taskset, vm::ptr task_id, s32 _spurs::task_start(ppu_thread& ppu, vm::ptr taskset, u32 taskId) { - vm::reservation_light_op(taskset->pending_ready, [&](CellSpursTaskset::atomic_tasks_bitset& v) + vm::light_op(taskset->pending_ready, [&](CellSpursTaskset::atomic_tasks_bitset& v) { v.values[taskId / 32] |= (1u << 31) >> (taskId % 32); }); @@ -4831,7 +4831,7 @@ s32 cellSpursGetJobChainInfo(ppu_thread& ppu, vm::ptr jobChai // Read the commands queue atomically CellSpursJobChain data; - vm::reservation_peek(ppu, vm::unsafe_ptr_cast(jobChain), [&](const CellSpursJobChain_x00& jch) + vm::peek_op(ppu, vm::unsafe_ptr_cast(jobChain), [&](const CellSpursJobChain_x00& jch) { std::memcpy(&data, &jch, sizeof(jch)); }); @@ -5020,7 +5020,7 @@ s32 cellSpursJobGuardReset(vm::ptr jobGuard) if (!jobGuard.aligned()) return CELL_SPURS_JOB_ERROR_ALIGN; - vm::reservation_light_op(jobGuard->ncount0, [&](atomic_be_t& ncount0) + vm::light_op(jobGuard->ncount0, [&](atomic_be_t& ncount0) { ncount0 = jobGuard->ncount1; }); @@ -5107,7 +5107,7 @@ s32 cellSpursJobSetMaxGrab(vm::ptr jobChain, u32 maxGrabbedJo if ((spurs->wklEnabled & (0x80000000u >> wid)) == 0u) return CELL_SPURS_JOB_ERROR_STAT; - vm::reservation_light_op(jobChain->maxGrabbedJob, [&](atomic_be_t& v) + vm::light_op(jobChain->maxGrabbedJob, [&](atomic_be_t& v) { v.release(static_cast(maxGrabbedJob)); }); diff --git a/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp b/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp index ed8c22962c..75cc6a0eb6 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSpursSpu.cpp @@ -1603,7 +1603,7 @@ s32 spursTasksetProcessRequest(spu_thread& spu, s32 request, u32* taskId, u32* i { auto spurs = kernelCtxt->spurs; - vm::reservation_light_op(spurs->readyCount(kernelCtxt->wklCurrentId), [&](atomic_t& val) + vm::light_op(spurs->readyCount(kernelCtxt->wklCurrentId), [&](atomic_t& val) { val.fetch_op([&](u8& val) { diff --git a/rpcs3/Emu/Memory/vm_reservation.h b/rpcs3/Emu/Memory/vm_reservation.h index ff1b6579a5..1e4b586763 100644 --- a/rpcs3/Emu/Memory/vm_reservation.h +++ b/rpcs3/Emu/Memory/vm_reservation.h @@ -309,10 +309,10 @@ namespace vm // Read memory value in pseudo-atomic manner template - SAFE_BUFFERS inline auto reservation_peek(CPU&& cpu, _ptr_base ptr, F op) + SAFE_BUFFERS inline auto peek_op(CPU&& cpu, _ptr_base ptr, F op) { // Atomic operation will be performed on aligned 128 bytes of data, so the data size and alignment must comply - static_assert(sizeof(T) <= 128 && alignof(T) == sizeof(T), "vm::reservation_peek: unsupported type"); + static_assert(sizeof(T) <= 128 && alignof(T) == sizeof(T), "vm::peek_op: unsupported type"); // Use 128-byte aligned addr const u32 addr = static_cast(ptr.addr()) & -128; @@ -357,7 +357,7 @@ namespace vm } template - SAFE_BUFFERS inline auto reservation_light_op(T& data, F op) + SAFE_BUFFERS inline auto light_op(T& data, F op) { // Optimized real ptr -> vm ptr conversion, simply UB if out of range const u32 addr = static_cast(reinterpret_cast(&data) - g_base_addr);