diff options
author | Maarten Lankhorst <m.b.lankhorst@gmail.com> | 2013-06-27 07:48:19 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2013-06-27 22:04:01 -0400 |
commit | 5e338405119a80aa59e811626739122d1c15045d (patch) | |
tree | 3474b9ab52408c78480a92a9d0c33626c61d7473 /include/drm/ttm | |
parent | b580c9e2b7ba5030a795aa2fb73b796523d65a78 (diff) |
drm/ttm: convert to the reservation api
Now that the code is compatible in semantics, flip the switch.
Use ww_mutex instead of the homegrown implementation.
ww_mutex uses -EDEADLK to signal that the caller has to back off,
and -EALREADY to indicate this buffer is already held by the caller.
ttm used -EAGAIN and -EDEADLK for those, respectively. So some changes
were needed to handle this correctly.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'include/drm/ttm')
-rw-r--r-- | include/drm/ttm/ttm_bo_api.h | 25 | ||||
-rw-r--r-- | include/drm/ttm/ttm_execbuf_util.h | 1 |
2 files changed, 6 insertions, 20 deletions
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 0a992b016fe9..31ad860c10cd 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/mm.h> | 39 | #include <linux/mm.h> |
40 | #include <linux/rbtree.h> | 40 | #include <linux/rbtree.h> |
41 | #include <linux/bitmap.h> | 41 | #include <linux/bitmap.h> |
42 | #include <linux/reservation.h> | ||
42 | 43 | ||
43 | struct ttm_bo_device; | 44 | struct ttm_bo_device; |
44 | 45 | ||
@@ -153,7 +154,6 @@ struct ttm_tt; | |||
153 | * Lru lists may keep one refcount, the delayed delete list, and kref != 0 | 154 | * Lru lists may keep one refcount, the delayed delete list, and kref != 0 |
154 | * keeps one refcount. When this refcount reaches zero, | 155 | * keeps one refcount. When this refcount reaches zero, |
155 | * the object is destroyed. | 156 | * the object is destroyed. |
156 | * @event_queue: Queue for processes waiting on buffer object status change. | ||
157 | * @mem: structure describing current placement. | 157 | * @mem: structure describing current placement. |
158 | * @persistent_swap_storage: Usually the swap storage is deleted for buffers | 158 | * @persistent_swap_storage: Usually the swap storage is deleted for buffers |
159 | * pinned in physical memory. If this behaviour is not desired, this member | 159 | * pinned in physical memory. If this behaviour is not desired, this member |
@@ -164,12 +164,6 @@ struct ttm_tt; | |||
164 | * @lru: List head for the lru list. | 164 | * @lru: List head for the lru list. |
165 | * @ddestroy: List head for the delayed destroy list. | 165 | * @ddestroy: List head for the delayed destroy list. |
166 | * @swap: List head for swap LRU list. | 166 | * @swap: List head for swap LRU list. |
167 | * @val_seq: Sequence of the validation holding the @reserved lock. | ||
168 | * Used to avoid starvation when many processes compete to validate the | ||
169 | * buffer. This member is protected by the bo_device::lru_lock. | ||
170 | * @seq_valid: The value of @val_seq is valid. This value is protected by | ||
171 | * the bo_device::lru_lock. | ||
172 | * @reserved: Deadlock-free lock used for synchronization state transitions. | ||
173 | * @sync_obj: Pointer to a synchronization object. | 167 | * @sync_obj: Pointer to a synchronization object. |
174 | * @priv_flags: Flags describing buffer object internal state. | 168 | * @priv_flags: Flags describing buffer object internal state. |
175 | * @vm_rb: Rb node for the vm rb tree. | 169 | * @vm_rb: Rb node for the vm rb tree. |
@@ -209,10 +203,9 @@ struct ttm_buffer_object { | |||
209 | 203 | ||
210 | struct kref kref; | 204 | struct kref kref; |
211 | struct kref list_kref; | 205 | struct kref list_kref; |
212 | wait_queue_head_t event_queue; | ||
213 | 206 | ||
214 | /** | 207 | /** |
215 | * Members protected by the bo::reserved lock. | 208 | * Members protected by the bo::resv::reserved lock. |
216 | */ | 209 | */ |
217 | 210 | ||
218 | struct ttm_mem_reg mem; | 211 | struct ttm_mem_reg mem; |
@@ -234,15 +227,6 @@ struct ttm_buffer_object { | |||
234 | struct list_head ddestroy; | 227 | struct list_head ddestroy; |
235 | struct list_head swap; | 228 | struct list_head swap; |
236 | struct list_head io_reserve_lru; | 229 | struct list_head io_reserve_lru; |
237 | unsigned long val_seq; | ||
238 | bool seq_valid; | ||
239 | |||
240 | /** | ||
241 | * Members protected by the bdev::lru_lock | ||
242 | * only when written to. | ||
243 | */ | ||
244 | |||
245 | atomic_t reserved; | ||
246 | 230 | ||
247 | /** | 231 | /** |
248 | * Members protected by struct buffer_object_device::fence_lock | 232 | * Members protected by struct buffer_object_device::fence_lock |
@@ -272,6 +256,9 @@ struct ttm_buffer_object { | |||
272 | uint32_t cur_placement; | 256 | uint32_t cur_placement; |
273 | 257 | ||
274 | struct sg_table *sg; | 258 | struct sg_table *sg; |
259 | |||
260 | struct reservation_object *resv; | ||
261 | struct reservation_object ttm_resv; | ||
275 | }; | 262 | }; |
276 | 263 | ||
277 | /** | 264 | /** |
@@ -736,7 +723,7 @@ extern void ttm_bo_swapout_all(struct ttm_bo_device *bdev); | |||
736 | */ | 723 | */ |
737 | static inline bool ttm_bo_is_reserved(struct ttm_buffer_object *bo) | 724 | static inline bool ttm_bo_is_reserved(struct ttm_buffer_object *bo) |
738 | { | 725 | { |
739 | return atomic_read(&bo->reserved); | 726 | return ww_mutex_is_locked(&bo->resv->lock); |
740 | } | 727 | } |
741 | 728 | ||
742 | #endif | 729 | #endif |
diff --git a/include/drm/ttm/ttm_execbuf_util.h b/include/drm/ttm/ttm_execbuf_util.h index ba71ef91f4d5..ec8a1d306510 100644 --- a/include/drm/ttm/ttm_execbuf_util.h +++ b/include/drm/ttm/ttm_execbuf_util.h | |||
@@ -33,7 +33,6 @@ | |||
33 | 33 | ||
34 | #include <ttm/ttm_bo_api.h> | 34 | #include <ttm/ttm_bo_api.h> |
35 | #include <linux/list.h> | 35 | #include <linux/list.h> |
36 | #include <linux/reservation.h> | ||
37 | 36 | ||
38 | /** | 37 | /** |
39 | * struct ttm_validate_buffer | 38 | * struct ttm_validate_buffer |