Skip to content

Commit

Permalink
SPU: cpu_work() fixup, fix recursion in AV handler
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Sep 18, 2021
1 parent 1af19d8 commit c40f2c6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
10 changes: 5 additions & 5 deletions Utilities/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,11 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) no

bool handled = rsx::g_access_violation_handler(addr, is_writing);

if (cpu)
{
cpu->state += cpu_flag::temp;
}

if (handled)
{
g_tls_fault_rsx++;
Expand Down Expand Up @@ -1389,11 +1394,6 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context) no

if (vm::check_addr(addr, is_writing ? vm::page_writable : vm::page_readable))
{
if (cpu && cpu->test_stopped())
{
//
}

return true;
}

Expand Down
13 changes: 12 additions & 1 deletion rpcs3/Emu/Cell/SPUThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1657,14 +1657,20 @@ void spu_thread::cpu_task()

void spu_thread::cpu_work()
{
if (std::exchange(in_cpu_work, true))
{
return;
}

const auto timeout = +g_cfg.core.mfc_transfers_timeout;

// If either MFC size exceeds limit or timeout has been reached execute pending MFC commands
if (mfc_size > g_cfg.core.mfc_transfers_shuffling || (timeout && get_system_time() - mfc_last_timestamp >= timeout))
{
do_mfc(false, false);
check_mfc_interrupts(pc + 4);
}

in_cpu_work = false;
}

struct raw_spu_cleanup
Expand Down Expand Up @@ -3187,6 +3193,11 @@ bool spu_thread::process_mfc_cmd()
// Process MFC commands
do_mfc();

if (mfc_size < 16)
{
break;
}

auto old = state.add_fetch(cpu_flag::wait);

if (is_stopped(old))
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/Emu/Cell/SPUThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,8 @@ class spu_thread : public cpu_thread
u64 mfc_dump_idx = 0;
static constexpr u32 max_mfc_dump_idx = 2048;

bool in_cpu_work = false;

std::array<v128, 0x4000> stack_mirror; // Return address information

const char* current_func{}; // Current STOP or RDCH blocking function
Expand Down

0 comments on commit c40f2c6

Please sign in to comment.