diff options
-rw-r--r-- | drivers/gpu/drm/qxl/qxl_release.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_bo.c | 26 | ||||
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_execbuf_util.c | 8 | ||||
-rw-r--r-- | include/drm/ttm/ttm_bo_driver.h | 47 |
4 files changed, 47 insertions, 36 deletions
diff --git a/drivers/gpu/drm/qxl/qxl_release.c b/drivers/gpu/drm/qxl/qxl_release.c index 821ab7b9409b..14e776f1d14e 100644 --- a/drivers/gpu/drm/qxl/qxl_release.c +++ b/drivers/gpu/drm/qxl/qxl_release.c | |||
@@ -349,7 +349,7 @@ void qxl_release_fence_buffer_objects(struct qxl_release *release) | |||
349 | qxl_fence_add_release_locked(&qbo->fence, release->id); | 349 | qxl_fence_add_release_locked(&qbo->fence, release->id); |
350 | 350 | ||
351 | ttm_bo_add_to_lru(bo); | 351 | ttm_bo_add_to_lru(bo); |
352 | ww_mutex_unlock(&bo->resv->lock); | 352 | __ttm_bo_unreserve(bo); |
353 | entry->reserved = false; | 353 | entry->reserved = false; |
354 | } | 354 | } |
355 | spin_unlock(&bdev->fence_lock); | 355 | spin_unlock(&bdev->fence_lock); |
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 9df79ac7b8f5..4ab9f7171c4f 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c | |||
@@ -412,7 +412,7 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo) | |||
412 | int ret; | 412 | int ret; |
413 | 413 | ||
414 | spin_lock(&glob->lru_lock); | 414 | spin_lock(&glob->lru_lock); |
415 | ret = ttm_bo_reserve_nolru(bo, false, true, false, 0); | 415 | ret = __ttm_bo_reserve(bo, false, true, false, 0); |
416 | 416 | ||
417 | spin_lock(&bdev->fence_lock); | 417 | spin_lock(&bdev->fence_lock); |
418 | (void) ttm_bo_wait(bo, false, false, true); | 418 | (void) ttm_bo_wait(bo, false, false, true); |
@@ -443,7 +443,7 @@ static void ttm_bo_cleanup_refs_or_queue(struct ttm_buffer_object *bo) | |||
443 | ttm_bo_add_to_lru(bo); | 443 | ttm_bo_add_to_lru(bo); |
444 | } | 444 | } |
445 | 445 | ||
446 | ww_mutex_unlock(&bo->resv->lock); | 446 | __ttm_bo_unreserve(bo); |
447 | } | 447 | } |
448 | 448 | ||
449 | kref_get(&bo->list_kref); | 449 | kref_get(&bo->list_kref); |
@@ -494,7 +494,7 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo, | |||
494 | sync_obj = driver->sync_obj_ref(bo->sync_obj); | 494 | sync_obj = driver->sync_obj_ref(bo->sync_obj); |
495 | spin_unlock(&bdev->fence_lock); | 495 | spin_unlock(&bdev->fence_lock); |
496 | 496 | ||
497 | ww_mutex_unlock(&bo->resv->lock); | 497 | __ttm_bo_unreserve(bo); |
498 | spin_unlock(&glob->lru_lock); | 498 | spin_unlock(&glob->lru_lock); |
499 | 499 | ||
500 | ret = driver->sync_obj_wait(sync_obj, false, interruptible); | 500 | ret = driver->sync_obj_wait(sync_obj, false, interruptible); |
@@ -514,7 +514,7 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo, | |||
514 | return ret; | 514 | return ret; |
515 | 515 | ||
516 | spin_lock(&glob->lru_lock); | 516 | spin_lock(&glob->lru_lock); |
517 | ret = ttm_bo_reserve_nolru(bo, false, true, false, 0); | 517 | ret = __ttm_bo_reserve(bo, false, true, false, 0); |
518 | 518 | ||
519 | /* | 519 | /* |
520 | * We raced, and lost, someone else holds the reservation now, | 520 | * We raced, and lost, someone else holds the reservation now, |
@@ -532,7 +532,7 @@ static int ttm_bo_cleanup_refs_and_unlock(struct ttm_buffer_object *bo, | |||
532 | spin_unlock(&bdev->fence_lock); | 532 | spin_unlock(&bdev->fence_lock); |
533 | 533 | ||
534 | if (ret || unlikely(list_empty(&bo->ddestroy))) { | 534 | if (ret || unlikely(list_empty(&bo->ddestroy))) { |
535 | ww_mutex_unlock(&bo->resv->lock); | 535 | __ttm_bo_unreserve(bo); |
536 | spin_unlock(&glob->lru_lock); | 536 | spin_unlock(&glob->lru_lock); |
537 | return ret; | 537 | return ret; |
538 | } | 538 | } |
@@ -577,11 +577,11 @@ static int ttm_bo_delayed_delete(struct ttm_bo_device *bdev, bool remove_all) | |||
577 | kref_get(&nentry->list_kref); | 577 | kref_get(&nentry->list_kref); |
578 | } | 578 | } |
579 | 579 | ||
580 | ret = ttm_bo_reserve_nolru(entry, false, true, false, 0); | 580 | ret = __ttm_bo_reserve(entry, false, true, false, 0); |
581 | if (remove_all && ret) { | 581 | if (remove_all && ret) { |
582 | spin_unlock(&glob->lru_lock); | 582 | spin_unlock(&glob->lru_lock); |
583 | ret = ttm_bo_reserve_nolru(entry, false, false, | 583 | ret = __ttm_bo_reserve(entry, false, false, |
584 | false, 0); | 584 | false, 0); |
585 | spin_lock(&glob->lru_lock); | 585 | spin_lock(&glob->lru_lock); |
586 | } | 586 | } |
587 | 587 | ||
@@ -726,7 +726,7 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev, | |||
726 | 726 | ||
727 | spin_lock(&glob->lru_lock); | 727 | spin_lock(&glob->lru_lock); |
728 | list_for_each_entry(bo, &man->lru, lru) { | 728 | list_for_each_entry(bo, &man->lru, lru) { |
729 | ret = ttm_bo_reserve_nolru(bo, false, true, false, 0); | 729 | ret = __ttm_bo_reserve(bo, false, true, false, 0); |
730 | if (!ret) | 730 | if (!ret) |
731 | break; | 731 | break; |
732 | } | 732 | } |
@@ -1630,7 +1630,7 @@ static int ttm_bo_swapout(struct ttm_mem_shrink *shrink) | |||
1630 | 1630 | ||
1631 | spin_lock(&glob->lru_lock); | 1631 | spin_lock(&glob->lru_lock); |
1632 | list_for_each_entry(bo, &glob->swap_lru, swap) { | 1632 | list_for_each_entry(bo, &glob->swap_lru, swap) { |
1633 | ret = ttm_bo_reserve_nolru(bo, false, true, false, 0); | 1633 | ret = __ttm_bo_reserve(bo, false, true, false, 0); |
1634 | if (!ret) | 1634 | if (!ret) |
1635 | break; | 1635 | break; |
1636 | } | 1636 | } |
@@ -1697,7 +1697,7 @@ out: | |||
1697 | * already swapped buffer. | 1697 | * already swapped buffer. |
1698 | */ | 1698 | */ |
1699 | 1699 | ||
1700 | ww_mutex_unlock(&bo->resv->lock); | 1700 | __ttm_bo_unreserve(bo); |
1701 | kref_put(&bo->list_kref, ttm_bo_release_list); | 1701 | kref_put(&bo->list_kref, ttm_bo_release_list); |
1702 | return ret; | 1702 | return ret; |
1703 | } | 1703 | } |
@@ -1731,10 +1731,10 @@ int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo) | |||
1731 | return -ERESTARTSYS; | 1731 | return -ERESTARTSYS; |
1732 | if (!ww_mutex_is_locked(&bo->resv->lock)) | 1732 | if (!ww_mutex_is_locked(&bo->resv->lock)) |
1733 | goto out_unlock; | 1733 | goto out_unlock; |
1734 | ret = ttm_bo_reserve_nolru(bo, true, false, false, NULL); | 1734 | ret = __ttm_bo_reserve(bo, true, false, false, NULL); |
1735 | if (unlikely(ret != 0)) | 1735 | if (unlikely(ret != 0)) |
1736 | goto out_unlock; | 1736 | goto out_unlock; |
1737 | ww_mutex_unlock(&bo->resv->lock); | 1737 | __ttm_bo_unreserve(bo); |
1738 | 1738 | ||
1739 | out_unlock: | 1739 | out_unlock: |
1740 | mutex_unlock(&bo->wu_mutex); | 1740 | mutex_unlock(&bo->wu_mutex); |
diff --git a/drivers/gpu/drm/ttm/ttm_execbuf_util.c b/drivers/gpu/drm/ttm/ttm_execbuf_util.c index 479e9418e3d7..e8dac8758528 100644 --- a/drivers/gpu/drm/ttm/ttm_execbuf_util.c +++ b/drivers/gpu/drm/ttm/ttm_execbuf_util.c | |||
@@ -46,7 +46,7 @@ static void ttm_eu_backoff_reservation_locked(struct list_head *list) | |||
46 | ttm_bo_add_to_lru(bo); | 46 | ttm_bo_add_to_lru(bo); |
47 | entry->removed = false; | 47 | entry->removed = false; |
48 | } | 48 | } |
49 | ww_mutex_unlock(&bo->resv->lock); | 49 | __ttm_bo_unreserve(bo); |
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
@@ -140,8 +140,8 @@ retry: | |||
140 | if (entry->reserved) | 140 | if (entry->reserved) |
141 | continue; | 141 | continue; |
142 | 142 | ||
143 | ret = ttm_bo_reserve_nolru(bo, true, (ticket == NULL), true, | 143 | ret = __ttm_bo_reserve(bo, true, (ticket == NULL), true, |
144 | ticket); | 144 | ticket); |
145 | 145 | ||
146 | if (ret == -EDEADLK) { | 146 | if (ret == -EDEADLK) { |
147 | /* uh oh, we lost out, drop every reservation and try | 147 | /* uh oh, we lost out, drop every reservation and try |
@@ -224,7 +224,7 @@ void ttm_eu_fence_buffer_objects(struct ww_acquire_ctx *ticket, | |||
224 | entry->old_sync_obj = bo->sync_obj; | 224 | entry->old_sync_obj = bo->sync_obj; |
225 | bo->sync_obj = driver->sync_obj_ref(sync_obj); | 225 | bo->sync_obj = driver->sync_obj_ref(sync_obj); |
226 | ttm_bo_add_to_lru(bo); | 226 | ttm_bo_add_to_lru(bo); |
227 | ww_mutex_unlock(&bo->resv->lock); | 227 | __ttm_bo_unreserve(bo); |
228 | entry->reserved = false; | 228 | entry->reserved = false; |
229 | } | 229 | } |
230 | spin_unlock(&bdev->fence_lock); | 230 | spin_unlock(&bdev->fence_lock); |
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 5d8aabe68f6c..a5183da3ef92 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h | |||
@@ -788,7 +788,7 @@ extern void ttm_bo_del_sub_from_lru(struct ttm_buffer_object *bo); | |||
788 | extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo); | 788 | extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo); |
789 | 789 | ||
790 | /** | 790 | /** |
791 | * ttm_bo_reserve_nolru: | 791 | * __ttm_bo_reserve: |
792 | * | 792 | * |
793 | * @bo: A pointer to a struct ttm_buffer_object. | 793 | * @bo: A pointer to a struct ttm_buffer_object. |
794 | * @interruptible: Sleep interruptible if waiting. | 794 | * @interruptible: Sleep interruptible if waiting. |
@@ -809,10 +809,10 @@ extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo); | |||
809 | * -EALREADY: Bo already reserved using @ticket. This error code will only | 809 | * -EALREADY: Bo already reserved using @ticket. This error code will only |
810 | * be returned if @use_ticket is set to true. | 810 | * be returned if @use_ticket is set to true. |
811 | */ | 811 | */ |
812 | static inline int ttm_bo_reserve_nolru(struct ttm_buffer_object *bo, | 812 | static inline int __ttm_bo_reserve(struct ttm_buffer_object *bo, |
813 | bool interruptible, | 813 | bool interruptible, |
814 | bool no_wait, bool use_ticket, | 814 | bool no_wait, bool use_ticket, |
815 | struct ww_acquire_ctx *ticket) | 815 | struct ww_acquire_ctx *ticket) |
816 | { | 816 | { |
817 | int ret = 0; | 817 | int ret = 0; |
818 | 818 | ||
@@ -888,8 +888,7 @@ static inline int ttm_bo_reserve(struct ttm_buffer_object *bo, | |||
888 | 888 | ||
889 | WARN_ON(!atomic_read(&bo->kref.refcount)); | 889 | WARN_ON(!atomic_read(&bo->kref.refcount)); |
890 | 890 | ||
891 | ret = ttm_bo_reserve_nolru(bo, interruptible, no_wait, use_ticket, | 891 | ret = __ttm_bo_reserve(bo, interruptible, no_wait, use_ticket, ticket); |
892 | ticket); | ||
893 | if (likely(ret == 0)) | 892 | if (likely(ret == 0)) |
894 | ttm_bo_del_sub_from_lru(bo); | 893 | ttm_bo_del_sub_from_lru(bo); |
895 | 894 | ||
@@ -929,20 +928,14 @@ static inline int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo, | |||
929 | } | 928 | } |
930 | 929 | ||
931 | /** | 930 | /** |
932 | * ttm_bo_unreserve_ticket | 931 | * __ttm_bo_unreserve |
933 | * @bo: A pointer to a struct ttm_buffer_object. | 932 | * @bo: A pointer to a struct ttm_buffer_object. |
934 | * @ticket: ww_acquire_ctx used for reserving | ||
935 | * | 933 | * |
936 | * Unreserve a previous reservation of @bo made with @ticket. | 934 | * Unreserve a previous reservation of @bo where the buffer object is |
935 | * already on lru lists. | ||
937 | */ | 936 | */ |
938 | static inline void ttm_bo_unreserve_ticket(struct ttm_buffer_object *bo, | 937 | static inline void __ttm_bo_unreserve(struct ttm_buffer_object *bo) |
939 | struct ww_acquire_ctx *t) | ||
940 | { | 938 | { |
941 | if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) { | ||
942 | spin_lock(&bo->glob->lru_lock); | ||
943 | ttm_bo_add_to_lru(bo); | ||
944 | spin_unlock(&bo->glob->lru_lock); | ||
945 | } | ||
946 | ww_mutex_unlock(&bo->resv->lock); | 939 | ww_mutex_unlock(&bo->resv->lock); |
947 | } | 940 | } |
948 | 941 | ||
@@ -955,7 +948,25 @@ static inline void ttm_bo_unreserve_ticket(struct ttm_buffer_object *bo, | |||
955 | */ | 948 | */ |
956 | static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo) | 949 | static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo) |
957 | { | 950 | { |
958 | ttm_bo_unreserve_ticket(bo, NULL); | 951 | if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) { |
952 | spin_lock(&bo->glob->lru_lock); | ||
953 | ttm_bo_add_to_lru(bo); | ||
954 | spin_unlock(&bo->glob->lru_lock); | ||
955 | } | ||
956 | __ttm_bo_unreserve(bo); | ||
957 | } | ||
958 | |||
959 | /** | ||
960 | * ttm_bo_unreserve_ticket | ||
961 | * @bo: A pointer to a struct ttm_buffer_object. | ||
962 | * @ticket: ww_acquire_ctx used for reserving | ||
963 | * | ||
964 | * Unreserve a previous reservation of @bo made with @ticket. | ||
965 | */ | ||
966 | static inline void ttm_bo_unreserve_ticket(struct ttm_buffer_object *bo, | ||
967 | struct ww_acquire_ctx *t) | ||
968 | { | ||
969 | ttm_bo_unreserve(bo); | ||
959 | } | 970 | } |
960 | 971 | ||
961 | /* | 972 | /* |