Set bo->resv to ttm_resv during BO cleanup. This way freed BOs can be better reaped during eviction. Signed-off-by: Roger He <Hongbo.He at amd.com> Signed-off-by: Christian König <christian.koenig at amd.com> --- drivers/gpu/drm/ttm/ttm_bo.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index c088703777e2..cc33eb2174f6 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -444,18 +444,19 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo) reservation_object_wait_timeout_rcu(bo->resv, true, false, 30 * HZ); spin_lock(&glob->lru_lock); + bo->resv = &bo->ttm_resv; goto error; } spin_lock(&glob->lru_lock); - ret = __ttm_bo_reserve(bo, false, true, NULL); + if (bo->resv != &bo->ttm_resv) + bo->resv = &bo->ttm_resv; + else + ret = __ttm_bo_reserve(bo, false, true, NULL); if (!ret) { - if (reservation_object_test_signaled_rcu(&bo->ttm_resv, true)) { + if (reservation_object_test_signaled_rcu(bo->resv, true)) { ttm_bo_del_from_lru(bo); spin_unlock(&glob->lru_lock); - if (bo->resv != &bo->ttm_resv) - reservation_object_unlock(&bo->ttm_resv); - ttm_bo_cleanup_memtype_use(bo); return; } @@ -474,8 +475,6 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo) __ttm_bo_unreserve(bo); } - if (bo->resv != &bo->ttm_resv) - reservation_object_unlock(&bo->ttm_resv); error: kref_get(&bo->list_kref); @@ -503,15 +502,9 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo, bool no_wait_gpu) { struct ttm_bo_global *glob = bo->glob; - struct reservation_object *resv; int ret; - if (unlikely(list_empty(&bo->ddestroy))) - resv = bo->resv; - else - resv = &bo->ttm_resv; - - if (reservation_object_test_signaled_rcu(resv, true)) + if (reservation_object_test_signaled_rcu(bo->resv, true)) ret = 0; else ret = -EBUSY; @@ -521,7 +514,7 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo, ww_mutex_unlock(&bo->resv->lock); spin_unlock(&glob->lru_lock); - lret = reservation_object_wait_timeout_rcu(resv, true, + lret = reservation_object_wait_timeout_rcu(bo->resv, true, interruptible, 30 * HZ); -- 2.11.0