Skip to content

Commit

Permalink
nouveau: more locking - make sure that fence work is always done with
Browse files Browse the repository at this point in the history
the push mutex acquired
  • Loading branch information
imirkin committed Jun 18, 2016
1 parent 654340d commit 5e8e523
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/gallium/drivers/nouveau/nouveau_buffer.c
Expand Up @@ -80,6 +80,8 @@ release_allocation(struct nouveau_mm_allocation **mm,
inline void
nouveau_buffer_release_gpu_storage(struct nv04_resource *buf)
{
if (buf->fence)
pipe_mutex_lock(buf->fence->screen->push_mutex);
if (buf->fence && buf->fence->state < NOUVEAU_FENCE_STATE_FLUSHED) {
nouveau_fence_work(buf->fence, nouveau_fence_unref_bo, buf->bo);
buf->bo = NULL;
Expand All @@ -89,6 +91,8 @@ nouveau_buffer_release_gpu_storage(struct nv04_resource *buf)

if (buf->mm)
release_allocation(&buf->mm, buf->fence);
if (buf->fence)
pipe_mutex_unlock(buf->fence->screen->push_mutex);

if (buf->domain == NOUVEAU_BO_VRAM)
NOUVEAU_DRV_STAT_RES(buf, buf_obj_current_bytes_vid, -(uint64_t)buf->base.width0);
Expand Down
7 changes: 5 additions & 2 deletions src/gallium/drivers/nouveau/nv50/nv50_miptree.c
Expand Up @@ -163,10 +163,13 @@ nv50_miptree_destroy(struct pipe_screen *pscreen, struct pipe_resource *pt)
{
struct nv50_miptree *mt = nv50_miptree(pt);

if (mt->base.fence && mt->base.fence->state < NOUVEAU_FENCE_STATE_FLUSHED)
if (mt->base.fence && mt->base.fence->state < NOUVEAU_FENCE_STATE_FLUSHED) {
pipe_mutex_lock(nouveau_screen(pscreen)->push_mutex);
nouveau_fence_work(mt->base.fence, nouveau_fence_unref_bo, mt->base.bo);
else
pipe_mutex_unlock(nouveau_screen(pscreen)->push_mutex);
} else {
nouveau_bo_ref(NULL, &mt->base.bo);
}

nouveau_fence_ref(NULL, &mt->base.fence);
nouveau_fence_ref(NULL, &mt->base.fence_wr);
Expand Down
5 changes: 4 additions & 1 deletion src/gallium/drivers/nouveau/nv50/nv50_query_hw.c
Expand Up @@ -56,9 +56,12 @@ nv50_hw_query_allocate(struct nv50_context *nv50, struct nv50_query *q,
if (hq->mm) {
if (hq->state == NV50_HW_QUERY_STATE_READY)
nouveau_mm_free(hq->mm);
else
else {
pipe_mutex_lock(screen->base.push_mutex);
nouveau_fence_work(screen->base.fence.current,
nouveau_mm_free_work, hq->mm);
pipe_mutex_unlock(screen->base.push_mutex);
}
}
}
if (size) {
Expand Down
5 changes: 4 additions & 1 deletion src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c
Expand Up @@ -48,9 +48,12 @@ nvc0_hw_query_allocate(struct nvc0_context *nvc0, struct nvc0_query *q,
if (hq->mm) {
if (hq->state == NVC0_HW_QUERY_STATE_READY)
nouveau_mm_free(hq->mm);
else
else {
pipe_mutex_lock(screen->base.push_mutex);
nouveau_fence_work(screen->base.fence.current,
nouveau_mm_free_work, hq->mm);
pipe_mutex_unlock(screen->base.push_mutex);
}
}
}
if (size) {
Expand Down

0 comments on commit 5e8e523

Please sign in to comment.