Blob Blame History Raw
From: Monk Liu <Monk.Liu@amd.com>
Date: Mon, 23 Oct 2017 10:30:57 +0800
Subject: drm/ttm:fix memory leak due to individualize
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Git-commit: bbb4d8d9ee81714b98c25df39a1ed90fa075e90a
Patch-mainline: v4.15-rc1
References: FATE#326289 FATE#326079 FATE#326049 FATE#322398 FATE#326166

after individualize we need manually call reservation_object_fini()
if all fences on resv signaled during test, otherwise kmemory leak

Signed-off-by: Monk Liu <Monk.Liu@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@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 |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -457,8 +457,11 @@ static void ttm_bo_cleanup_refs_or_queue
 		if (reservation_object_test_signaled_rcu(&bo->ttm_resv, true)) {
 			ttm_bo_del_from_lru(bo);
 			spin_unlock(&glob->lru_lock);
-			if (bo->resv != &bo->ttm_resv)
+			if (bo->resv != &bo->ttm_resv) {
 				reservation_object_unlock(&bo->ttm_resv);
+				reservation_object_fini(&bo->ttm_resv);
+			}
+
 			ttm_bo_cleanup_memtype_use(bo);
 			return;
 		}