aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2014-04-05 02:07:39 -0400
committerDave Airlie <airlied@redhat.com>2014-04-05 02:07:39 -0400
commit8d51a977a4961d3ed6df699aea50bc2dd6bbc5cc (patch)
treecff4fe3ab8eee3d8efab35aa5dad0d7c33bde527 /include/drm
parentaa17edff0afa893b5ab1dd60d842cc6f42e847b4 (diff)
parentc75230833ce4fbbfaa257c07b55f97912fb1dc02 (diff)
Merge tag 'ttm-next-2014-04-04' of git://people.freedesktop.org/~thomash/linux into drm-next
Pull request of 2014-04-04 Currently only a single patch fixing up mixed use of the ttm_bo_reserve and ww_mutex APIs * tag 'ttm-next-2014-04-04' of git://people.freedesktop.org/~thomash/linux: drm/ttm: Hide the implementation details of reservation
Diffstat (limited to 'include/drm')
-rw-r--r--include/drm/ttm/ttm_bo_driver.h47
1 files changed, 29 insertions, 18 deletions
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);
788extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo); 788extern 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 */
812static inline int ttm_bo_reserve_nolru(struct ttm_buffer_object *bo, 812static 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 */
938static inline void ttm_bo_unreserve_ticket(struct ttm_buffer_object *bo, 937static 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 */
956static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo) 949static 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 */
966static 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/*