Skip to content

Commit 62975d2

Browse files
Christian Königairlied
authored andcommitted
drm/ttm: revert "drm/ttm: make TT creation purely optional v3"
This reverts commit 2ddef17. As it turned out VMWGFX needs a much wider audit to fix this. Signed-off-by: Christian König <[email protected]> Reviewed-by: Dave Airlie <[email protected]> Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 312d100 commit 62975d2

File tree

4 files changed

+31
-22
lines changed

4 files changed

+31
-22
lines changed

drivers/gpu/drm/ttm/ttm_bo.c

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,12 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
287287
*/
288288

289289
if (!(new_man->flags & TTM_MEMTYPE_FLAG_FIXED)) {
290-
bool zero = !(old_man->flags & TTM_MEMTYPE_FLAG_FIXED);
291-
292-
ret = ttm_tt_create(bo, zero);
293-
if (ret)
294-
goto out_err;
290+
if (bo->ttm == NULL) {
291+
bool zero = !(old_man->flags & TTM_MEMTYPE_FLAG_FIXED);
292+
ret = ttm_tt_create(bo, zero);
293+
if (ret)
294+
goto out_err;
295+
}
295296

296297
ret = ttm_tt_set_placement_caching(bo->ttm, mem->placement);
297298
if (ret)
@@ -652,8 +653,13 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo,
652653
placement.num_busy_placement = 0;
653654
bdev->driver->evict_flags(bo, &placement);
654655

655-
if (!placement.num_placement && !placement.num_busy_placement)
656-
return ttm_bo_pipeline_gutting(bo);
656+
if (!placement.num_placement && !placement.num_busy_placement) {
657+
ret = ttm_bo_pipeline_gutting(bo);
658+
if (ret)
659+
return ret;
660+
661+
return ttm_tt_create(bo, false);
662+
}
657663

658664
evict_mem = bo->mem;
659665
evict_mem.mm_node = NULL;
@@ -1192,8 +1198,13 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
11921198
/*
11931199
* Remove the backing store if no placement is given.
11941200
*/
1195-
if (!placement->num_placement && !placement->num_busy_placement)
1196-
return ttm_bo_pipeline_gutting(bo);
1201+
if (!placement->num_placement && !placement->num_busy_placement) {
1202+
ret = ttm_bo_pipeline_gutting(bo);
1203+
if (ret)
1204+
return ret;
1205+
1206+
return ttm_tt_create(bo, false);
1207+
}
11971208

11981209
/*
11991210
* Check whether we need to move buffer.
@@ -1210,6 +1221,14 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
12101221
ttm_flag_masked(&bo->mem.placement, new_flags,
12111222
~TTM_PL_MASK_MEMTYPE);
12121223
}
1224+
/*
1225+
* We might need to add a TTM.
1226+
*/
1227+
if (bo->mem.mem_type == TTM_PL_SYSTEM && bo->ttm == NULL) {
1228+
ret = ttm_tt_create(bo, true);
1229+
if (ret)
1230+
return ret;
1231+
}
12131232
return 0;
12141233
}
12151234
EXPORT_SYMBOL(ttm_bo_validate);

drivers/gpu/drm/ttm/ttm_bo_util.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -531,15 +531,12 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo,
531531
.interruptible = false,
532532
.no_wait_gpu = false
533533
};
534-
struct ttm_tt *ttm;
534+
struct ttm_tt *ttm = bo->ttm;
535535
pgprot_t prot;
536536
int ret;
537537

538-
ret = ttm_tt_create(bo, true);
539-
if (ret)
540-
return ret;
538+
BUG_ON(!ttm);
541539

542-
ttm = bo->ttm;
543540
ret = ttm_tt_populate(ttm, &ctx);
544541
if (ret)
545542
return ret;

drivers/gpu/drm/ttm/ttm_bo_vm.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,6 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,
351351

352352
};
353353

354-
if (ttm_tt_create(bo, true)) {
355-
ret = VM_FAULT_OOM;
356-
goto out_io_unlock;
357-
}
358-
359354
ttm = bo->ttm;
360355
if (ttm_tt_populate(bo->ttm, &ctx)) {
361356
ret = VM_FAULT_OOM;

drivers/gpu/drm/ttm/ttm_tt.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc)
5050

5151
dma_resv_assert_held(bo->base.resv);
5252

53-
if (bo->ttm)
54-
return 0;
55-
5653
if (bdev->need_dma32)
5754
page_flags |= TTM_PAGE_FLAG_DMA32;
5855

@@ -70,6 +67,7 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc)
7067
page_flags |= TTM_PAGE_FLAG_SG;
7168
break;
7269
default:
70+
bo->ttm = NULL;
7371
pr_err("Illegal buffer object type\n");
7472
return -EINVAL;
7573
}

0 commit comments

Comments
 (0)