If we free the bo immediately, then the PTE gets deallocated immediate.
We have to wait until execution completes before freeing the old code
bo.

Signed-off-by: Ilia Mirkin <imir...@alum.mit.edu>
---
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
index 13cb466645e..51a5857474b 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
@@ -750,7 +750,7 @@ int
 nvc0_screen_resize_text_area(struct nvc0_screen *screen, uint64_t size)
 {
    struct nouveau_pushbuf *push = screen->base.pushbuf;
-   struct nouveau_bo *bo;
+   struct nouveau_bo *bo, *old = screen->text;
    int ret;
 
    ret = nouveau_bo_new(screen->base.device, NV_VRAM_DOMAIN(&screen->base),
@@ -758,7 +758,6 @@ nvc0_screen_resize_text_area(struct nvc0_screen *screen, 
uint64_t size)
    if (ret)
       return ret;
 
-   nouveau_bo_ref(NULL, &screen->text);
    screen->text = bo;
 
    nouveau_heap_destroy(&screen->lib_code);
@@ -779,6 +778,10 @@ nvc0_screen_resize_text_area(struct nvc0_screen *screen, 
uint64_t size)
       PUSH_DATA (push, screen->text->offset);
    }
 
+   /* Kill the old text bo once all this is done executing. */
+   nouveau_fence_work(screen->base.fence.current,
+                      nouveau_fence_unref_bo, old);
+
    return 0;
 }
 
-- 
2.13.6

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to