aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm/ttm
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 /include/drm/ttm
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 'include/drm/ttm')
-rw-r--r--include/drm/ttm/ttm_bo_api.h6
-rw-r--r--include/drm/ttm/ttm_bo_driver.h3
2 files changed, 5 insertions, 4 deletions
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index b0fc9c12554b..edacd483c59c 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -154,7 +154,6 @@ struct ttm_tt;
154 * keeps one refcount. When this refcount reaches zero, 154 * keeps one refcount. When this refcount reaches zero,
155 * the object is destroyed. 155 * the object is destroyed.
156 * @event_queue: Queue for processes waiting on buffer object status change. 156 * @event_queue: Queue for processes waiting on buffer object status change.
157 * @lock: spinlock protecting mostly synchronization members.
158 * @mem: structure describing current placement. 157 * @mem: structure describing current placement.
159 * @persistant_swap_storage: Usually the swap storage is deleted for buffers 158 * @persistant_swap_storage: Usually the swap storage is deleted for buffers
160 * 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
@@ -213,7 +212,6 @@ struct ttm_buffer_object {
213 struct kref kref; 212 struct kref kref;
214 struct kref list_kref; 213 struct kref list_kref;
215 wait_queue_head_t event_queue; 214 wait_queue_head_t event_queue;
216 spinlock_t lock;
217 215
218 /** 216 /**
219 * Members protected by the bo::reserved lock. 217 * Members protected by the bo::reserved lock.
@@ -248,10 +246,10 @@ struct ttm_buffer_object {
248 atomic_t reserved; 246 atomic_t reserved;
249 247
250 /** 248 /**
251 * Members protected by the bo::lock 249 * Members protected by struct buffer_object_device::fence_lock
252 * In addition, setting sync_obj to anything else 250 * In addition, setting sync_obj to anything else
253 * than NULL requires bo::reserved to be held. This allows for 251 * than NULL requires bo::reserved to be held. This allows for
254 * checking NULL while reserved but not holding bo::lock. 252 * checking NULL while reserved but not holding the mentioned lock.
255 */ 253 */
256 254
257 void *sync_obj_arg; 255 void *sync_obj_arg;
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 1e25a40c688e..ca8131e98300 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -510,6 +510,8 @@ struct ttm_bo_global {
510 * 510 *
511 * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver. 511 * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver.
512 * @man: An array of mem_type_managers. 512 * @man: An array of mem_type_managers.
513 * @fence_lock: Protects the synchronizing members on *all* bos belonging
514 * to this device.
513 * @addr_space_mm: Range manager for the device address space. 515 * @addr_space_mm: Range manager for the device address space.
514 * lru_lock: Spinlock that protects the buffer+device lru lists and 516 * lru_lock: Spinlock that protects the buffer+device lru lists and
515 * ddestroy lists. 517 * ddestroy lists.
@@ -531,6 +533,7 @@ struct ttm_bo_device {
531 struct ttm_bo_driver *driver; 533 struct ttm_bo_driver *driver;
532 rwlock_t vm_lock; 534 rwlock_t vm_lock;
533 struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES]; 535 struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES];
536 spinlock_t fence_lock;
534 /* 537 /*
535 * Protected by the vm lock. 538 * Protected by the vm lock.
536 */ 539 */