NV2A : Trying to fix locking (not very successful atm)

This commit is contained in:
PatrickvL 2018-02-02 17:37:23 +01:00
parent c3d8cc2e0e
commit 57776c9027
4 changed files with 20 additions and 10 deletions

View File

@ -361,8 +361,11 @@ int pfifo_puller_thread(NV2AState *d)
while (true) {
state->cache_lock.lock();
std::unique_lock<std::mutex> _cache_lock(state->cache_lock); // TODO : Is this correct??
while (state->cache.empty() || !state->pull_enabled) {
state->cache_cond.wait(state->cache_lock);
state->cache_cond.wait(_cache_lock);
}
// Copy cache to working_cache

View File

@ -713,8 +713,10 @@ static void pgraph_method(NV2AState *d,
pg->lock.lock();
qemu_mutex_unlock_iothread();
std::unique_lock<std::mutex> _lock(pg->lock); // TODO : Is this correct??
while (pg->pending_interrupts & NV_PGRAPH_INTR_ERROR) {
pg->interrupt_cond.wait(pg->lock);
pg->interrupt_cond.wait(_lock);
}
}
break;
@ -784,7 +786,9 @@ static void pgraph_method(NV2AState *d,
!= GET_MASK(s, NV_PGRAPH_SURFACE_WRITE_3D)) {
break;
}
pg->flip_3d.wait(pg->lock);
std::unique_lock<std::mutex> _lock(pg->lock); // TODO : Is this correct??
pg->flip_3d.wait(_lock);
}
NV2A_DPRINTF("flip stall done\n");
break;
@ -2598,15 +2602,19 @@ static void pgraph_context_switch(NV2AState *d, unsigned int channel_id)
d->pgraph.lock.lock();
qemu_mutex_unlock_iothread();
std::unique_lock<std::mutex> _lock(d->pgraph.lock); // TODO : Is this correct??
while (d->pgraph.pending_interrupts & NV_PGRAPH_INTR_CONTEXT_SWITCH) {
d->pgraph.interrupt_cond.wait(d->pgraph.lock);
d->pgraph.interrupt_cond.wait(_lock);
}
}
}
static void pgraph_wait_fifo_access(NV2AState *d) {
while (!d->pgraph.fifo_access) {
d->pgraph.fifo_access_cond.wait(d->pgraph.lock);
std::unique_lock<std::mutex> _lock(d->pgraph.lock); // TODO : Is this correct??
while (!d->pgraph.fifo_access) {
d->pgraph.fifo_access_cond.wait(_lock);
}
}

View File

@ -704,7 +704,6 @@ uint32_t NV2ADevice::MMIORead(int barIndex, uint32_t addr, unsigned size)
}
}
// TODO : Log unexpected bar access
EmuWarning("NV2ADevice::MMIORead: Unhandled barIndex %d, addr %08X, size %d", barIndex, addr, size);
return 0;
}

View File

@ -293,7 +293,7 @@ typedef struct GraphicsContext {
typedef struct PGRAPHState {
std::unique_lock<std::mutex> lock;
std::mutex lock; // std::unique_lock<std::mutex>(lock, std::defer_lock);
uint32_t pending_interrupts;
uint32_t enabled_interrupts;
@ -436,7 +436,7 @@ typedef struct Cache1State {
enum FIFOEngine last_engine;
/* The actual command queue */
std::unique_lock<std::mutex> cache_lock;
std::mutex cache_lock; // std::unique_lock<std::mutex>(cache_lock, std::defer_lock);
std::condition_variable cache_cond;
std::queue<CacheEntry*> cache;
std::queue<CacheEntry*> working_cache;
@ -528,7 +528,7 @@ typedef struct NV2AState {
uint8_t cr[256]; /* CRT registers */
} prmcio; // Not in xqemu/openxbox?
std::mutex io_lock; // TODO ? std::unique_lock<std::mutex>
std::mutex io_lock;
//SDL_Window *sdl_window;
} NV2AState;