drm/ttm: use an operation context for ttm_bo_mem_space v2
authorChristian König <christian.koenig@amd.com>
Wed, 12 Apr 2017 13:33:00 +0000 (15:33 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 6 Dec 2017 17:48:02 +0000 (12:48 -0500)
Instead of specifying interruptible and no_wait_gpu manually.

v2: rebase

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_device.c
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
include/drm/ttm/ttm_bo_driver.h

index a43d096ebb52e38331203ae321f68f177a8106f2..0750b323e03fcbeb076c5d26c267075e81d35607 100644 (file)
@@ -657,6 +657,7 @@ void amdgpu_fw_reserve_vram_fini(struct amdgpu_device *adev)
  */
 int amdgpu_fw_reserve_vram_init(struct amdgpu_device *adev)
 {
+       struct ttm_operation_ctx ctx = { false, false };
        int r = 0;
        int i;
        u64 vram_size = adev->mc.visible_vram_size;
@@ -693,8 +694,8 @@ int amdgpu_fw_reserve_vram_init(struct amdgpu_device *adev)
                }
 
                ttm_bo_mem_put(&bo->tbo, &bo->tbo.mem);
-               r = ttm_bo_mem_space(&bo->tbo, &bo->placement, &bo->tbo.mem,
-                                    false, false);
+               r = ttm_bo_mem_space(&bo->tbo, &bo->placement,
+                                    &bo->tbo.mem, &ctx);
                if (r)
                        goto error_pin;
 
index 07ecf721ebf91b4d24647f6b9f7c7cb62bc1939a..48b24155462cf9590758b270b295a2e2d6cd9636 100644 (file)
@@ -471,6 +471,7 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo,
                                bool no_wait_gpu,
                                struct ttm_mem_reg *new_mem)
 {
+       struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };
        struct amdgpu_device *adev;
        struct ttm_mem_reg *old_mem = &bo->mem;
        struct ttm_mem_reg tmp_mem;
@@ -488,8 +489,7 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo,
        placements.fpfn = 0;
        placements.lpfn = 0;
        placements.flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT;
-       r = ttm_bo_mem_space(bo, &placement, &tmp_mem,
-                            interruptible, no_wait_gpu);
+       r = ttm_bo_mem_space(bo, &placement, &tmp_mem, &ctx);
        if (unlikely(r)) {
                return r;
        }
@@ -518,6 +518,7 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo,
                                bool no_wait_gpu,
                                struct ttm_mem_reg *new_mem)
 {
+       struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };
        struct amdgpu_device *adev;
        struct ttm_mem_reg *old_mem = &bo->mem;
        struct ttm_mem_reg tmp_mem;
@@ -535,8 +536,7 @@ static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo,
        placements.fpfn = 0;
        placements.lpfn = 0;
        placements.flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT;
-       r = ttm_bo_mem_space(bo, &placement, &tmp_mem,
-                            interruptible, no_wait_gpu);
+       r = ttm_bo_mem_space(bo, &placement, &tmp_mem, &ctx);
        if (unlikely(r)) {
                return r;
        }
@@ -878,6 +878,7 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm,
 int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
 {
        struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
+       struct ttm_operation_ctx ctx = { false, false };
        struct amdgpu_ttm_tt *gtt = (void*)bo->ttm;
        struct ttm_mem_reg tmp;
        struct ttm_placement placement;
@@ -900,7 +901,7 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
        placements.flags = (bo->mem.placement & ~TTM_PL_MASK_MEM) |
                TTM_PL_FLAG_TT;
 
-       r = ttm_bo_mem_space(bo, &placement, &tmp, false, false);
+       r = ttm_bo_mem_space(bo, &placement, &tmp, &ctx);
        if (unlikely(r))
                return r;
 
index 1cf3da3d7bea0017060454bc6a6ea5c5af7f1097..dae90cb748a41d76919daa1443c472e008d310f3 100644 (file)
@@ -1199,6 +1199,7 @@ static int
 nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
                      bool no_wait_gpu, struct ttm_mem_reg *new_reg)
 {
+       struct ttm_operation_ctx ctx = { intr, no_wait_gpu };
        struct ttm_place placement_memtype = {
                .fpfn = 0,
                .lpfn = 0,
@@ -1213,7 +1214,7 @@ 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, intr, no_wait_gpu);
+       ret = ttm_bo_mem_space(bo, &placement, &tmp_reg, &ctx);
        if (ret)
                return ret;
 
@@ -1235,6 +1236,7 @@ static int
 nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,
                      bool no_wait_gpu, struct ttm_mem_reg *new_reg)
 {
+       struct ttm_operation_ctx ctx = { intr, no_wait_gpu };
        struct ttm_place placement_memtype = {
                .fpfn = 0,
                .lpfn = 0,
@@ -1249,7 +1251,7 @@ 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, intr, no_wait_gpu);
+       ret = ttm_bo_mem_space(bo, &placement, &tmp_reg, &ctx);
        if (ret)
                return ret;
 
index 6ada64db00e9c5b8208f6f83e1e35d80e429b253..ef7cb83331b3854ee35d6021d57e7e7c19a33c47 100644 (file)
@@ -311,6 +311,7 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo,
                                bool no_wait_gpu,
                                struct ttm_mem_reg *new_mem)
 {
+       struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };
        struct radeon_device *rdev;
        struct ttm_mem_reg *old_mem = &bo->mem;
        struct ttm_mem_reg tmp_mem;
@@ -328,8 +329,7 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo,
        placements.fpfn = 0;
        placements.lpfn = 0;
        placements.flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT;
-       r = ttm_bo_mem_space(bo, &placement, &tmp_mem,
-                            interruptible, no_wait_gpu);
+       r = ttm_bo_mem_space(bo, &placement, &tmp_mem, &ctx);
        if (unlikely(r)) {
                return r;
        }
@@ -358,6 +358,7 @@ static int radeon_move_ram_vram(struct ttm_buffer_object *bo,
                                bool no_wait_gpu,
                                struct ttm_mem_reg *new_mem)
 {
+       struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };
        struct radeon_device *rdev;
        struct ttm_mem_reg *old_mem = &bo->mem;
        struct ttm_mem_reg tmp_mem;
@@ -375,8 +376,7 @@ static int radeon_move_ram_vram(struct ttm_buffer_object *bo,
        placements.fpfn = 0;
        placements.lpfn = 0;
        placements.flags = TTM_PL_MASK_CACHING | TTM_PL_FLAG_TT;
-       r = ttm_bo_mem_space(bo, &placement, &tmp_mem,
-                            interruptible, no_wait_gpu);
+       r = ttm_bo_mem_space(bo, &placement, &tmp_mem, &ctx);
        if (unlikely(r)) {
                return r;
        }
index 1f6957adc19e7db170bc22f8d789e5b300cb98c3..63c1a97b35895d4f3dc8dac41390d50e003a4541 100644 (file)
@@ -656,6 +656,7 @@ EXPORT_SYMBOL(ttm_bo_unlock_delayed_workqueue);
 static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
                        bool no_wait_gpu)
 {
+       struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };
        struct ttm_bo_device *bdev = bo->bdev;
        struct ttm_mem_reg evict_mem;
        struct ttm_placement placement;
@@ -671,8 +672,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
        placement.num_placement = 0;
        placement.num_busy_placement = 0;
        bdev->driver->evict_flags(bo, &placement);
-       ret = ttm_bo_mem_space(bo, &placement, &evict_mem, interruptible,
-                               no_wait_gpu);
+       ret = ttm_bo_mem_space(bo, &placement, &evict_mem, &ctx);
        if (ret) {
                if (ret != -ERESTARTSYS) {
                        pr_err("Failed to find memory space for buffer 0x%p eviction\n",
@@ -682,8 +682,8 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
                goto out;
        }
 
-       ret = ttm_bo_handle_move_mem(bo, &evict_mem, true, interruptible,
-                                    no_wait_gpu);
+       ret = ttm_bo_handle_move_mem(bo, &evict_mem, true,
+                                    interruptible, no_wait_gpu);
        if (unlikely(ret)) {
                if (ret != -ERESTARTSYS)
                        pr_err("Buffer eviction failed\n");
@@ -903,8 +903,7 @@ static bool ttm_bo_mt_compatible(struct ttm_mem_type_manager *man,
 int ttm_bo_mem_space(struct ttm_buffer_object *bo,
                        struct ttm_placement *placement,
                        struct ttm_mem_reg *mem,
-                       bool interruptible,
-                       bool no_wait_gpu)
+                       struct ttm_operation_ctx *ctx)
 {
        struct ttm_bo_device *bdev = bo->bdev;
        struct ttm_mem_type_manager *man;
@@ -999,7 +998,8 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
                }
 
                ret = ttm_bo_mem_force_space(bo, mem_type, place, mem,
-                                               interruptible, no_wait_gpu);
+                                               ctx->interruptible,
+                                               ctx->no_wait_gpu);
                if (ret == 0 && mem->mm_node) {
                        mem->placement = cur_flags;
                        return 0;
@@ -1022,6 +1022,7 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
                        bool interruptible,
                        bool no_wait_gpu)
 {
+       struct ttm_operation_ctx ctx = { interruptible, no_wait_gpu };
        int ret = 0;
        struct ttm_mem_reg mem;
 
@@ -1035,12 +1036,11 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
        /*
         * Determine where to move the buffer.
         */
-       ret = ttm_bo_mem_space(bo, placement, &mem,
-                              interruptible, no_wait_gpu);
+       ret = ttm_bo_mem_space(bo, placement, &mem, &ctx);
        if (ret)
                goto out_unlock;
-       ret = ttm_bo_handle_move_mem(bo, &mem, false,
-                                    interruptible, no_wait_gpu);
+       ret = ttm_bo_handle_move_mem(bo, &mem, false, interruptible,
+                                    no_wait_gpu);
 out_unlock:
        if (ret && mem.mm_node)
                ttm_bo_mem_put(bo, &mem);
index a7c826a1e53f7ba19a7f76ffccf1633472967b1e..494322a5f239f36cec385fb51831cf21e9427dea 100644 (file)
@@ -743,8 +743,7 @@ bool ttm_mem_reg_is_pci(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem);
 int ttm_bo_mem_space(struct ttm_buffer_object *bo,
                     struct ttm_placement *placement,
                     struct ttm_mem_reg *mem,
-                    bool interruptible,
-                    bool no_wait_gpu);
+                    struct ttm_operation_ctx *ctx);
 
 void ttm_bo_mem_put(struct ttm_buffer_object *bo, struct ttm_mem_reg *mem);
 void ttm_bo_mem_put_locked(struct ttm_buffer_object *bo,