aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorFlora Cui <Flora.Cui@amd.com>2016-04-19 22:23:47 -0400
committerAlex Deucher <alexander.deucher@amd.com>2016-04-27 12:26:50 -0400
commit56fc350224f16901db709cd8cba86bac751aa2a2 (patch)
treef9b6f852d5d928e463a1427bcb95f6a54f72634a /drivers/gpu
parent18cdfe751f26ffa610f2a7b59775c5cc4c1c9619 (diff)
drm/ttm: fix kref count mess in ttm_bo_move_to_lru_tail
Fixes the following scenario: 1. Page table bo allocated in vram and linked to man->lru. tbo->list_kref.refcount=2 2. Page table bo is swapped out and removed from man->lru. tbo->list_kref.refcount=1 3. Command submission from userspace. Page table bo is moved to vram. ttm_bo_move_to_lru_tail() link it to man->lru and don't increase the kref count. Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: Flora Cui <Flora.Cui@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 4cbf26555093..e3daafa1be13 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -230,22 +230,13 @@ EXPORT_SYMBOL(ttm_bo_del_sub_from_lru);
230 230
231void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo) 231void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo)
232{ 232{
233 struct ttm_bo_device *bdev = bo->bdev; 233 int put_count = 0;
234 struct ttm_mem_type_manager *man;
235 234
236 lockdep_assert_held(&bo->resv->lock.base); 235 lockdep_assert_held(&bo->resv->lock.base);
237 236
238 if (bo->mem.placement & TTM_PL_FLAG_NO_EVICT) { 237 put_count = ttm_bo_del_from_lru(bo);
239 list_del_init(&bo->swap); 238 ttm_bo_list_ref_sub(bo, put_count, true);
240 list_del_init(&bo->lru); 239 ttm_bo_add_to_lru(bo);
241
242 } else {
243 if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG))
244 list_move_tail(&bo->swap, &bo->glob->swap_lru);
245
246 man = &bdev->man[bo->mem.mem_type];
247 list_move_tail(&bo->lru, &man->lru);
248 }
249} 240}
250EXPORT_SYMBOL(ttm_bo_move_to_lru_tail); 241EXPORT_SYMBOL(ttm_bo_move_to_lru_tail);
251 242