aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm/ttm/ttm_bo_driver.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/drm/ttm/ttm_bo_driver.h')
-rw-r--r--include/drm/ttm/ttm_bo_driver.h49
1 files changed, 31 insertions, 18 deletions
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 32d34ebf0706..a5183da3ef92 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -747,6 +747,7 @@ extern int ttm_bo_device_release(struct ttm_bo_device *bdev);
747 * @bdev: A pointer to a struct ttm_bo_device to initialize. 747 * @bdev: A pointer to a struct ttm_bo_device to initialize.
748 * @glob: A pointer to an initialized struct ttm_bo_global. 748 * @glob: A pointer to an initialized struct ttm_bo_global.
749 * @driver: A pointer to a struct ttm_bo_driver set up by the caller. 749 * @driver: A pointer to a struct ttm_bo_driver set up by the caller.
750 * @mapping: The address space to use for this bo.
750 * @file_page_offset: Offset into the device address space that is available 751 * @file_page_offset: Offset into the device address space that is available
751 * for buffer data. This ensures compatibility with other users of the 752 * for buffer data. This ensures compatibility with other users of the
752 * address space. 753 * address space.
@@ -758,6 +759,7 @@ extern int ttm_bo_device_release(struct ttm_bo_device *bdev);
758extern int ttm_bo_device_init(struct ttm_bo_device *bdev, 759extern int ttm_bo_device_init(struct ttm_bo_device *bdev,
759 struct ttm_bo_global *glob, 760 struct ttm_bo_global *glob,
760 struct ttm_bo_driver *driver, 761 struct ttm_bo_driver *driver,
762 struct address_space *mapping,
761 uint64_t file_page_offset, bool need_dma32); 763 uint64_t file_page_offset, bool need_dma32);
762 764
763/** 765/**
@@ -786,7 +788,7 @@ extern void ttm_bo_del_sub_from_lru(struct ttm_buffer_object *bo);
786extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo); 788extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo);
787 789
788/** 790/**
789 * ttm_bo_reserve_nolru: 791 * __ttm_bo_reserve:
790 * 792 *
791 * @bo: A pointer to a struct ttm_buffer_object. 793 * @bo: A pointer to a struct ttm_buffer_object.
792 * @interruptible: Sleep interruptible if waiting. 794 * @interruptible: Sleep interruptible if waiting.
@@ -807,10 +809,10 @@ extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo);
807 * -EALREADY: Bo already reserved using @ticket. This error code will only 809 * -EALREADY: Bo already reserved using @ticket. This error code will only
808 * be returned if @use_ticket is set to true. 810 * be returned if @use_ticket is set to true.
809 */ 811 */
810static inline int ttm_bo_reserve_nolru(struct ttm_buffer_object *bo, 812static inline int __ttm_bo_reserve(struct ttm_buffer_object *bo,
811 bool interruptible, 813 bool interruptible,
812 bool no_wait, bool use_ticket, 814 bool no_wait, bool use_ticket,
813 struct ww_acquire_ctx *ticket) 815 struct ww_acquire_ctx *ticket)
814{ 816{
815 int ret = 0; 817 int ret = 0;
816 818
@@ -886,8 +888,7 @@ static inline int ttm_bo_reserve(struct ttm_buffer_object *bo,
886 888
887 WARN_ON(!atomic_read(&bo->kref.refcount)); 889 WARN_ON(!atomic_read(&bo->kref.refcount));
888 890
889 ret = ttm_bo_reserve_nolru(bo, interruptible, no_wait, use_ticket, 891 ret = __ttm_bo_reserve(bo, interruptible, no_wait, use_ticket, ticket);
890 ticket);
891 if (likely(ret == 0)) 892 if (likely(ret == 0))
892 ttm_bo_del_sub_from_lru(bo); 893 ttm_bo_del_sub_from_lru(bo);
893 894
@@ -927,20 +928,14 @@ static inline int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo,
927} 928}
928 929
929/** 930/**
930 * ttm_bo_unreserve_ticket 931 * __ttm_bo_unreserve
931 * @bo: A pointer to a struct ttm_buffer_object. 932 * @bo: A pointer to a struct ttm_buffer_object.
932 * @ticket: ww_acquire_ctx used for reserving
933 * 933 *
934 * 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.
935 */ 936 */
936static inline void ttm_bo_unreserve_ticket(struct ttm_buffer_object *bo, 937static inline void __ttm_bo_unreserve(struct ttm_buffer_object *bo)
937 struct ww_acquire_ctx *t)
938{ 938{
939 if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
940 spin_lock(&bo->glob->lru_lock);
941 ttm_bo_add_to_lru(bo);
942 spin_unlock(&bo->glob->lru_lock);
943 }
944 ww_mutex_unlock(&bo->resv->lock); 939 ww_mutex_unlock(&bo->resv->lock);
945} 940}
946 941
@@ -953,7 +948,25 @@ static inline void ttm_bo_unreserve_ticket(struct ttm_buffer_object *bo,
953 */ 948 */
954static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo) 949static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)
955{ 950{
956 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);
957} 970}
958 971
959/* 972/*