diff options
| author | Dave Airlie <airlied@redhat.com> | 2010-11-21 22:24:40 -0500 |
|---|---|---|
| committer | Dave Airlie <airlied@redhat.com> | 2010-11-21 22:24:40 -0500 |
| commit | d6ea88865d3e5b0c62040531310c1f2c6a994f46 (patch) | |
| tree | b80a7cbc6eeab003b412e3037fd335ce9d572f67 /include/drm/ttm | |
| parent | 27641c3f003e7f3b6585c01d8a788883603eb262 (diff) | |
drm/ttm: Add a bo list reserve fastpath (v2)
Makes it possible to reserve a list of buffer objects with a single
spin lock / unlock if there is no contention.
Should improve cpu usage on SMP kernels.
v2: Initialize private list members on reserve and don't call
ttm_bo_list_ref_sub() with zero put_count.
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.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 | 38 | ||||
| -rw-r--r-- | include/drm/ttm/ttm_bo_driver.h | 14 | ||||
| -rw-r--r-- | include/drm/ttm/ttm_execbuf_util.h | 6 |
3 files changed, 57 insertions, 1 deletions
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index beafc156a53..b0fc9c12554 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h | |||
| @@ -364,6 +364,44 @@ extern int ttm_bo_validate(struct ttm_buffer_object *bo, | |||
| 364 | */ | 364 | */ |
| 365 | extern void ttm_bo_unref(struct ttm_buffer_object **bo); | 365 | extern void ttm_bo_unref(struct ttm_buffer_object **bo); |
| 366 | 366 | ||
| 367 | |||
| 368 | /** | ||
| 369 | * ttm_bo_list_ref_sub | ||
| 370 | * | ||
| 371 | * @bo: The buffer object. | ||
| 372 | * @count: The number of references with which to decrease @bo::list_kref; | ||
| 373 | * @never_free: The refcount should not reach zero with this operation. | ||
| 374 | * | ||
| 375 | * Release @count lru list references to this buffer object. | ||
| 376 | */ | ||
| 377 | extern void ttm_bo_list_ref_sub(struct ttm_buffer_object *bo, int count, | ||
| 378 | bool never_free); | ||
| 379 | |||
| 380 | /** | ||
| 381 | * ttm_bo_add_to_lru | ||
| 382 | * | ||
| 383 | * @bo: The buffer object. | ||
| 384 | * | ||
| 385 | * Add this bo to the relevant mem type lru and, if it's backed by | ||
| 386 | * system pages (ttms) to the swap list. | ||
| 387 | * This function must be called with struct ttm_bo_global::lru_lock held, and | ||
| 388 | * is typically called immediately prior to unreserving a bo. | ||
| 389 | */ | ||
| 390 | extern void ttm_bo_add_to_lru(struct ttm_buffer_object *bo); | ||
| 391 | |||
| 392 | /** | ||
| 393 | * ttm_bo_del_from_lru | ||
| 394 | * | ||
| 395 | * @bo: The buffer object. | ||
| 396 | * | ||
| 397 | * Remove this bo from all lru lists used to lookup and reserve an object. | ||
| 398 | * This function must be called with struct ttm_bo_global::lru_lock held, | ||
| 399 | * and is usually called just immediately after the bo has been reserved to | ||
| 400 | * avoid recursive reservation from lru lists. | ||
| 401 | */ | ||
| 402 | extern int ttm_bo_del_from_lru(struct ttm_buffer_object *bo); | ||
| 403 | |||
| 404 | |||
| 367 | /** | 405 | /** |
| 368 | * ttm_bo_lock_delayed_workqueue | 406 | * ttm_bo_lock_delayed_workqueue |
| 369 | * | 407 | * |
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 8e0c848326b..95068e6024d 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h | |||
| @@ -864,6 +864,20 @@ extern int ttm_bo_reserve(struct ttm_buffer_object *bo, | |||
| 864 | bool interruptible, | 864 | bool interruptible, |
| 865 | bool no_wait, bool use_sequence, uint32_t sequence); | 865 | bool no_wait, bool use_sequence, uint32_t sequence); |
| 866 | 866 | ||
| 867 | |||
| 868 | /** | ||
| 869 | * ttm_bo_reserve_locked: | ||
| 870 | * | ||
| 871 | * Similar to ttm_bo_reserve, but must be called with the glob::lru_lock | ||
| 872 | * spinlock held, and will not remove reserved buffers from the lru lists. | ||
| 873 | * The function may release the LRU spinlock if it needs to sleep. | ||
| 874 | */ | ||
| 875 | |||
| 876 | extern int ttm_bo_reserve_locked(struct ttm_buffer_object *bo, | ||
| 877 | bool interruptible, | ||
| 878 | bool no_wait, bool use_sequence, | ||
| 879 | uint32_t sequence); | ||
| 880 | |||
| 867 | /** | 881 | /** |
| 868 | * ttm_bo_unreserve | 882 | * ttm_bo_unreserve |
| 869 | * | 883 | * |
diff --git a/include/drm/ttm/ttm_execbuf_util.h b/include/drm/ttm/ttm_execbuf_util.h index cd2c475da9e..fd09b843897 100644 --- a/include/drm/ttm/ttm_execbuf_util.h +++ b/include/drm/ttm/ttm_execbuf_util.h | |||
| @@ -41,7 +41,9 @@ | |||
| 41 | * @bo: refcounted buffer object pointer. | 41 | * @bo: refcounted buffer object pointer. |
| 42 | * @new_sync_obj_arg: New sync_obj_arg for @bo, to be used once | 42 | * @new_sync_obj_arg: New sync_obj_arg for @bo, to be used once |
| 43 | * adding a new sync object. | 43 | * adding a new sync object. |
| 44 | * @reservied: Indicates whether @bo has been reserved for validation. | 44 | * @reserved: Indicates whether @bo has been reserved for validation. |
| 45 | * @removed: Indicates whether @bo has been removed from lru lists. | ||
| 46 | * @put_count: Number of outstanding references on bo::list_kref. | ||
| 45 | */ | 47 | */ |
| 46 | 48 | ||
| 47 | struct ttm_validate_buffer { | 49 | struct ttm_validate_buffer { |
| @@ -49,6 +51,8 @@ struct ttm_validate_buffer { | |||
| 49 | struct ttm_buffer_object *bo; | 51 | struct ttm_buffer_object *bo; |
| 50 | void *new_sync_obj_arg; | 52 | void *new_sync_obj_arg; |
| 51 | bool reserved; | 53 | bool reserved; |
| 54 | bool removed; | ||
| 55 | int put_count; | ||
| 52 | }; | 56 | }; |
| 53 | 57 | ||
| 54 | /** | 58 | /** |
