Skip to content

Commit 97a875c

Browse files
mlankhorstairlied
authored andcommitted
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>
1 parent e7ab201 commit 97a875c

File tree

15 files changed

+107
-114
lines changed

15 files changed

+107
-114
lines changed

drivers/gpu/drm/ast/ast_ttm.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,11 @@ static void ast_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_mem_reg *
186186

187187
static int ast_bo_move(struct ttm_buffer_object *bo,
188188
bool evict, bool interruptible,
189-
bool no_wait_reserve, bool no_wait_gpu,
189+
bool no_wait_gpu,
190190
struct ttm_mem_reg *new_mem)
191191
{
192192
int r;
193-
r = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, no_wait_gpu, new_mem);
193+
r = ttm_bo_move_memcpy(bo, evict, no_wait_gpu, new_mem);
194194
return r;
195195
}
196196

@@ -383,7 +383,7 @@ int ast_bo_pin(struct ast_bo *bo, u32 pl_flag, u64 *gpu_addr)
383383
ast_ttm_placement(bo, pl_flag);
384384
for (i = 0; i < bo->placement.num_placement; i++)
385385
bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
386-
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false, false);
386+
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
387387
if (ret)
388388
return ret;
389389

@@ -406,7 +406,7 @@ int ast_bo_unpin(struct ast_bo *bo)
406406

407407
for (i = 0; i < bo->placement.num_placement ; i++)
408408
bo->placements[i] &= ~TTM_PL_FLAG_NO_EVICT;
409-
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false, false);
409+
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
410410
if (ret)
411411
return ret;
412412

@@ -431,7 +431,7 @@ int ast_bo_push_sysram(struct ast_bo *bo)
431431
for (i = 0; i < bo->placement.num_placement ; i++)
432432
bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
433433

434-
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false, false);
434+
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
435435
if (ret) {
436436
DRM_ERROR("pushing to VRAM failed\n");
437437
return ret;

drivers/gpu/drm/cirrus/cirrus_ttm.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,11 @@ static void cirrus_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_mem_re
186186

187187
static int cirrus_bo_move(struct ttm_buffer_object *bo,
188188
bool evict, bool interruptible,
189-
bool no_wait_reserve, bool no_wait_gpu,
189+
bool no_wait_gpu,
190190
struct ttm_mem_reg *new_mem)
191191
{
192192
int r;
193-
r = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, no_wait_gpu, new_mem);
193+
r = ttm_bo_move_memcpy(bo, evict, no_wait_gpu, new_mem);
194194
return r;
195195
}
196196

@@ -388,7 +388,7 @@ int cirrus_bo_pin(struct cirrus_bo *bo, u32 pl_flag, u64 *gpu_addr)
388388
cirrus_ttm_placement(bo, pl_flag);
389389
for (i = 0; i < bo->placement.num_placement; i++)
390390
bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
391-
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false, false);
391+
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
392392
if (ret)
393393
return ret;
394394

@@ -411,7 +411,7 @@ int cirrus_bo_unpin(struct cirrus_bo *bo)
411411

412412
for (i = 0; i < bo->placement.num_placement ; i++)
413413
bo->placements[i] &= ~TTM_PL_FLAG_NO_EVICT;
414-
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false, false);
414+
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
415415
if (ret)
416416
return ret;
417417

@@ -436,7 +436,7 @@ int cirrus_bo_push_sysram(struct cirrus_bo *bo)
436436
for (i = 0; i < bo->placement.num_placement ; i++)
437437
bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
438438

439-
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false, false);
439+
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
440440
if (ret) {
441441
DRM_ERROR("pushing to VRAM failed\n");
442442
return ret;

drivers/gpu/drm/mgag200/mgag200_ttm.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,11 @@ static void mgag200_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_mem_r
186186

187187
static int mgag200_bo_move(struct ttm_buffer_object *bo,
188188
bool evict, bool interruptible,
189-
bool no_wait_reserve, bool no_wait_gpu,
189+
bool no_wait_gpu,
190190
struct ttm_mem_reg *new_mem)
191191
{
192192
int r;
193-
r = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, no_wait_gpu, new_mem);
193+
r = ttm_bo_move_memcpy(bo, evict, no_wait_gpu, new_mem);
194194
return r;
195195
}
196196

@@ -382,7 +382,7 @@ int mgag200_bo_pin(struct mgag200_bo *bo, u32 pl_flag, u64 *gpu_addr)
382382
mgag200_ttm_placement(bo, pl_flag);
383383
for (i = 0; i < bo->placement.num_placement; i++)
384384
bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
385-
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false, false);
385+
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
386386
if (ret)
387387
return ret;
388388

@@ -405,7 +405,7 @@ int mgag200_bo_unpin(struct mgag200_bo *bo)
405405

406406
for (i = 0; i < bo->placement.num_placement ; i++)
407407
bo->placements[i] &= ~TTM_PL_FLAG_NO_EVICT;
408-
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false, false);
408+
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
409409
if (ret)
410410
return ret;
411411

@@ -430,7 +430,7 @@ int mgag200_bo_push_sysram(struct mgag200_bo *bo)
430430
for (i = 0; i < bo->placement.num_placement ; i++)
431431
bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
432432

433-
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false, false);
433+
ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
434434
if (ret) {
435435
DRM_ERROR("pushing to VRAM failed\n");
436436
return ret;

drivers/gpu/drm/nouveau/nouveau_bo.c

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ nouveau_bo_pin(struct nouveau_bo *nvbo, uint32_t memtype)
315315

316316
nouveau_bo_placement_set(nvbo, memtype, 0);
317317

318-
ret = nouveau_bo_validate(nvbo, false, false, false);
318+
ret = nouveau_bo_validate(nvbo, false, false);
319319
if (ret == 0) {
320320
switch (bo->mem.mem_type) {
321321
case TTM_PL_VRAM:
@@ -351,7 +351,7 @@ nouveau_bo_unpin(struct nouveau_bo *nvbo)
351351

352352
nouveau_bo_placement_set(nvbo, bo->mem.placement, 0);
353353

354-
ret = nouveau_bo_validate(nvbo, false, false, false);
354+
ret = nouveau_bo_validate(nvbo, false, false);
355355
if (ret == 0) {
356356
switch (bo->mem.mem_type) {
357357
case TTM_PL_VRAM:
@@ -392,12 +392,12 @@ nouveau_bo_unmap(struct nouveau_bo *nvbo)
392392

393393
int
394394
nouveau_bo_validate(struct nouveau_bo *nvbo, bool interruptible,
395-
bool no_wait_reserve, bool no_wait_gpu)
395+
bool no_wait_gpu)
396396
{
397397
int ret;
398398

399-
ret = ttm_bo_validate(&nvbo->bo, &nvbo->placement, interruptible,
400-
no_wait_reserve, no_wait_gpu);
399+
ret = ttm_bo_validate(&nvbo->bo, &nvbo->placement,
400+
interruptible, no_wait_gpu);
401401
if (ret)
402402
return ret;
403403

@@ -556,8 +556,7 @@ nouveau_bo_evict_flags(struct ttm_buffer_object *bo, struct ttm_placement *pl)
556556
static int
557557
nouveau_bo_move_accel_cleanup(struct nouveau_channel *chan,
558558
struct nouveau_bo *nvbo, bool evict,
559-
bool no_wait_reserve, bool no_wait_gpu,
560-
struct ttm_mem_reg *new_mem)
559+
bool no_wait_gpu, struct ttm_mem_reg *new_mem)
561560
{
562561
struct nouveau_fence *fence = NULL;
563562
int ret;
@@ -567,7 +566,7 @@ nouveau_bo_move_accel_cleanup(struct nouveau_channel *chan,
567566
return ret;
568567

569568
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);
571570
nouveau_fence_unref(&fence);
572571
return ret;
573572
}
@@ -965,8 +964,7 @@ nouveau_vma_getmap(struct nouveau_channel *chan, struct nouveau_bo *nvbo,
965964

966965
static int
967966
nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
968-
bool no_wait_reserve, bool no_wait_gpu,
969-
struct ttm_mem_reg *new_mem)
967+
bool no_wait_gpu, struct ttm_mem_reg *new_mem)
970968
{
971969
struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
972970
struct nouveau_channel *chan = chan = drm->channel;
@@ -995,7 +993,6 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
995993
ret = drm->ttm.move(chan, bo, &bo->mem, new_mem);
996994
if (ret == 0) {
997995
ret = nouveau_bo_move_accel_cleanup(chan, nvbo, evict,
998-
no_wait_reserve,
999996
no_wait_gpu, new_mem);
1000997
}
1001998

@@ -1064,8 +1061,7 @@ nouveau_bo_move_init(struct nouveau_drm *drm)
10641061

10651062
static int
10661063
nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
1067-
bool no_wait_reserve, bool no_wait_gpu,
1068-
struct ttm_mem_reg *new_mem)
1064+
bool no_wait_gpu, struct ttm_mem_reg *new_mem)
10691065
{
10701066
u32 placement_memtype = TTM_PL_FLAG_TT | TTM_PL_MASK_CACHING;
10711067
struct ttm_placement placement;
@@ -1078,28 +1074,27 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
10781074

10791075
tmp_mem = *new_mem;
10801076
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);
10821078
if (ret)
10831079
return ret;
10841080

10851081
ret = ttm_tt_bind(bo->ttm, &tmp_mem);
10861082
if (ret)
10871083
goto out;
10881084

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);
10901086
if (ret)
10911087
goto out;
10921088

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);
10941090
out:
10951091
ttm_bo_mem_put(bo, &tmp_mem);
10961092
return ret;
10971093
}
10981094

10991095
static int
11001096
nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,
1101-
bool no_wait_reserve, bool no_wait_gpu,
1102-
struct ttm_mem_reg *new_mem)
1097+
bool no_wait_gpu, struct ttm_mem_reg *new_mem)
11031098
{
11041099
u32 placement_memtype = TTM_PL_FLAG_TT | TTM_PL_MASK_CACHING;
11051100
struct ttm_placement placement;
@@ -1112,15 +1107,15 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,
11121107

11131108
tmp_mem = *new_mem;
11141109
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);
11161111
if (ret)
11171112
return ret;
11181113

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);
11201115
if (ret)
11211116
goto out;
11221117

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);
11241119
if (ret)
11251120
goto out;
11261121

@@ -1195,8 +1190,7 @@ nouveau_bo_vm_cleanup(struct ttm_buffer_object *bo,
11951190

11961191
static int
11971192
nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr,
1198-
bool no_wait_reserve, bool no_wait_gpu,
1199-
struct ttm_mem_reg *new_mem)
1193+
bool no_wait_gpu, struct ttm_mem_reg *new_mem)
12001194
{
12011195
struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
12021196
struct nouveau_bo *nvbo = nouveau_bo(bo);
@@ -1220,23 +1214,26 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr,
12201214

12211215
/* CPU copy if we have no accelerated method available */
12221216
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);
12241218
goto out;
12251219
}
12261220

12271221
/* Hardware assisted copy. */
12281222
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);
12301225
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);
12321228
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);
12341231

12351232
if (!ret)
12361233
goto out;
12371234

12381235
/* 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);
12401237

12411238
out:
12421239
if (nv_device(drm->device)->card_type < NV_50) {
@@ -1343,7 +1340,7 @@ nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
13431340
nvbo->placement.fpfn = 0;
13441341
nvbo->placement.lpfn = mappable;
13451342
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);
13471344
}
13481345

13491346
static int

drivers/gpu/drm/nouveau/nouveau_bo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ u32 nouveau_bo_rd32(struct nouveau_bo *, unsigned index);
7676
void nouveau_bo_wr32(struct nouveau_bo *, unsigned index, u32 val);
7777
void nouveau_bo_fence(struct nouveau_bo *, struct nouveau_fence *);
7878
int nouveau_bo_validate(struct nouveau_bo *, bool interruptible,
79-
bool no_wait_reserve, bool no_wait_gpu);
79+
bool no_wait_gpu);
8080

8181
struct nouveau_vma *
8282
nouveau_bo_vma_find(struct nouveau_bo *, struct nouveau_vm *);

drivers/gpu/drm/nouveau/nouveau_gem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ validate_list(struct nouveau_channel *chan, struct list_head *list,
433433
return ret;
434434
}
435435

436-
ret = nouveau_bo_validate(nvbo, true, false, false);
436+
ret = nouveau_bo_validate(nvbo, true, false);
437437
if (unlikely(ret)) {
438438
if (ret != -ERESTARTSYS)
439439
NV_ERROR(drm, "fail ttm_validate\n");

drivers/gpu/drm/radeon/radeon_object.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ int radeon_bo_pin_restricted(struct radeon_bo *bo, u32 domain, u64 max_offset,
250250
}
251251
for (i = 0; i < bo->placement.num_placement; i++)
252252
bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
253-
r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false, false);
253+
r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false);
254254
if (likely(r == 0)) {
255255
bo->pin_count = 1;
256256
if (gpu_addr != NULL)
@@ -279,7 +279,7 @@ int radeon_bo_unpin(struct radeon_bo *bo)
279279
return 0;
280280
for (i = 0; i < bo->placement.num_placement; i++)
281281
bo->placements[i] &= ~TTM_PL_FLAG_NO_EVICT;
282-
r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false, false);
282+
r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false);
283283
if (unlikely(r != 0))
284284
dev_err(bo->rdev->dev, "%p validate failed for unpin\n", bo);
285285
return r;
@@ -365,7 +365,7 @@ int radeon_bo_list_validate(struct list_head *head)
365365
retry:
366366
radeon_ttm_placement_from_domain(bo, domain);
367367
r = ttm_bo_validate(&bo->tbo, &bo->placement,
368-
true, false, false);
368+
true, false);
369369
if (unlikely(r)) {
370370
if (r != -ERESTARTSYS && domain == RADEON_GEM_DOMAIN_VRAM) {
371371
domain |= RADEON_GEM_DOMAIN_GTT;
@@ -585,7 +585,7 @@ int radeon_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
585585
/* hurrah the memory is not visible ! */
586586
radeon_ttm_placement_from_domain(rbo, RADEON_GEM_DOMAIN_VRAM);
587587
rbo->placement.lpfn = rdev->mc.visible_vram_size >> PAGE_SHIFT;
588-
r = ttm_bo_validate(bo, &rbo->placement, false, true, false);
588+
r = ttm_bo_validate(bo, &rbo->placement, false, false);
589589
if (unlikely(r != 0))
590590
return r;
591591
offset = bo->mem.start << PAGE_SHIFT;

0 commit comments

Comments
 (0)