]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/ttm: revert "drm/ttm: make TT creation purely optional v3"
authorChristian König <ckoenig.leichtzumerken@gmail.com>
Wed, 12 Aug 2020 03:03:49 +0000 (13:03 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 12 Aug 2020 03:26:28 +0000 (13:26 +1000)
This reverts commit 2ddef17678bc2ea1d20517dd2b4ed4aa967ffa8b.

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

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200811092400.188124-1-christian.koenig@amd.com
drivers/gpu/drm/ttm/ttm_bo.c
drivers/gpu/drm/ttm/ttm_bo_util.c
drivers/gpu/drm/ttm/ttm_bo_vm.c
drivers/gpu/drm/ttm/ttm_tt.c

index f297fd5e02d4d407b0f18e275a8202dc0c2f648e..cc6a4e7551e3175b05b9339169fae8761a1fe294 100644 (file)
@@ -287,11 +287,12 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
         */
 
        if (!(new_man->flags & TTM_MEMTYPE_FLAG_FIXED)) {
-               bool zero = !(old_man->flags & TTM_MEMTYPE_FLAG_FIXED);
-
-               ret = ttm_tt_create(bo, zero);
-               if (ret)
-                       goto out_err;
+               if (bo->ttm == NULL) {
+                       bool zero = !(old_man->flags & TTM_MEMTYPE_FLAG_FIXED);
+                       ret = ttm_tt_create(bo, zero);
+                       if (ret)
+                               goto out_err;
+               }
 
                ret = ttm_tt_set_placement_caching(bo->ttm, mem->placement);
                if (ret)
@@ -652,8 +653,13 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo,
        placement.num_busy_placement = 0;
        bdev->driver->evict_flags(bo, &placement);
 
-       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);
+       }
 
        evict_mem = bo->mem;
        evict_mem.mm_node = NULL;
@@ -1192,8 +1198,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.
@@ -1210,6 +1221,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);
index 7fb3e0bcbab42e2e8cf2be1af5f7a669140108eb..e6c8bd254055e82e3d288980098d5ed5dc927843 100644 (file)
@@ -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;
index dd60b96b7522e4a23141a86aa8f1b3940f98003e..33526c5df0e8ca1286216d47e272a64aa7b0b8ef 100644 (file)
@@ -351,11 +351,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;
index 9d1c7177384cf43041736bfc7fc8987ced603189..3437711ddb438a31c4d19eb5dfa7329eb798e755 100644 (file)
@@ -50,9 +50,6 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc)
 
        dma_resv_assert_held(bo->base.resv);
 
-       if (bo->ttm)
-               return 0;
-
        if (bdev->need_dma32)
                page_flags |= TTM_PAGE_FLAG_DMA32;
 
@@ -70,6 +67,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;
        }