Signed-off-by: Maarten Lankhorst <[email protected]>
---
 drivers/gpu/drm/nouveau/nouveau_bo.c  |   16 ++++++++++++++++
 drivers/gpu/drm/nouveau/nouveau_bo.h  |    1 +
 drivers/gpu/drm/nouveau/nouveau_gem.c |    2 +-
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 2fa736d..cee7448 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1551,9 +1551,25 @@ nouveau_bo_vma_del(struct nouveau_bo *nvbo, struct 
nouveau_vma *vma)
 {
        if (vma->node) {
                if (nvbo->bo.mem.mem_type != TTM_PL_SYSTEM) {
+                       ttm_bo_reserve(&nvbo->bo, false, false, false, 0);
                        spin_lock(&nvbo->bo.bdev->fence_lock);
                        ttm_bo_wait(&nvbo->bo, false, false, false);
                        spin_unlock(&nvbo->bo.bdev->fence_lock);
+                       ttm_bo_unreserve(&nvbo->bo);
+                       nouveau_vm_unmap(vma);
+               }
+
+               nouveau_vm_put(vma);
+               list_del(&vma->head);
+       }
+}
+
+void
+nouveau_bo_vma_del_reserved(struct nouveau_bo *nvbo, struct nouveau_vma *vma)
+{
+       if (vma->node) {
+               if (nvbo->bo.mem.mem_type != TTM_PL_SYSTEM) {
+                       ttm_bo_wait(&nvbo->bo, false, false, false);
                        nouveau_vm_unmap(vma);
                }
 
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.h 
b/drivers/gpu/drm/nouveau/nouveau_bo.h
index dec51b1..61b8980 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.h
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.h
@@ -84,6 +84,7 @@ nouveau_bo_vma_find(struct nouveau_bo *, struct nouveau_vm *);
 int  nouveau_bo_vma_add(struct nouveau_bo *, struct nouveau_vm *,
                        struct nouveau_vma *);
 void nouveau_bo_vma_del(struct nouveau_bo *, struct nouveau_vma *);
+void nouveau_bo_vma_del_reserved(struct nouveau_bo *, struct nouveau_vma *);
 
 /* TODO: submit equivalent to TTM generic API upstream? */
 static inline void __iomem *
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c 
b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 18342b0..5972ecd 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -121,7 +121,7 @@ nouveau_gem_object_close(struct drm_gem_object *gem, struct 
drm_file *file_priv)
        vma = nouveau_bo_vma_find(nvbo, cli->base.vm);
        if (vma) {
                if (--vma->refcount == 0) {
-                       nouveau_bo_vma_del(nvbo, vma);
+                       nouveau_bo_vma_del_reserved(nvbo, vma);
                        kfree(vma);
                }
        }

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to