summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Clark <rob@ti.com>2012-06-25 13:52:45 -0500
committerXavier Boudet <x-boudet@ti.com>2012-07-10 17:26:54 +0200
commitc8361bb824945018226047b82d6cad9bb4e58f6b (patch)
treebc851927f7b08a22a23fde5a149c6dbb16f4103f
parent03ab7d1e21d6516738ece9e46a3b2bd14ce15c0b (diff)
omapdce: synchronize with GPU
If a buffer is passed in which is still being read by the GPU, wait for it to become writable. If userspace takes care not to pass in an in-use buffer, this will have no effect, but if userspace does not know to synchronize with the GPU this will prevent rendering artifacts resulting from writing a future frame into a buffer the GPU is still reading. Signed-off-by: Rob Clark <rob@ti.com>
-rw-r--r--drivers/staging/omapdce/dce.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/staging/omapdce/dce.c b/drivers/staging/omapdce/dce.c
index f7c351a81fad..52036cb531d5 100644
--- a/drivers/staging/omapdce/dce.c
+++ b/drivers/staging/omapdce/dce.c
@@ -676,6 +676,7 @@ static inline struct drm_gem_object * handle_single_buf_desc(
struct drm_gem_object *obj;
uint32_t flags;
int32_t offset = 0;
+ int ret;
/* maybe support remapping user ptrs later on.. */
if (desc->mem_type != XDM_MEMTYPE_BO &&
@@ -724,6 +725,21 @@ static inline struct drm_gem_object * handle_single_buf_desc(
// know if the buffer is cached or not so we could set DATASYNC
// bit if needed..
+ /* if we are using the GPU to render, it might still be reading
+ * from the buffer.. we don't want to overwrite it yet!
+ *
+ * Note: this is an interruptible wait, but in case we are
+ * interrupted the normal error cleanup paths (rpabort(), etc)
+ * will handle the cleanup
+ *
+ * Note: this is only for decoder output frames.. for encoder
+ * input frames, we don't care if anyone is reading, use
+ * instead OMAP_GEM_READ ad the access mode..
+ */
+ ret = omap_gem_op_sync(obj, OMAP_GEM_WRITE);
+ if (ret)
+ return ERR_PTR(ret);
+
return obj;
}