aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau
diff options
context:
space:
mode:
authorMaarten Lankhorst <m.b.lankhorst@gmail.com>2012-11-28 06:25:44 -0500
committerDave Airlie <airlied@redhat.com>2012-12-10 05:21:30 -0500
commit97a875cbdf89a4638eea57c2b456c7cc4e3e8b21 (patch)
tree286ff23a3f8e389ec4fa1a6f3b58cbee4fc8e9fe /drivers/gpu/drm/nouveau
parente7ab20197be3ee5fd75441e1cff0c7cdfea5bf1a (diff)
drm/ttm: remove no_wait_reserve, v3
All items on the lru list are always reservable, so this is a stupid thing to keep. Not only that, it is used in a way which would guarantee deadlocks if it were ever to be set to block on reserve. This is a lot of churn, but mostly because of the removal of the argument which can be nested arbitrarily deeply in many places. No change of code in this patch except removal of the no_wait_reserve argument, the previous patch removed the use of no_wait_reserve. v2: - Warn if -EBUSY is returned on reservation, all objects on the list should be reservable. Adjusted patch slightly due to conflicts. v3: - Focus on no_wait_reserve removal only. Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com> Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c55
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.h2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_gem.c2
3 files changed, 28 insertions, 31 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 4c950b4cf416..5614c89148cb 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -315,7 +315,7 @@ nouveau_bo_pin(struct nouveau_bo *nvbo, uint32_t memtype)
315 315
316 nouveau_bo_placement_set(nvbo, memtype, 0); 316 nouveau_bo_placement_set(nvbo, memtype, 0);
317 317
318 ret = nouveau_bo_validate(nvbo, false, false, false); 318 ret = nouveau_bo_validate(nvbo, false, false);
319 if (ret == 0) { 319 if (ret == 0) {
320 switch (bo->mem.mem_type) { 320 switch (bo->mem.mem_type) {
321 case TTM_PL_VRAM: 321 case TTM_PL_VRAM:
@@ -351,7 +351,7 @@ nouveau_bo_unpin(struct nouveau_bo *nvbo)
351 351
352 nouveau_bo_placement_set(nvbo, bo->mem.placement, 0); 352 nouveau_bo_placement_set(nvbo, bo->mem.placement, 0);
353 353
354 ret = nouveau_bo_validate(nvbo, false, false, false); 354 ret = nouveau_bo_validate(nvbo, false, false);
355 if (ret == 0) { 355 if (ret == 0) {
356 switch (bo->mem.mem_type) { 356 switch (bo->mem.mem_type) {
357 case TTM_PL_VRAM: 357 case TTM_PL_VRAM:
@@ -392,12 +392,12 @@ nouveau_bo_unmap(struct nouveau_bo *nvbo)
392 392
393int 393int
394nouveau_bo_validate(struct nouveau_bo *nvbo, bool interruptible, 394nouveau_bo_validate(struct nouveau_bo *nvbo, bool interruptible,
395 bool no_wait_reserve, bool no_wait_gpu) 395 bool no_wait_gpu)
396{ 396{
397 int ret; 397 int ret;
398 398
399 ret = ttm_bo_validate(&nvbo->bo, &nvbo->placement, interruptible, 399 ret = ttm_bo_validate(&nvbo->bo, &nvbo->placement,
400 no_wait_reserve, no_wait_gpu); 400 interruptible, no_wait_gpu);
401 if (ret) 401 if (ret)
402 return ret; 402 return ret;
403 403
@@ -556,8 +556,7 @@ nouveau_bo_evict_flags(struct ttm_buffer_object *bo, struct ttm_placement *pl)
556static int 556static int
557nouveau_bo_move_accel_cleanup(struct nouveau_channel *chan, 557nouveau_bo_move_accel_cleanup(struct nouveau_channel *chan,
558 struct nouveau_bo *nvbo, bool evict, 558 struct nouveau_bo *nvbo, bool evict,
559 bool no_wait_reserve, bool no_wait_gpu, 559 bool no_wait_gpu, struct ttm_mem_reg *new_mem)
560 struct ttm_mem_reg *new_mem)
561{ 560{
562 struct nouveau_fence *fence = NULL; 561 struct nouveau_fence *fence = NULL;
563 int ret; 562 int ret;
@@ -567,7 +566,7 @@ nouveau_bo_move_accel_cleanup(struct nouveau_channel *chan,
567 return ret; 566 return ret;
568 567
569 ret = ttm_bo_move_accel_cleanup(&nvbo->bo, fence, evict, 568 ret = ttm_bo_move_accel_cleanup(&nvbo->bo, fence, evict,
570 no_wait_reserve, no_wait_gpu, new_mem); 569 no_wait_gpu, new_mem);
571 nouveau_fence_unref(&fence); 570 nouveau_fence_unref(&fence);
572 return ret; 571 return ret;
573} 572}
@@ -965,8 +964,7 @@ nouveau_vma_getmap(struct nouveau_channel *chan, struct nouveau_bo *nvbo,
965 964
966static int 965static int
967nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr, 966nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
968 bool no_wait_reserve, bool no_wait_gpu, 967 bool no_wait_gpu, struct ttm_mem_reg *new_mem)
969 struct ttm_mem_reg *new_mem)
970{ 968{
971 struct nouveau_drm *drm = nouveau_bdev(bo->bdev); 969 struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
972 struct nouveau_channel *chan = chan = drm->channel; 970 struct nouveau_channel *chan = chan = drm->channel;
@@ -995,7 +993,6 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
995 ret = drm->ttm.move(chan, bo, &bo->mem, new_mem); 993 ret = drm->ttm.move(chan, bo, &bo->mem, new_mem);
996 if (ret == 0) { 994 if (ret == 0) {
997 ret = nouveau_bo_move_accel_cleanup(chan, nvbo, evict, 995 ret = nouveau_bo_move_accel_cleanup(chan, nvbo, evict,
998 no_wait_reserve,
999 no_wait_gpu, new_mem); 996 no_wait_gpu, new_mem);
1000 } 997 }
1001 998
@@ -1064,8 +1061,7 @@ nouveau_bo_move_init(struct nouveau_drm *drm)
1064 1061
1065static int 1062static int
1066nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr, 1063nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
1067 bool no_wait_reserve, bool no_wait_gpu, 1064 bool no_wait_gpu, struct ttm_mem_reg *new_mem)
1068 struct ttm_mem_reg *new_mem)
1069{ 1065{
1070 u32 placement_memtype = TTM_PL_FLAG_TT | TTM_PL_MASK_CACHING; 1066 u32 placement_memtype = TTM_PL_FLAG_TT | TTM_PL_MASK_CACHING;
1071 struct ttm_placement placement; 1067 struct ttm_placement placement;
@@ -1078,7 +1074,7 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
1078 1074
1079 tmp_mem = *new_mem; 1075 tmp_mem = *new_mem;
1080 tmp_mem.mm_node = NULL; 1076 tmp_mem.mm_node = NULL;
1081 ret = ttm_bo_mem_space(bo, &placement, &tmp_mem, intr, no_wait_reserve, no_wait_gpu); 1077 ret = ttm_bo_mem_space(bo, &placement, &tmp_mem, intr, no_wait_gpu);
1082 if (ret) 1078 if (ret)
1083 return ret; 1079 return ret;
1084 1080
@@ -1086,11 +1082,11 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
1086 if (ret) 1082 if (ret)
1087 goto out; 1083 goto out;
1088 1084
1089 ret = nouveau_bo_move_m2mf(bo, true, intr, no_wait_reserve, no_wait_gpu, &tmp_mem); 1085 ret = nouveau_bo_move_m2mf(bo, true, intr, no_wait_gpu, &tmp_mem);
1090 if (ret) 1086 if (ret)
1091 goto out; 1087 goto out;
1092 1088
1093 ret = ttm_bo_move_ttm(bo, true, no_wait_reserve, no_wait_gpu, new_mem); 1089 ret = ttm_bo_move_ttm(bo, true, no_wait_gpu, new_mem);
1094out: 1090out:
1095 ttm_bo_mem_put(bo, &tmp_mem); 1091 ttm_bo_mem_put(bo, &tmp_mem);
1096 return ret; 1092 return ret;
@@ -1098,8 +1094,7 @@ out:
1098 1094
1099static int 1095static int
1100nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr, 1096nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,
1101 bool no_wait_reserve, bool no_wait_gpu, 1097 bool no_wait_gpu, struct ttm_mem_reg *new_mem)
1102 struct ttm_mem_reg *new_mem)
1103{ 1098{
1104 u32 placement_memtype = TTM_PL_FLAG_TT | TTM_PL_MASK_CACHING; 1099 u32 placement_memtype = TTM_PL_FLAG_TT | TTM_PL_MASK_CACHING;
1105 struct ttm_placement placement; 1100 struct ttm_placement placement;
@@ -1112,15 +1107,15 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,
1112 1107
1113 tmp_mem = *new_mem; 1108 tmp_mem = *new_mem;
1114 tmp_mem.mm_node = NULL; 1109 tmp_mem.mm_node = NULL;
1115 ret = ttm_bo_mem_space(bo, &placement, &tmp_mem, intr, no_wait_reserve, no_wait_gpu); 1110 ret = ttm_bo_mem_space(bo, &placement, &tmp_mem, intr, no_wait_gpu);
1116 if (ret) 1111 if (ret)
1117 return ret; 1112 return ret;
1118 1113
1119 ret = ttm_bo_move_ttm(bo, true, no_wait_reserve, no_wait_gpu, &tmp_mem); 1114 ret = ttm_bo_move_ttm(bo, true, no_wait_gpu, &tmp_mem);
1120 if (ret) 1115 if (ret)
1121 goto out; 1116 goto out;
1122 1117
1123 ret = nouveau_bo_move_m2mf(bo, true, intr, no_wait_reserve, no_wait_gpu, new_mem); 1118 ret = nouveau_bo_move_m2mf(bo, true, intr, no_wait_gpu, new_mem);
1124 if (ret) 1119 if (ret)
1125 goto out; 1120 goto out;
1126 1121
@@ -1195,8 +1190,7 @@ nouveau_bo_vm_cleanup(struct ttm_buffer_object *bo,
1195 1190
1196static int 1191static int
1197nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr, 1192nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr,
1198 bool no_wait_reserve, bool no_wait_gpu, 1193 bool no_wait_gpu, struct ttm_mem_reg *new_mem)
1199 struct ttm_mem_reg *new_mem)
1200{ 1194{
1201 struct nouveau_drm *drm = nouveau_bdev(bo->bdev); 1195 struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
1202 struct nouveau_bo *nvbo = nouveau_bo(bo); 1196 struct nouveau_bo *nvbo = nouveau_bo(bo);
@@ -1220,23 +1214,26 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr,
1220 1214
1221 /* CPU copy if we have no accelerated method available */ 1215 /* CPU copy if we have no accelerated method available */
1222 if (!drm->ttm.move) { 1216 if (!drm->ttm.move) {
1223 ret = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, no_wait_gpu, new_mem); 1217 ret = ttm_bo_move_memcpy(bo, evict, no_wait_gpu, new_mem);
1224 goto out; 1218 goto out;
1225 } 1219 }
1226 1220
1227 /* Hardware assisted copy. */ 1221 /* Hardware assisted copy. */
1228 if (new_mem->mem_type == TTM_PL_SYSTEM) 1222 if (new_mem->mem_type == TTM_PL_SYSTEM)
1229 ret = nouveau_bo_move_flipd(bo, evict, intr, no_wait_reserve, no_wait_gpu, new_mem); 1223 ret = nouveau_bo_move_flipd(bo, evict, intr,
1224 no_wait_gpu, new_mem);
1230 else if (old_mem->mem_type == TTM_PL_SYSTEM) 1225 else if (old_mem->mem_type == TTM_PL_SYSTEM)
1231 ret = nouveau_bo_move_flips(bo, evict, intr, no_wait_reserve, no_wait_gpu, new_mem); 1226 ret = nouveau_bo_move_flips(bo, evict, intr,
1227 no_wait_gpu, new_mem);
1232 else 1228 else
1233 ret = nouveau_bo_move_m2mf(bo, evict, intr, no_wait_reserve, no_wait_gpu, new_mem); 1229 ret = nouveau_bo_move_m2mf(bo, evict, intr,
1230 no_wait_gpu, new_mem);
1234 1231
1235 if (!ret) 1232 if (!ret)
1236 goto out; 1233 goto out;
1237 1234
1238 /* Fallback to software copy. */ 1235 /* Fallback to software copy. */
1239 ret = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, no_wait_gpu, new_mem); 1236 ret = ttm_bo_move_memcpy(bo, evict, no_wait_gpu, new_mem);
1240 1237
1241out: 1238out:
1242 if (nv_device(drm->device)->card_type < NV_50) { 1239 if (nv_device(drm->device)->card_type < NV_50) {
@@ -1343,7 +1340,7 @@ nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
1343 nvbo->placement.fpfn = 0; 1340 nvbo->placement.fpfn = 0;
1344 nvbo->placement.lpfn = mappable; 1341 nvbo->placement.lpfn = mappable;
1345 nouveau_bo_placement_set(nvbo, TTM_PL_FLAG_VRAM, 0); 1342 nouveau_bo_placement_set(nvbo, TTM_PL_FLAG_VRAM, 0);
1346 return nouveau_bo_validate(nvbo, false, true, false); 1343 return nouveau_bo_validate(nvbo, false, false);
1347} 1344}
1348 1345
1349static int 1346static int
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.h b/drivers/gpu/drm/nouveau/nouveau_bo.h
index dec51b1098fe..25ca37989d2c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.h
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.h
@@ -76,7 +76,7 @@ u32 nouveau_bo_rd32(struct nouveau_bo *, unsigned index);
76void nouveau_bo_wr32(struct nouveau_bo *, unsigned index, u32 val); 76void nouveau_bo_wr32(struct nouveau_bo *, unsigned index, u32 val);
77void nouveau_bo_fence(struct nouveau_bo *, struct nouveau_fence *); 77void nouveau_bo_fence(struct nouveau_bo *, struct nouveau_fence *);
78int nouveau_bo_validate(struct nouveau_bo *, bool interruptible, 78int nouveau_bo_validate(struct nouveau_bo *, bool interruptible,
79 bool no_wait_reserve, bool no_wait_gpu); 79 bool no_wait_gpu);
80 80
81struct nouveau_vma * 81struct nouveau_vma *
82nouveau_bo_vma_find(struct nouveau_bo *, struct nouveau_vm *); 82nouveau_bo_vma_find(struct nouveau_bo *, struct nouveau_vm *);
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 5e2f52158f19..8bf695c52f95 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -433,7 +433,7 @@ validate_list(struct nouveau_channel *chan, struct list_head *list,
433 return ret; 433 return ret;
434 } 434 }
435 435
436 ret = nouveau_bo_validate(nvbo, true, false, false); 436 ret = nouveau_bo_validate(nvbo, true, false);
437 if (unlikely(ret)) { 437 if (unlikely(ret)) {
438 if (ret != -ERESTARTSYS) 438 if (ret != -ERESTARTSYS)
439 NV_ERROR(drm, "fail ttm_validate\n"); 439 NV_ERROR(drm, "fail ttm_validate\n");