From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com>
Date: Wed, 15 Nov 2017 11:05:17 +0100
Subject: drm/ttm: fix ttm_mem_evict_first once more
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Git-commit: 090528639321ab09c150603c0da3c38c26aa5ea9
Patch-mainline: v4.16-rc1
References: FATE#326289 FATE#326079 FATE#326049 FATE#322398 FATE#326166
The code path isn't hit at the moment, but we need to take the lock to
add the BO back to the LRU.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Roger He <Hongbo.He@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Petr Tesarik <ptesarik@suse.com>
---
drivers/gpu/drm/ttm/ttm_bo.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -793,10 +793,13 @@ static int ttm_mem_evict_first(struct tt
spin_unlock(&glob->lru_lock);
ret = ttm_bo_evict(bo, interruptible, no_wait_gpu);
- if (locked)
+ if (locked) {
ttm_bo_unreserve(bo);
- else
+ } else {
+ spin_lock(&glob->lru_lock);
ttm_bo_add_to_lru(bo);
+ spin_unlock(&glob->lru_lock);
+ }
kref_put(&bo->list_kref, ttm_bo_release_list);
return ret;