diff options
author | Christian König <christian.koenig@amd.com> | 2017-11-08 15:02:31 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-12-06 12:47:19 -0500 |
commit | 842cde05840e9203d13383d30cc479f44f4ab599 (patch) | |
tree | 017ea4357f3539fbf173dc684091e897b2675eb8 /drivers | |
parent | 36a0680aac137a9b956fb454d6bf642c9aae0be1 (diff) |
drm/ttm: user reservation object wrappers v2
Consistently use the reservation object wrappers instead of accessing
the ww_mutex directly.
Additional to that use the reservation object wrappers directly instead of
calling __ttm_bo_reserve with fixed parameters.
v2: fix typo
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-and-Tested-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_bo.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 6f55310a9d09..db0f670911ec 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c | |||
@@ -446,7 +446,7 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo) | |||
446 | } | 446 | } |
447 | 447 | ||
448 | spin_lock(&glob->lru_lock); | 448 | spin_lock(&glob->lru_lock); |
449 | ret = __ttm_bo_reserve(bo, false, true, NULL); | 449 | ret = reservation_object_trylock(bo->resv) ? 0 : -EBUSY; |
450 | if (!ret) { | 450 | if (!ret) { |
451 | if (reservation_object_test_signaled_rcu(&bo->ttm_resv, true)) { | 451 | if (reservation_object_test_signaled_rcu(&bo->ttm_resv, true)) { |
452 | ttm_bo_del_from_lru(bo); | 452 | ttm_bo_del_from_lru(bo); |
@@ -531,7 +531,7 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo, | |||
531 | return -EBUSY; | 531 | return -EBUSY; |
532 | 532 | ||
533 | spin_lock(&glob->lru_lock); | 533 | spin_lock(&glob->lru_lock); |
534 | ret = __ttm_bo_reserve(bo, false, true, NULL); | 534 | ret = reservation_object_trylock(bo->resv) ? 0 : -EBUSY; |
535 | 535 | ||
536 | /* | 536 | /* |
537 | * We raced, and lost, someone else holds the reservation now, | 537 | * We raced, and lost, someone else holds the reservation now, |
@@ -592,10 +592,10 @@ static int ttm_bo_delayed_delete(struct ttm_bo_device *bdev, bool remove_all) | |||
592 | kref_get(&nentry->list_kref); | 592 | kref_get(&nentry->list_kref); |
593 | } | 593 | } |
594 | 594 | ||
595 | ret = __ttm_bo_reserve(entry, false, true, NULL); | 595 | ret = reservation_object_trylock(entry->resv) ? 0 : -EBUSY; |
596 | if (remove_all && ret) { | 596 | if (remove_all && ret) { |
597 | spin_unlock(&glob->lru_lock); | 597 | spin_unlock(&glob->lru_lock); |
598 | ret = __ttm_bo_reserve(entry, false, false, NULL); | 598 | ret = reservation_object_lock(entry->resv, NULL); |
599 | spin_lock(&glob->lru_lock); | 599 | spin_lock(&glob->lru_lock); |
600 | } | 600 | } |
601 | 601 | ||
@@ -744,7 +744,7 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev, | |||
744 | spin_lock(&glob->lru_lock); | 744 | spin_lock(&glob->lru_lock); |
745 | for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { | 745 | for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { |
746 | list_for_each_entry(bo, &man->lru[i], lru) { | 746 | list_for_each_entry(bo, &man->lru[i], lru) { |
747 | ret = __ttm_bo_reserve(bo, false, true, NULL); | 747 | ret = reservation_object_trylock(bo->resv) ? 0 : -EBUSY; |
748 | if (ret) | 748 | if (ret) |
749 | continue; | 749 | continue; |
750 | 750 | ||
@@ -1719,7 +1719,7 @@ static int ttm_bo_swapout(struct ttm_mem_shrink *shrink) | |||
1719 | spin_lock(&glob->lru_lock); | 1719 | spin_lock(&glob->lru_lock); |
1720 | for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { | 1720 | for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { |
1721 | list_for_each_entry(bo, &glob->swap_lru[i], swap) { | 1721 | list_for_each_entry(bo, &glob->swap_lru[i], swap) { |
1722 | ret = __ttm_bo_reserve(bo, false, true, NULL); | 1722 | ret = reservation_object_trylock(bo->resv) ? 0 : -EBUSY; |
1723 | if (!ret) | 1723 | if (!ret) |
1724 | break; | 1724 | break; |
1725 | } | 1725 | } |
@@ -1823,7 +1823,9 @@ int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo) | |||
1823 | return -ERESTARTSYS; | 1823 | return -ERESTARTSYS; |
1824 | if (!ww_mutex_is_locked(&bo->resv->lock)) | 1824 | if (!ww_mutex_is_locked(&bo->resv->lock)) |
1825 | goto out_unlock; | 1825 | goto out_unlock; |
1826 | ret = __ttm_bo_reserve(bo, true, false, NULL); | 1826 | ret = reservation_object_lock_interruptible(bo->resv, NULL); |
1827 | if (ret == -EINTR) | ||
1828 | ret = -ERESTARTSYS; | ||
1827 | if (unlikely(ret != 0)) | 1829 | if (unlikely(ret != 0)) |
1828 | goto out_unlock; | 1830 | goto out_unlock; |
1829 | reservation_object_unlock(bo->resv); | 1831 | reservation_object_unlock(bo->resv); |