drm/nouveau/ttm: plumb ctx through move functions.
authorDave Airlie <airlied@redhat.com>
Wed, 23 Sep 2020 03:04:48 +0000 (13:04 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 23 Sep 2020 20:41:29 +0000 (06:41 +1000)
This just uses the ctx instead of passing bools and recreating it.

Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200923030454.362731-5-airlied@gmail.com
drivers/gpu/drm/nouveau/nouveau_bo.c

index 2ee7564..0cbf5fb 100644 (file)
@@ -796,8 +796,9 @@ done:
 }
 
 static int
-nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
-                    bool no_wait_gpu, struct ttm_resource *new_reg)
+nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict,
+                    struct ttm_operation_ctx *ctx,
+                    struct ttm_resource *new_reg)
 {
        struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
        struct nouveau_channel *chan = drm->ttm.chan;
@@ -816,7 +817,7 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
        }
 
        mutex_lock_nested(&cli->mutex, SINGLE_DEPTH_NESTING);
-       ret = nouveau_fence_sync(nouveau_bo(bo), chan, true, intr);
+       ret = nouveau_fence_sync(nouveau_bo(bo), chan, true, ctx->interruptible);
        if (ret == 0) {
                ret = drm->ttm.move(chan, bo, &bo->mem, new_reg);
                if (ret == 0) {
@@ -903,10 +904,10 @@ nouveau_bo_move_init(struct nouveau_drm *drm)
 }
 
 static int
-nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
-                     bool no_wait_gpu, struct ttm_resource *new_reg)
+nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict,
+                     struct ttm_operation_ctx *ctx,
+                     struct ttm_resource *new_reg)
 {
-       struct ttm_operation_ctx ctx = { intr, no_wait_gpu };
        struct ttm_place placement_memtype = {
                .fpfn = 0,
                .lpfn = 0,
@@ -922,11 +923,11 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
 
        tmp_reg = *new_reg;
        tmp_reg.mm_node = NULL;
-       ret = ttm_bo_mem_space(bo, &placement, &tmp_reg, &ctx);
+       ret = ttm_bo_mem_space(bo, &placement, &tmp_reg, ctx);
        if (ret)
                return ret;
 
-       ret = ttm_tt_populate(bo->bdev, bo->ttm, &ctx);
+       ret = ttm_tt_populate(bo->bdev, bo->ttm, ctx);
        if (ret)
                goto out;
 
@@ -934,21 +935,21 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
        if (ret)
                goto out;
 
-       ret = nouveau_bo_move_m2mf(bo, true, intr, no_wait_gpu, &tmp_reg);
+       ret = nouveau_bo_move_m2mf(bo, true, ctx, &tmp_reg);
        if (ret)
                goto out;
 
-       ret = ttm_bo_move_ttm(bo, &ctx, new_reg);
+       ret = ttm_bo_move_ttm(bo, ctx, new_reg);
 out:
        ttm_resource_free(bo, &tmp_reg);
        return ret;
 }
 
 static int
-nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,
-                     bool no_wait_gpu, struct ttm_resource *new_reg)
+nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict,
+                     struct ttm_operation_ctx *ctx,
+                     struct ttm_resource *new_reg)
 {
-       struct ttm_operation_ctx ctx = { intr, no_wait_gpu };
        struct ttm_place placement_memtype = {
                .fpfn = 0,
                .lpfn = 0,
@@ -964,15 +965,15 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,
 
        tmp_reg = *new_reg;
        tmp_reg.mm_node = NULL;
-       ret = ttm_bo_mem_space(bo, &placement, &tmp_reg, &ctx);
+       ret = ttm_bo_mem_space(bo, &placement, &tmp_reg, ctx);
        if (ret)
                return ret;
 
-       ret = ttm_bo_move_ttm(bo, &ctx, &tmp_reg);
+       ret = ttm_bo_move_ttm(bo, ctx, &tmp_reg);
        if (ret)
                goto out;
 
-       ret = nouveau_bo_move_m2mf(bo, true, intr, no_wait_gpu, new_reg);
+       ret = nouveau_bo_move_m2mf(bo, true, ctx, new_reg);
        if (ret)
                goto out;
 
@@ -1083,17 +1084,14 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
        /* Hardware assisted copy. */
        if (drm->ttm.move) {
                if (new_reg->mem_type == TTM_PL_SYSTEM)
-                       ret = nouveau_bo_move_flipd(bo, evict,
-                                                   ctx->interruptible,
-                                                   ctx->no_wait_gpu, new_reg);
+                       ret = nouveau_bo_move_flipd(bo, evict, ctx,
+                                                   new_reg);
                else if (old_reg->mem_type == TTM_PL_SYSTEM)
-                       ret = nouveau_bo_move_flips(bo, evict,
-                                                   ctx->interruptible,
-                                                   ctx->no_wait_gpu, new_reg);
+                       ret = nouveau_bo_move_flips(bo, evict, ctx,
+                                                   new_reg);
                else
-                       ret = nouveau_bo_move_m2mf(bo, evict,
-                                                  ctx->interruptible,
-                                                  ctx->no_wait_gpu, new_reg);
+                       ret = nouveau_bo_move_m2mf(bo, evict, ctx,
+                                                  new_reg);
                if (!ret)
                        goto out;
        }