This reverts commit 2ddef17678bc2ea1d20517dd2b4ed4aa967ffa8b.

As it turned out VMWGFX needs a much wider audit to fix this.

Signed-off-by: Christian König <christian.koe...@amd.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c      | 19 ++++++++++++++++---
 drivers/gpu/drm/ttm/ttm_bo_util.c |  7 ++-----
 drivers/gpu/drm/ttm/ttm_bo_vm.c   |  5 -----
 drivers/gpu/drm/ttm/ttm_tt.c      |  1 +
 4 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index ad09329b62d3..42386bda32fe 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -656,7 +656,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo,
                ttm_bo_wait(bo, false, false);
 
                ttm_bo_cleanup_memtype_use(bo);
-               return 0;
+               return ttm_tt_create(bo, false);
        }
 
        evict_mem = bo->mem;
@@ -1191,8 +1191,13 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
        /*
         * Remove the backing store if no placement is given.
         */
-       if (!placement->num_placement && !placement->num_busy_placement)
-               return ttm_bo_pipeline_gutting(bo);
+       if (!placement->num_placement && !placement->num_busy_placement) {
+               ret = ttm_bo_pipeline_gutting(bo);
+               if (ret)
+                       return ret;
+
+               return ttm_tt_create(bo, false);
+       }
 
        /*
         * Check whether we need to move buffer.
@@ -1209,6 +1214,14 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
                ttm_flag_masked(&bo->mem.placement, new_flags,
                                ~TTM_PL_MASK_MEMTYPE);
        }
+       /*
+        * We might need to add a TTM.
+        */
+       if (bo->mem.mem_type == TTM_PL_SYSTEM && bo->ttm == NULL) {
+               ret = ttm_tt_create(bo, true);
+               if (ret)
+                       return ret;
+       }
        return 0;
 }
 EXPORT_SYMBOL(ttm_bo_validate);
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c 
b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 496158acd5b9..76376dc71f25 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -531,15 +531,12 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo,
                .interruptible = false,
                .no_wait_gpu = false
        };
-       struct ttm_tt *ttm;
+       struct ttm_tt *ttm = bo->ttm;
        pgprot_t prot;
        int ret;
 
-       ret = ttm_tt_create(bo, true);
-       if (ret)
-               return ret;
+       BUG_ON(!ttm);
 
-       ttm = bo->ttm;
        ret = ttm_tt_populate(ttm, &ctx);
        if (ret)
                return ret;
diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index ba2e8bd198ad..e90c5c806645 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -347,11 +347,6 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
 
                };
 
-               if (ttm_tt_create(bo, true)) {
-                       ret = VM_FAULT_OOM;
-                       goto out_io_unlock;
-               }
-
                ttm = bo->ttm;
                if (ttm_tt_populate(bo->ttm, &ctx)) {
                        ret = VM_FAULT_OOM;
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index bdd6169cef13..05c9147ac6d3 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -70,6 +70,7 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool 
zero_alloc)
                page_flags |= TTM_PAGE_FLAG_SG;
                break;
        default:
+               bo->ttm = NULL;
                pr_err("Illegal buffer object type\n");
                return -EINVAL;
        }
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to