drm/ttm: split populate out from binding.
authorDave Airlie <airlied@redhat.com>
Tue, 15 Sep 2020 01:16:53 +0000 (11:16 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 15 Sep 2020 23:34:54 +0000 (09:34 +1000)
Drivers have to call populate themselves now before binding.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200915024007.67163-5-airlied@gmail.com
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/radeon/radeon_ttm.c
drivers/gpu/drm/ttm/ttm_bo.c
drivers/gpu/drm/ttm/ttm_bo_util.c
drivers/gpu/drm/ttm/ttm_tt.c
include/drm/ttm/ttm_tt.h

index 3e8376891ec8230623523f1c14ecc8043919b59b..9353e41cf66925793ca7167912ae3dc854e08081 100644 (file)
@@ -547,8 +547,12 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
                goto out_cleanup;
        }
 
+       r = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
+       if (unlikely(r))
+               goto out_cleanup;
+
        /* Bind the memory to the GTT space */
-       r = ttm_tt_bind(bo->bdev, bo->ttm, &tmp_mem, ctx);
+       r = ttm_tt_bind(bo->bdev, bo->ttm, &tmp_mem);
        if (unlikely(r)) {
                goto out_cleanup;
        }
index 963bac0730dab49fdaad6982662a20b164354a5a..1088de50c14cedd50f33024827479c4f509bc084 100644 (file)
@@ -920,7 +920,11 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
        if (ret)
                return ret;
 
-       ret = ttm_tt_bind(bo->bdev, bo->ttm, &tmp_reg, &ctx);
+       ret = ttm_tt_populate(bo->bdev, bo->ttm, &ctx);
+       if (ret)
+               goto out;
+
+       ret = ttm_tt_bind(bo->bdev, bo->ttm, &tmp_reg);
        if (ret)
                goto out;
 
index b0e8c9337f5479bf752a1f3556791baa64820f50..2833028982010e16c4184395d7429cc27c4e7161 100644 (file)
@@ -233,7 +233,12 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo,
                goto out_cleanup;
        }
 
-       r = ttm_tt_bind(bo->bdev, bo->ttm, &tmp_mem, &ctx);
+       r = ttm_tt_populate(bo->bdev, bo->ttm, &ctx);
+       if (unlikely(r)) {
+               goto out_cleanup;
+       }
+
+       r = ttm_tt_bind(bo->bdev, bo->ttm, &tmp_mem);
        if (unlikely(r)) {
                goto out_cleanup;
        }
index bca0d42a970a9b0d893f72a25ebdab2a43a90f7a..654384c7aae1109be270efc1ac6355b6ecd62579 100644 (file)
@@ -260,7 +260,11 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
                        goto out_err;
 
                if (mem->mem_type != TTM_PL_SYSTEM) {
-                       ret = ttm_tt_bind(bdev, bo->ttm, mem, ctx);
+                       ret = ttm_tt_populate(bdev, bo->ttm, ctx);
+                       if (ret)
+                               goto out_err;
+
+                       ret = ttm_tt_bind(bdev, bo->ttm, mem);
                        if (ret)
                                goto out_err;
                }
index 8389972a1ed6f87510075bd85384ff2c913e7224..2ce97760a0892cb18c575f2766ceaa307305b4ce 100644 (file)
@@ -77,7 +77,12 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
                return ret;
 
        if (new_mem->mem_type != TTM_PL_SYSTEM) {
-               ret = ttm_tt_bind(bo->bdev, ttm, new_mem, ctx);
+
+               ret = ttm_tt_populate(bo->bdev, ttm, ctx);
+               if (unlikely(ret != 0))
+                       return ret;
+
+               ret = ttm_tt_bind(bo->bdev, ttm, new_mem);
                if (unlikely(ret != 0))
                        return ret;
        }
index 381face3cedb79418da9f6da29d94596f5991ecd..93d65e5e4205a7916e8135db91de22f583d13776 100644 (file)
@@ -312,8 +312,7 @@ void ttm_tt_unbind(struct ttm_bo_device *bdev, struct ttm_tt *ttm)
 }
 
 int ttm_tt_bind(struct ttm_bo_device *bdev,
-               struct ttm_tt *ttm, struct ttm_resource *bo_mem,
-               struct ttm_operation_ctx *ctx)
+               struct ttm_tt *ttm, struct ttm_resource *bo_mem)
 {
        int ret = 0;
 
@@ -323,10 +322,6 @@ int ttm_tt_bind(struct ttm_bo_device *bdev,
        if (ttm_tt_is_bound(ttm))
                return 0;
 
-       ret = ttm_tt_populate(bdev, ttm, ctx);
-       if (ret)
-               return ret;
-
        ret = bdev->driver->ttm_tt_bind(bdev, ttm, bo_mem);
        if (unlikely(ret != 0))
                return ret;
@@ -455,6 +450,9 @@ int ttm_tt_populate(struct ttm_bo_device *bdev,
 {
        int ret;
 
+       if (!ttm)
+               return -EINVAL;
+
        if (ttm_tt_is_populated(ttm))
                return 0;
 
@@ -466,6 +464,7 @@ int ttm_tt_populate(struct ttm_bo_device *bdev,
                ttm_tt_add_mapping(bdev, ttm);
        return ret;
 }
+EXPORT_SYMBOL(ttm_tt_populate);
 
 static void ttm_tt_clear_mapping(struct ttm_tt *ttm)
 {
index 86ae759ff0182b5dae2d33a468e4f9c398f32400..8f57d86ee67b532fa4e69061f0302cb40ba8c7c5 100644 (file)
@@ -173,8 +173,7 @@ void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma);
  * Bind the pages of @ttm to an aperture location identified by @bo_mem
  */
 int ttm_tt_bind(struct ttm_bo_device *bdev,
-               struct ttm_tt *ttm, struct ttm_resource *bo_mem,
-               struct ttm_operation_ctx *ctx);
+               struct ttm_tt *ttm, struct ttm_resource *bo_mem);
 
 /**
  * ttm_ttm_destroy: