aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ttm/ttm_bo.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/ttm/ttm_bo.c')
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c46
1 files changed, 24 insertions, 22 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 6059771d506e..a9151337d5b9 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -366,7 +366,7 @@ static int ttm_bo_add_ttm(struct ttm_buffer_object *bo, bool zero_alloc)
366static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, 366static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
367 struct ttm_mem_reg *mem, 367 struct ttm_mem_reg *mem,
368 bool evict, bool interruptible, 368 bool evict, bool interruptible,
369 bool no_wait_reserve, bool no_wait_gpu) 369 bool no_wait_gpu)
370{ 370{
371 struct ttm_bo_device *bdev = bo->bdev; 371 struct ttm_bo_device *bdev = bo->bdev;
372 bool old_is_pci = ttm_mem_reg_is_pci(bdev, &bo->mem); 372 bool old_is_pci = ttm_mem_reg_is_pci(bdev, &bo->mem);
@@ -420,12 +420,12 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
420 420
421 if (!(old_man->flags & TTM_MEMTYPE_FLAG_FIXED) && 421 if (!(old_man->flags & TTM_MEMTYPE_FLAG_FIXED) &&
422 !(new_man->flags & TTM_MEMTYPE_FLAG_FIXED)) 422 !(new_man->flags & TTM_MEMTYPE_FLAG_FIXED))
423 ret = ttm_bo_move_ttm(bo, evict, no_wait_reserve, no_wait_gpu, mem); 423 ret = ttm_bo_move_ttm(bo, evict, no_wait_gpu, mem);
424 else if (bdev->driver->move) 424 else if (bdev->driver->move)
425 ret = bdev->driver->move(bo, evict, interruptible, 425 ret = bdev->driver->move(bo, evict, interruptible,
426 no_wait_reserve, no_wait_gpu, mem); 426 no_wait_gpu, mem);
427 else 427 else
428 ret = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, no_wait_gpu, mem); 428 ret = ttm_bo_move_memcpy(bo, evict, no_wait_gpu, mem);
429 429
430 if (ret) { 430 if (ret) {
431 if (bdev->driver->move_notify) { 431 if (bdev->driver->move_notify) {
@@ -749,7 +749,7 @@ void ttm_bo_unlock_delayed_workqueue(struct ttm_bo_device *bdev, int resched)
749EXPORT_SYMBOL(ttm_bo_unlock_delayed_workqueue); 749EXPORT_SYMBOL(ttm_bo_unlock_delayed_workqueue);
750 750
751static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible, 751static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
752 bool no_wait_reserve, bool no_wait_gpu) 752 bool no_wait_gpu)
753{ 753{
754 struct ttm_bo_device *bdev = bo->bdev; 754 struct ttm_bo_device *bdev = bo->bdev;
755 struct ttm_mem_reg evict_mem; 755 struct ttm_mem_reg evict_mem;
@@ -780,7 +780,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
780 placement.num_busy_placement = 0; 780 placement.num_busy_placement = 0;
781 bdev->driver->evict_flags(bo, &placement); 781 bdev->driver->evict_flags(bo, &placement);
782 ret = ttm_bo_mem_space(bo, &placement, &evict_mem, interruptible, 782 ret = ttm_bo_mem_space(bo, &placement, &evict_mem, interruptible,
783 no_wait_reserve, no_wait_gpu); 783 no_wait_gpu);
784 if (ret) { 784 if (ret) {
785 if (ret != -ERESTARTSYS) { 785 if (ret != -ERESTARTSYS) {
786 pr_err("Failed to find memory space for buffer 0x%p eviction\n", 786 pr_err("Failed to find memory space for buffer 0x%p eviction\n",
@@ -791,7 +791,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
791 } 791 }
792 792
793 ret = ttm_bo_handle_move_mem(bo, &evict_mem, true, interruptible, 793 ret = ttm_bo_handle_move_mem(bo, &evict_mem, true, interruptible,
794 no_wait_reserve, no_wait_gpu); 794 no_wait_gpu);
795 if (ret) { 795 if (ret) {
796 if (ret != -ERESTARTSYS) 796 if (ret != -ERESTARTSYS)
797 pr_err("Buffer eviction failed\n"); 797 pr_err("Buffer eviction failed\n");
@@ -805,7 +805,7 @@ out:
805 805
806static int ttm_mem_evict_first(struct ttm_bo_device *bdev, 806static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
807 uint32_t mem_type, 807 uint32_t mem_type,
808 bool interruptible, bool no_wait_reserve, 808 bool interruptible,
809 bool no_wait_gpu) 809 bool no_wait_gpu)
810{ 810{
811 struct ttm_bo_global *glob = bdev->glob; 811 struct ttm_bo_global *glob = bdev->glob;
@@ -841,7 +841,7 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
841 841
842 ttm_bo_list_ref_sub(bo, put_count, true); 842 ttm_bo_list_ref_sub(bo, put_count, true);
843 843
844 ret = ttm_bo_evict(bo, interruptible, no_wait_reserve, no_wait_gpu); 844 ret = ttm_bo_evict(bo, interruptible, no_wait_gpu);
845 ttm_bo_unreserve(bo); 845 ttm_bo_unreserve(bo);
846 846
847 kref_put(&bo->list_kref, ttm_bo_release_list); 847 kref_put(&bo->list_kref, ttm_bo_release_list);
@@ -866,7 +866,6 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
866 struct ttm_placement *placement, 866 struct ttm_placement *placement,
867 struct ttm_mem_reg *mem, 867 struct ttm_mem_reg *mem,
868 bool interruptible, 868 bool interruptible,
869 bool no_wait_reserve,
870 bool no_wait_gpu) 869 bool no_wait_gpu)
871{ 870{
872 struct ttm_bo_device *bdev = bo->bdev; 871 struct ttm_bo_device *bdev = bo->bdev;
@@ -879,8 +878,8 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,
879 return ret; 878 return ret;
880 if (mem->mm_node) 879 if (mem->mm_node)
881 break; 880 break;
882 ret = ttm_mem_evict_first(bdev, mem_type, interruptible, 881 ret = ttm_mem_evict_first(bdev, mem_type,
883 no_wait_reserve, no_wait_gpu); 882 interruptible, no_wait_gpu);
884 if (unlikely(ret != 0)) 883 if (unlikely(ret != 0))
885 return ret; 884 return ret;
886 } while (1); 885 } while (1);
@@ -945,7 +944,7 @@ static bool ttm_bo_mt_compatible(struct ttm_mem_type_manager *man,
945int ttm_bo_mem_space(struct ttm_buffer_object *bo, 944int ttm_bo_mem_space(struct ttm_buffer_object *bo,
946 struct ttm_placement *placement, 945 struct ttm_placement *placement,
947 struct ttm_mem_reg *mem, 946 struct ttm_mem_reg *mem,
948 bool interruptible, bool no_wait_reserve, 947 bool interruptible,
949 bool no_wait_gpu) 948 bool no_wait_gpu)
950{ 949{
951 struct ttm_bo_device *bdev = bo->bdev; 950 struct ttm_bo_device *bdev = bo->bdev;
@@ -1036,7 +1035,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,
1036 } 1035 }
1037 1036
1038 ret = ttm_bo_mem_force_space(bo, mem_type, placement, mem, 1037 ret = ttm_bo_mem_force_space(bo, mem_type, placement, mem,
1039 interruptible, no_wait_reserve, no_wait_gpu); 1038 interruptible, no_wait_gpu);
1040 if (ret == 0 && mem->mm_node) { 1039 if (ret == 0 && mem->mm_node) {
1041 mem->placement = cur_flags; 1040 mem->placement = cur_flags;
1042 return 0; 1041 return 0;
@@ -1051,7 +1050,7 @@ EXPORT_SYMBOL(ttm_bo_mem_space);
1051 1050
1052int ttm_bo_move_buffer(struct ttm_buffer_object *bo, 1051int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
1053 struct ttm_placement *placement, 1052 struct ttm_placement *placement,
1054 bool interruptible, bool no_wait_reserve, 1053 bool interruptible,
1055 bool no_wait_gpu) 1054 bool no_wait_gpu)
1056{ 1055{
1057 int ret = 0; 1056 int ret = 0;
@@ -1078,10 +1077,12 @@ int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
1078 /* 1077 /*
1079 * Determine where to move the buffer. 1078 * Determine where to move the buffer.
1080 */ 1079 */
1081 ret = ttm_bo_mem_space(bo, placement, &mem, interruptible, no_wait_reserve, no_wait_gpu); 1080 ret = ttm_bo_mem_space(bo, placement, &mem,
1081 interruptible, no_wait_gpu);
1082 if (ret) 1082 if (ret)
1083 goto out_unlock; 1083 goto out_unlock;
1084 ret = ttm_bo_handle_move_mem(bo, &mem, false, interruptible, no_wait_reserve, no_wait_gpu); 1084 ret = ttm_bo_handle_move_mem(bo, &mem, false,
1085 interruptible, no_wait_gpu);
1085out_unlock: 1086out_unlock:
1086 if (ret && mem.mm_node) 1087 if (ret && mem.mm_node)
1087 ttm_bo_mem_put(bo, &mem); 1088 ttm_bo_mem_put(bo, &mem);
@@ -1110,7 +1111,7 @@ static int ttm_bo_mem_compat(struct ttm_placement *placement,
1110 1111
1111int ttm_bo_validate(struct ttm_buffer_object *bo, 1112int ttm_bo_validate(struct ttm_buffer_object *bo,
1112 struct ttm_placement *placement, 1113 struct ttm_placement *placement,
1113 bool interruptible, bool no_wait_reserve, 1114 bool interruptible,
1114 bool no_wait_gpu) 1115 bool no_wait_gpu)
1115{ 1116{
1116 int ret; 1117 int ret;
@@ -1126,7 +1127,8 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
1126 */ 1127 */
1127 ret = ttm_bo_mem_compat(placement, &bo->mem); 1128 ret = ttm_bo_mem_compat(placement, &bo->mem);
1128 if (ret < 0) { 1129 if (ret < 0) {
1129 ret = ttm_bo_move_buffer(bo, placement, interruptible, no_wait_reserve, no_wait_gpu); 1130 ret = ttm_bo_move_buffer(bo, placement, interruptible,
1131 no_wait_gpu);
1130 if (ret) 1132 if (ret)
1131 return ret; 1133 return ret;
1132 } else { 1134 } else {
@@ -1239,7 +1241,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev,
1239 goto out_err; 1241 goto out_err;
1240 } 1242 }
1241 1243
1242 ret = ttm_bo_validate(bo, placement, interruptible, false, false); 1244 ret = ttm_bo_validate(bo, placement, interruptible, false);
1243 if (ret) 1245 if (ret)
1244 goto out_err; 1246 goto out_err;
1245 1247
@@ -1325,7 +1327,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
1325 spin_lock(&glob->lru_lock); 1327 spin_lock(&glob->lru_lock);
1326 while (!list_empty(&man->lru)) { 1328 while (!list_empty(&man->lru)) {
1327 spin_unlock(&glob->lru_lock); 1329 spin_unlock(&glob->lru_lock);
1328 ret = ttm_mem_evict_first(bdev, mem_type, false, false, false); 1330 ret = ttm_mem_evict_first(bdev, mem_type, false, false);
1329 if (ret) { 1331 if (ret) {
1330 if (allow_errors) { 1332 if (allow_errors) {
1331 return ret; 1333 return ret;
@@ -1837,7 +1839,7 @@ static int ttm_bo_swapout(struct ttm_mem_shrink *shrink)
1837 evict_mem.mem_type = TTM_PL_SYSTEM; 1839 evict_mem.mem_type = TTM_PL_SYSTEM;
1838 1840
1839 ret = ttm_bo_handle_move_mem(bo, &evict_mem, true, 1841 ret = ttm_bo_handle_move_mem(bo, &evict_mem, true,
1840 false, false, false); 1842 false, false);
1841 if (unlikely(ret != 0)) 1843 if (unlikely(ret != 0))
1842 goto out; 1844 goto out;
1843 } 1845 }