nouveau: avoid double-emitting fence
authorIlia Mirkin <imirkin@alum.mit.edu>
Mon, 12 Oct 2015 21:15:32 +0000 (17:15 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Mon, 12 Oct 2015 21:21:29 +0000 (17:21 -0400)
The act of ensuring that there is space can cause a flush to happen,
which will emit the current screen fence. If that is the fence we're
trying to wait on, then it will have been emitted as a result of doing
the PUSH_SPACE. Don't attempt to emit it a second time.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Fixes: 8053c9208f (nouveau: avoid emitting new fences unnecessarily)
Cc: mesa-stable@lists.freedesktop.org
src/gallium/drivers/nouveau/nouveau_fence.c

index 18b15920185913b9a4849dbd01a46b7d1e32836d..21cf2b9ae5e64ae0f75e3e3f1253386f62cf6347 100644 (file)
@@ -192,7 +192,11 @@ nouveau_fence_wait(struct nouveau_fence *fence)
 
    if (fence->state < NOUVEAU_FENCE_STATE_EMITTED) {
       PUSH_SPACE(screen->pushbuf, 8);
-      nouveau_fence_emit(fence);
+      /* The space allocation might trigger a flush, which could emit the
+       * current fence. So check again.
+       */
+      if (fence->state < NOUVEAU_FENCE_STATE_EMITTED)
+         nouveau_fence_emit(fence);
    }
 
    if (fence->state < NOUVEAU_FENCE_STATE_FLUSHED)