Skip to content

Commit

Permalink
SPU Test
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Aug 21, 2022
1 parent bf63a18 commit b3407b9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 18 additions & 5 deletions rpcs3/Emu/Cell/SPUThread.cpp
Expand Up @@ -3348,6 +3348,8 @@ u32 spu_thread::get_mfc_completed() const

bool spu_thread::process_mfc_cmd()
{
mfc_cmd_id++;

// Stall infinitely if MFC queue is full
while (mfc_size >= 16) [[unlikely]]
{
Expand Down Expand Up @@ -3440,7 +3442,7 @@ bool spu_thread::process_mfc_cmd()
if ([&]() -> bool
{
// Validation that it is indeed GETLLAR spinning (large time window is intentional)
if (last_getllar != pc || perf0.get() - last_gtsc >= 50'000)
if (last_getllar != pc || mfc_cmd_id - 1 != last_getllar_id || perf0.get() - last_gtsc >= 50'000)
{
// Seemingly not
getllar_busy_waiting_switch = umax;
Expand All @@ -3465,6 +3467,7 @@ bool spu_thread::process_mfc_cmd()
}

last_getllar = pc;
last_getllar_id = mfc_cmd_id;
last_gtsc = perf0.get();

if (getllar_busy_waiting_switch == true)
Expand Down Expand Up @@ -3495,6 +3498,7 @@ bool spu_thread::process_mfc_cmd()
std::memcpy(dump.data, rdata, 128);
}

last_getllar_id = mfc_cmd_id;
last_gtsc = perf0.get();
return true;
}
Expand All @@ -3507,6 +3511,11 @@ bool spu_thread::process_mfc_cmd()
}
}

last_getllar_id = mfc_cmd_id;
last_getllar = pc;
last_gtsc = perf0.get();
getllar_busy_waiting_switch = umax;

u64 ntime;
rsx::reservation_lock rsx_lock(addr, 128);

Expand Down Expand Up @@ -3592,10 +3601,7 @@ bool spu_thread::process_mfc_cmd()
raddr = addr;
rtime = ntime;
mov_rdata(_ref<spu_rdata_t>(ch_mfc_cmd.lsa & 0x3ff80), rdata);
last_getllar = pc;
last_gtsc = perf0.get();
getllar_busy_waiting_switch = umax;


ch_atomic_stat.set_value(MFC_GETLLAR_SUCCESS);

if (g_cfg.core.mfc_debug)
Expand Down Expand Up @@ -4217,6 +4223,13 @@ s64 spu_thread::get_ch_value(u32 ch)
case SPU_RdEventStat:
{
const u32 mask1 = ch_events.load().mask;

if (mask1 & SPU_EVENT_LR && raddr)
{
// Hack: force waiting for reservation loss even when LR is set
ch_events.fetch_op([](ch_events_t& x){ if ((x.events & x.mask) == SPU_EVENT_LR) return x.count = 0, true; return false; });
}

auto events = get_events(mask1, false, true);

if (events.count)
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/Emu/Cell/SPUThread.h
Expand Up @@ -721,6 +721,7 @@ class spu_thread : public cpu_thread

// MFC command data
spu_mfc_cmd ch_mfc_cmd;
u32 mfc_cmd_id = 0;

// MFC command queue
spu_mfc_cmd mfc_queue[16]{};
Expand Down Expand Up @@ -840,6 +841,7 @@ class spu_thread : public cpu_thread
u64 last_succ = 0;
u64 last_gtsc = 0;
u32 last_getllar = umax; // LS address of last GETLLAR (if matches current GETLLAR we can let the thread rest)
u32 last_getllar_id = umax;
u32 getllar_busy_waiting_switch = umax; // umax means the test needs evaluation, otherwise it's a boolean

std::vector<mfc_cmd_dump> mfc_history;
Expand Down

0 comments on commit b3407b9

Please sign in to comment.