PPU: Clear reservation on context switch

Ensure that only 2 PPU reservations exist at maximum at a time.
This commit is contained in:
Eladash 2020-05-01 08:59:15 +03:00 committed by Ivan
parent 0e6937a359
commit 72bef8dd7f
2 changed files with 13 additions and 1 deletions

View File

@ -456,6 +456,10 @@ std::string ppu_thread::dump_regs() const
fmt::append(ret, "XER = [CA=%u | OV=%u | SO=%u | CNT=%u]\n", xer.ca, xer.ov, xer.so, xer.cnt);
fmt::append(ret, "VSCR = [SAT=%u | NJ=%u]\n", sat, nj);
fmt::append(ret, "FPSCR = [FL=%u | FG=%u | FE=%u | FU=%u]\n", fpscr.fl, fpscr.fg, fpscr.fe, fpscr.fu);
if (const u32 addr = raddr)
fmt::append(ret, "Reservation Addr = 0x%x", addr);
else
fmt::append(ret, "Reservation Addr = none");
return ret;
}
@ -666,6 +670,7 @@ void ppu_thread::cpu_task()
void ppu_thread::cpu_sleep()
{
raddr = 0; // Clear reservation
vm::temporary_unlock(*this);
lv2_obj::awake(this);
}

View File

@ -1109,9 +1109,16 @@ void lv2_obj::sleep_unlocked(cpu_thread& thread, u64 timeout)
}
// Find and remove the thread
unqueue(g_ppu, ppu);
if (!unqueue(g_ppu, ppu))
{
// Already sleeping
ppu_log.trace("sleep(): called on already sleeping thread.");
return;
}
unqueue(g_pending, ppu);
ppu->raddr = 0; // Clear reservation
ppu->start_time = start_time;
}