drm/ttm: add context to driver move callback as well
authorChristian König <christian.koenig@amd.com>
Wed, 26 Apr 2017 14:31:14 +0000 (16:31 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 6 Dec 2017 17:48:03 +0000 (12:48 -0500)
Instead of passing the parameters manually.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
Tested-by: Michel Dänzer <michel.daenzer@amd.com>
Acked-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
drivers/gpu/drm/nouveau/nouveau_bo.c
drivers/gpu/drm/qxl/qxl_ttm.c
drivers/gpu/drm/radeon/radeon_ttm.c
drivers/gpu/drm/ttm/ttm_bo.c
drivers/gpu/drm/virtio/virtgpu_ttm.c
include/drm/ttm/ttm_bo_driver.h

index 48b24155462cf9590758b270b295a2e2d6cd9636..0e90f64c2c09c87302b31ace2a3f55fbc635bebf 100644 (file)
@@ -553,10 +553,9 @@ out_cleanup:
        return r;
 }
 
-static int amdgpu_bo_move(struct ttm_buffer_object *bo,
-                       bool evict, bool interruptible,
-                       bool no_wait_gpu,
-                       struct ttm_mem_reg *new_mem)
+static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
+                         struct ttm_operation_ctx *ctx,
+                         struct ttm_mem_reg *new_mem)
 {
        struct amdgpu_device *adev;
        struct amdgpu_bo *abo;
@@ -591,19 +590,21 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo,
 
        if (old_mem->mem_type == TTM_PL_VRAM &&
            new_mem->mem_type == TTM_PL_SYSTEM) {
-               r = amdgpu_move_vram_ram(bo, evict, interruptible,
-                                       no_wait_gpu, new_mem);
+               r = amdgpu_move_vram_ram(bo, evict, ctx->interruptible,
+                                       ctx->no_wait_gpu, new_mem);
        } else if (old_mem->mem_type == TTM_PL_SYSTEM &&
                   new_mem->mem_type == TTM_PL_VRAM) {
-               r = amdgpu_move_ram_vram(bo, evict, interruptible,
-                                           no_wait_gpu, new_mem);
+               r = amdgpu_move_ram_vram(bo, evict, ctx->interruptible,
+                                           ctx->no_wait_gpu, new_mem);
        } else {
-               r = amdgpu_move_blit(bo, evict, no_wait_gpu, new_mem, old_mem);
+               r = amdgpu_move_blit(bo, evict, ctx->no_wait_gpu,
+                                    new_mem, old_mem);
        }
 
        if (r) {
 memcpy:
-               r = ttm_bo_move_memcpy(bo, interruptible, no_wait_gpu, new_mem);
+               r = ttm_bo_move_memcpy(bo, ctx->interruptible,
+                                      ctx->no_wait_gpu, new_mem);
                if (r) {
                        return r;
                }
index dae90cb748a41d76919daa1443c472e008d310f3..949bf6b3feab3aa0d25ac1ee51a0d6bb20a4ef61 100644 (file)
@@ -1328,8 +1328,9 @@ nouveau_bo_vm_cleanup(struct ttm_buffer_object *bo,
 }
 
 static int
-nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr,
-               bool no_wait_gpu, struct ttm_mem_reg *new_reg)
+nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
+               struct ttm_operation_ctx *ctx,
+               struct ttm_mem_reg *new_reg)
 {
        struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
        struct nouveau_bo *nvbo = nouveau_bo(bo);
@@ -1337,7 +1338,7 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr,
        struct nouveau_drm_tile *new_tile = NULL;
        int ret = 0;
 
-       ret = ttm_bo_wait(bo, intr, no_wait_gpu);
+       ret = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu);
        if (ret)
                return ret;
 
@@ -1361,22 +1362,26 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr,
        /* Hardware assisted copy. */
        if (drm->ttm.move) {
                if (new_reg->mem_type == TTM_PL_SYSTEM)
-                       ret = nouveau_bo_move_flipd(bo, evict, intr,
-                                                   no_wait_gpu, new_reg);
+                       ret = nouveau_bo_move_flipd(bo, evict,
+                                                   ctx->interruptible,
+                                                   ctx->no_wait_gpu, new_reg);
                else if (old_reg->mem_type == TTM_PL_SYSTEM)
-                       ret = nouveau_bo_move_flips(bo, evict, intr,
-                                                   no_wait_gpu, new_reg);
+                       ret = nouveau_bo_move_flips(bo, evict,
+                                                   ctx->interruptible,
+                                                   ctx->no_wait_gpu, new_reg);
                else
-                       ret = nouveau_bo_move_m2mf(bo, evict, intr,
-                                                  no_wait_gpu, new_reg);
+                       ret = nouveau_bo_move_m2mf(bo, evict,
+                                                  ctx->interruptible,
+                                                  ctx->no_wait_gpu, new_reg);
                if (!ret)
                        goto out;
        }
 
        /* Fallback to software copy. */
-       ret = ttm_bo_wait(bo, intr, no_wait_gpu);
+       ret = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu);
        if (ret == 0)
-               ret = ttm_bo_move_memcpy(bo, intr, no_wait_gpu, new_reg);
+               ret = ttm_bo_move_memcpy(bo, ctx->interruptible,
+                                        ctx->no_wait_gpu, new_reg);
 
 out:
        if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) {
index 586ecd6e0e457ec020116c87d065abfc1e5e63a2..d866f329e7d8501daa4cddcf9a0ebf878bc5c706 100644 (file)
@@ -341,15 +341,14 @@ static void qxl_move_null(struct ttm_buffer_object *bo,
        new_mem->mm_node = NULL;
 }
 
-static int qxl_bo_move(struct ttm_buffer_object *bo,
-                      bool evict, bool interruptible,
-                      bool no_wait_gpu,
+static int qxl_bo_move(struct ttm_buffer_object *bo, bool evict,
+                      struct ttm_operation_ctx *ctx,
                       struct ttm_mem_reg *new_mem)
 {
        struct ttm_mem_reg *old_mem = &bo->mem;
        int ret;
 
-       ret = ttm_bo_wait(bo, interruptible, no_wait_gpu);
+       ret = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu);
        if (ret)
                return ret;
 
@@ -358,7 +357,7 @@ static int qxl_bo_move(struct ttm_buffer_object *bo,
                qxl_move_null(bo, new_mem);
                return 0;
        }
-       return ttm_bo_move_memcpy(bo, interruptible, no_wait_gpu,
+       return ttm_bo_move_memcpy(bo, ctx->interruptible, ctx->no_wait_gpu,
                                  new_mem);
 }
 
index ef7cb83331b3854ee35d6021d57e7e7c19a33c47..98e30d71d9e0f8970b17d058e08e491d1dcb2c72 100644 (file)
@@ -393,17 +393,16 @@ out_cleanup:
        return r;
 }
 
-static int radeon_bo_move(struct ttm_buffer_object *bo,
-                       bool evict, bool interruptible,
-                       bool no_wait_gpu,
-                       struct ttm_mem_reg *new_mem)
+static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
+                         struct ttm_operation_ctx *ctx,
+                         struct ttm_mem_reg *new_mem)
 {
        struct radeon_device *rdev;
        struct radeon_bo *rbo;
        struct ttm_mem_reg *old_mem = &bo->mem;
        int r;
 
-       r = ttm_bo_wait(bo, interruptible, no_wait_gpu);
+       r = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu);
        if (r)
                return r;
 
@@ -433,19 +432,21 @@ static int radeon_bo_move(struct ttm_buffer_object *bo,
 
        if (old_mem->mem_type == TTM_PL_VRAM &&
            new_mem->mem_type == TTM_PL_SYSTEM) {
-               r = radeon_move_vram_ram(bo, evict, interruptible,
-                                       no_wait_gpu, new_mem);
+               r = radeon_move_vram_ram(bo, evict, ctx->interruptible,
+                                       ctx->no_wait_gpu, new_mem);
        } else if (old_mem->mem_type == TTM_PL_SYSTEM &&
                   new_mem->mem_type == TTM_PL_VRAM) {
-               r = radeon_move_ram_vram(bo, evict, interruptible,
-                                           no_wait_gpu, new_mem);
+               r = radeon_move_ram_vram(bo, evict, ctx->interruptible,
+                                           ctx->no_wait_gpu, new_mem);
        } else {
-               r = radeon_move_blit(bo, evict, no_wait_gpu, new_mem, old_mem);
+               r = radeon_move_blit(bo, evict, ctx->no_wait_gpu,
+                                    new_mem, old_mem);
        }
 
        if (r) {
 memcpy:
-               r = ttm_bo_move_memcpy(bo, interruptible, no_wait_gpu, new_mem);
+               r = ttm_bo_move_memcpy(bo, ctx->interruptible,
+                                      ctx->no_wait_gpu, new_mem);
                if (r) {
                        return r;
                }
index 4ed30ffa411fe651b777b3be72f8aa991ed0939a..d3448c38f00df602c0bb06a65ea529bbb5eb226b 100644 (file)
@@ -327,8 +327,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
                ret = ttm_bo_move_ttm(bo, ctx->interruptible,
                                      ctx->no_wait_gpu, mem);
        else if (bdev->driver->move)
-               ret = bdev->driver->move(bo, evict, ctx->interruptible,
-                                        ctx->no_wait_gpu, mem);
+               ret = bdev->driver->move(bo, evict, ctx, mem);
        else
                ret = ttm_bo_move_memcpy(bo, ctx->interruptible,
                                         ctx->no_wait_gpu, mem);
index cd389c5eaef5b74aefd052bdaddc11a27b6d8f31..488c6bd032fc6ab6bba167a76db8d4a60c28c59d 100644 (file)
@@ -369,14 +369,13 @@ static void virtio_gpu_move_null(struct ttm_buffer_object *bo,
        new_mem->mm_node = NULL;
 }
 
-static int virtio_gpu_bo_move(struct ttm_buffer_object *bo,
-                             bool evict, bool interruptible,
-                             bool no_wait_gpu,
+static int virtio_gpu_bo_move(struct ttm_buffer_object *bo, bool evict,
+                             struct ttm_operation_ctx *ctx,
                              struct ttm_mem_reg *new_mem)
 {
        int ret;
 
-       ret = ttm_bo_wait(bo, interruptible, no_wait_gpu);
+       ret = ttm_bo_wait(bo, ctx->interruptible, ctx->no_wait_gpu);
        if (ret)
                return ret;
 
index 494322a5f239f36cec385fb51831cf21e9427dea..6996d884c50875aeb851c214528d4b252c45e6c5 100644 (file)
@@ -409,15 +409,13 @@ struct ttm_bo_driver {
         * @bo: the buffer to move
         * @evict: whether this motion is evicting the buffer from
         * the graphics address space
-        * @interruptible: Use interruptible sleeps if possible when sleeping.
-        * @no_wait: whether this should give up and return -EBUSY
-        * if this move would require sleeping
+        * @ctx: context for this move with parameters
         * @new_mem: the new memory region receiving the buffer
         *
         * Move a buffer between two memory regions.
         */
        int (*move)(struct ttm_buffer_object *bo, bool evict,
-                   bool interruptible, bool no_wait_gpu,
+                   struct ttm_operation_ctx *ctx,
                    struct ttm_mem_reg *new_mem);
 
        /**