SPU: Implement Accurate DMA (#8822)

This commit is contained in:
Eladash 2020-09-03 00:58:29 +03:00 committed by GitHub
parent ddfa077c3e
commit 73d23eb6e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 170 additions and 60 deletions

View file

@ -440,16 +440,20 @@ namespace vm
g_mutex.unlock();
}
bool reservation_lock_internal(u32 addr, atomic_t<u64>& res)
u64 reservation_lock_internal(u32 addr, atomic_t<u64>& res, u64 lock_bits)
{
for (u64 i = 0;; i++)
{
if (!res.bts(0)) [[likely]]
if (u64 rtime = res; !(rtime & 127) && reservation_trylock(res, rtime, lock_bits)) [[likely]]
{
break;
return rtime;
}
if (i < 15)
if (auto cpu = get_current_cpu_thread(); cpu && cpu->state)
{
cpu->check_state();
}
else if (i < 15)
{
busy_wait(500);
}
@ -458,14 +462,12 @@ namespace vm
// TODO: Accurate locking in this case
if (!(g_pages[addr / 4096].flags & page_writable))
{
return false;
return -1;
}
std::this_thread::yield();
}
}
return true;
}
static void _page_map(u32 addr, u8 flags, u32 size, utils::shm* shm)