From b271e5c3971a95c1ca8675c558961fac822a9579 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 26 May 2014 06:54:03 +0100 Subject: [PATCH 1/2] sna: Assert that we do not replace active IO buffers References: https://bugs.freedesktop.org/show_bug.cgi?id=79238 Signed-off-by: Chris Wilson --- src/sna/kgem.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sna/kgem.c b/src/sna/kgem.c index 6078302..98aa48c 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -6281,7 +6281,7 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem, __FUNCTION__, size, bo->used, bytes(&bo->base))); gem_write__cachealigned(kgem->fd, bo->base.handle, 0, bo->used, bo->mem); - kgem_buffer_release(kgem, bo); + assert(list_is_empty(&bo->base.vma)); bo->need_io = 0; bo->write = 0; offset = 0; @@ -6338,13 +6338,14 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem, goto done; } - if (size <= bytes(&bo->base) && + if (bo->base.refcnt == 1 && + size <= bytes(&bo->base) && (bo->base.rq == NULL || !__kgem_busy(kgem, bo->base.handle))) { DBG(("%s: reusing whole buffer? size=%d, total=%d\n", __FUNCTION__, size, bytes(&bo->base))); __kgem_bo_clear_busy(&bo->base); - kgem_buffer_release(kgem, bo); + assert(list_is_empty(&bo->base.vma)); switch (bo->mmapped) { case MMAPPED_CPU: -- 1.9.1