aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ttm/ttm_bo_util.c
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom@vmware.com>2010-11-17 07:28:29 -0500
committerDave Airlie <airlied@redhat.com>2010-11-21 22:25:18 -0500
commit702adba22433c175e8429a47760f35ca16caf1cd (patch)
treea9c6a1ad8ebaf9970a87b7047357b6d7232b70e6 /drivers/gpu/drm/ttm/ttm_bo_util.c
parent96726fe50feae74812a2ccf5d5da23cb01c0a413 (diff)
drm/ttm/radeon/nouveau: Kill the bo lock in favour of a bo device fence_lock
The bo lock used only to protect the bo sync object members, and since it is a per bo lock, fencing a buffer list will see a lot of locks and unlocks. Replace it with a per-device lock that protects the sync object members on *all* bos. Reading and setting these members will always be very quick, so the risc of heavy lock contention is microscopic. Note that waiting for sync objects will always take place outside of this lock. The bo device fence lock will eventually be replaced with a seqlock / rcu mechanism so we can determine that a bo is idle under a rcu / read seqlock. However this change will allow us to batch fencing and unreserving of buffers with a minimal amount of locking. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Jerome Glisse <j.glisse@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/ttm/ttm_bo_util.c')
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo_util.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 3106d5bcce32..4b75133d6606 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -337,7 +337,6 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
337 * TODO: Explicit member copy would probably be better here. 337 * TODO: Explicit member copy would probably be better here.
338 */ 338 */
339 339
340 spin_lock_init(&fbo->lock);
341 init_waitqueue_head(&fbo->event_queue); 340 init_waitqueue_head(&fbo->event_queue);
342 INIT_LIST_HEAD(&fbo->ddestroy); 341 INIT_LIST_HEAD(&fbo->ddestroy);
343 INIT_LIST_HEAD(&fbo->lru); 342 INIT_LIST_HEAD(&fbo->lru);
@@ -520,7 +519,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
520 struct ttm_buffer_object *ghost_obj; 519 struct ttm_buffer_object *ghost_obj;
521 void *tmp_obj = NULL; 520 void *tmp_obj = NULL;
522 521
523 spin_lock(&bo->lock); 522 spin_lock(&bdev->fence_lock);
524 if (bo->sync_obj) { 523 if (bo->sync_obj) {
525 tmp_obj = bo->sync_obj; 524 tmp_obj = bo->sync_obj;
526 bo->sync_obj = NULL; 525 bo->sync_obj = NULL;
@@ -529,7 +528,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
529 bo->sync_obj_arg = sync_obj_arg; 528 bo->sync_obj_arg = sync_obj_arg;
530 if (evict) { 529 if (evict) {
531 ret = ttm_bo_wait(bo, false, false, false); 530 ret = ttm_bo_wait(bo, false, false, false);
532 spin_unlock(&bo->lock); 531 spin_unlock(&bdev->fence_lock);
533 if (tmp_obj) 532 if (tmp_obj)
534 driver->sync_obj_unref(&tmp_obj); 533 driver->sync_obj_unref(&tmp_obj);
535 if (ret) 534 if (ret)
@@ -552,7 +551,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo,
552 */ 551 */
553 552
554 set_bit(TTM_BO_PRIV_FLAG_MOVING, &bo->priv_flags); 553 set_bit(TTM_BO_PRIV_FLAG_MOVING, &bo->priv_flags);
555 spin_unlock(&bo->lock); 554 spin_unlock(&bdev->fence_lock);
556 if (tmp_obj) 555 if (tmp_obj)
557 driver->sync_obj_unref(&tmp_obj); 556 driver->sync_obj_unref(&tmp_obj);
558 557