aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm
diff options
context:
space:
mode:
authorMarek Olšák <maraeo@gmail.com>2011-08-13 16:32:11 -0400
committerDave Airlie <airlied@redhat.com>2011-08-31 14:25:35 -0400
commitdfadbbdb57b3f2bb33e14f129a43047c6f0caefa (patch)
tree0a6e00b5fa56d9f5a5b4dc833e3057e4660efd1c /include/drm
parentb464e9a25c27884eb8ee2c2bb904ec50bd3990ea (diff)
drm/ttm: add a way to bo_wait for either the last read or last write
Sometimes we want to know whether a buffer is busy and wait for it (bo_wait). However, sometimes it would be more useful to be able to query whether a buffer is busy and being either read or written, and wait until it's stopped being either read or written. The point of this is to be able to avoid unnecessary waiting, e.g. if a GPU has written something to a buffer and is now reading that buffer, and a CPU wants to map that buffer for read, it needs to only wait for the last write. If there were no write, there wouldn't be any waiting needed. This, or course, requires user space drivers to send read/write flags with each relocation (like we have read/write domains in radeon, so we can actually use those for something useful now). Now how this patch works: The read/write flags should passed to ttm_validate_buffer. TTM maintains separate sync objects of the last read and write for each buffer, in addition to the sync object of the last use of a buffer. ttm_bo_wait then operates with one the sync objects. Signed-off-by: Marek Olšák <maraeo@gmail.com> Reviewed-by: Jerome Glisse <jglisse@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'include/drm')
-rw-r--r--include/drm/ttm/ttm_bo_api.h16
-rw-r--r--include/drm/ttm/ttm_execbuf_util.h6
2 files changed, 20 insertions, 2 deletions
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 42e346985186..da957bf3fe44 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -44,6 +44,11 @@ struct ttm_bo_device;
44 44
45struct drm_mm_node; 45struct drm_mm_node;
46 46
47enum ttm_buffer_usage {
48 TTM_USAGE_READ = 1,
49 TTM_USAGE_WRITE = 2,
50 TTM_USAGE_READWRITE = TTM_USAGE_READ | TTM_USAGE_WRITE
51};
47 52
48/** 53/**
49 * struct ttm_placement 54 * struct ttm_placement
@@ -174,7 +179,10 @@ struct ttm_tt;
174 * the bo_device::lru_lock. 179 * the bo_device::lru_lock.
175 * @reserved: Deadlock-free lock used for synchronization state transitions. 180 * @reserved: Deadlock-free lock used for synchronization state transitions.
176 * @sync_obj_arg: Opaque argument to synchronization object function. 181 * @sync_obj_arg: Opaque argument to synchronization object function.
177 * @sync_obj: Pointer to a synchronization object. 182 * @sync_obj: Pointer to a synchronization object of a last read or write,
183 * whichever is later.
184 * @sync_obj_read: Pointer to a synchronization object of a last read.
185 * @sync_obj_write: Pointer to a synchronization object of a last write.
178 * @priv_flags: Flags describing buffer object internal state. 186 * @priv_flags: Flags describing buffer object internal state.
179 * @vm_rb: Rb node for the vm rb tree. 187 * @vm_rb: Rb node for the vm rb tree.
180 * @vm_node: Address space manager node. 188 * @vm_node: Address space manager node.
@@ -258,6 +266,8 @@ struct ttm_buffer_object {
258 266
259 void *sync_obj_arg; 267 void *sync_obj_arg;
260 void *sync_obj; 268 void *sync_obj;
269 void *sync_obj_read;
270 void *sync_obj_write;
261 unsigned long priv_flags; 271 unsigned long priv_flags;
262 272
263 /** 273 /**
@@ -325,6 +335,7 @@ ttm_bo_reference(struct ttm_buffer_object *bo)
325 * @bo: The buffer object. 335 * @bo: The buffer object.
326 * @interruptible: Use interruptible wait. 336 * @interruptible: Use interruptible wait.
327 * @no_wait: Return immediately if buffer is busy. 337 * @no_wait: Return immediately if buffer is busy.
338 * @usage: Whether to wait for the last read and/or the last write.
328 * 339 *
329 * This function must be called with the bo::mutex held, and makes 340 * This function must be called with the bo::mutex held, and makes
330 * sure any previous rendering to the buffer is completed. 341 * sure any previous rendering to the buffer is completed.
@@ -334,7 +345,8 @@ ttm_bo_reference(struct ttm_buffer_object *bo)
334 * Returns -ERESTARTSYS if interrupted by a signal. 345 * Returns -ERESTARTSYS if interrupted by a signal.
335 */ 346 */
336extern int ttm_bo_wait(struct ttm_buffer_object *bo, bool lazy, 347extern int ttm_bo_wait(struct ttm_buffer_object *bo, bool lazy,
337 bool interruptible, bool no_wait); 348 bool interruptible, bool no_wait,
349 enum ttm_buffer_usage usage);
338/** 350/**
339 * ttm_bo_validate 351 * ttm_bo_validate
340 * 352 *
diff --git a/include/drm/ttm/ttm_execbuf_util.h b/include/drm/ttm/ttm_execbuf_util.h
index 26cc7f9ffa41..375f29902295 100644
--- a/include/drm/ttm/ttm_execbuf_util.h
+++ b/include/drm/ttm/ttm_execbuf_util.h
@@ -41,20 +41,26 @@
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 * @usage Indicates how @bo is used by the device.
44 * @reserved: Indicates whether @bo has been reserved for validation. 45 * @reserved: Indicates whether @bo has been reserved for validation.
45 * @removed: Indicates whether @bo has been removed from lru lists. 46 * @removed: Indicates whether @bo has been removed from lru lists.
46 * @put_count: Number of outstanding references on bo::list_kref. 47 * @put_count: Number of outstanding references on bo::list_kref.
47 * @old_sync_obj: Pointer to a sync object about to be unreferenced 48 * @old_sync_obj: Pointer to a sync object about to be unreferenced
49 * @old_sync_obj_read: Pointer to a read sync object about to be unreferenced.
50 * @old_sync_obj_write: Pointer to a write sync object about to be unreferenced.
48 */ 51 */
49 52
50struct ttm_validate_buffer { 53struct ttm_validate_buffer {
51 struct list_head head; 54 struct list_head head;
52 struct ttm_buffer_object *bo; 55 struct ttm_buffer_object *bo;
53 void *new_sync_obj_arg; 56 void *new_sync_obj_arg;
57 enum ttm_buffer_usage usage;
54 bool reserved; 58 bool reserved;
55 bool removed; 59 bool removed;
56 int put_count; 60 int put_count;
57 void *old_sync_obj; 61 void *old_sync_obj;
62 void *old_sync_obj_read;
63 void *old_sync_obj_write;
58}; 64};
59 65
60/** 66/**