Commit e84fcb95 authored by Stefan Schake's avatar Stefan Schake Committed by Eric Anholt

drm/vc4: Export fence through syncobj

Allow specifying a syncobj on render job submission where we store the
fence for the job. This gives userland flexible access to the fence.

v2: Use 0 as invalid syncobj to drop flag (Eric)
    Don't reintroduce the padding (Eric)
Signed-off-by: default avatarStefan Schake <stschake@gmail.com>
Signed-off-by: default avatarEric Anholt <eric@anholt.net>
Reviewed-by: default avatarEric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/1524607427-12876-3-git-send-email-stschake@gmail.com
parent 818f5c8f
...@@ -656,7 +656,8 @@ vc4_lock_bo_reservations(struct drm_device *dev, ...@@ -656,7 +656,8 @@ vc4_lock_bo_reservations(struct drm_device *dev,
*/ */
static int static int
vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec, vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec,
struct ww_acquire_ctx *acquire_ctx) struct ww_acquire_ctx *acquire_ctx,
struct drm_syncobj *out_sync)
{ {
struct vc4_dev *vc4 = to_vc4_dev(dev); struct vc4_dev *vc4 = to_vc4_dev(dev);
struct vc4_exec_info *renderjob; struct vc4_exec_info *renderjob;
...@@ -679,6 +680,9 @@ vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec, ...@@ -679,6 +680,9 @@ vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec,
fence->seqno = exec->seqno; fence->seqno = exec->seqno;
exec->fence = &fence->base; exec->fence = &fence->base;
if (out_sync)
drm_syncobj_replace_fence(out_sync, exec->fence);
vc4_update_bo_seqnos(exec, seqno); vc4_update_bo_seqnos(exec, seqno);
vc4_unlock_bo_reservations(dev, exec, acquire_ctx); vc4_unlock_bo_reservations(dev, exec, acquire_ctx);
...@@ -1114,6 +1118,7 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data, ...@@ -1114,6 +1118,7 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
struct vc4_dev *vc4 = to_vc4_dev(dev); struct vc4_dev *vc4 = to_vc4_dev(dev);
struct vc4_file *vc4file = file_priv->driver_priv; struct vc4_file *vc4file = file_priv->driver_priv;
struct drm_vc4_submit_cl *args = data; struct drm_vc4_submit_cl *args = data;
struct drm_syncobj *out_sync = NULL;
struct vc4_exec_info *exec; struct vc4_exec_info *exec;
struct ww_acquire_ctx acquire_ctx; struct ww_acquire_ctx acquire_ctx;
struct dma_fence *in_fence; struct dma_fence *in_fence;
...@@ -1201,12 +1206,33 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data, ...@@ -1201,12 +1206,33 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
if (ret) if (ret)
goto fail; goto fail;
if (args->out_sync) {
out_sync = drm_syncobj_find(file_priv, args->out_sync);
if (!out_sync) {
ret = -EINVAL;
goto fail;
}
/* We replace the fence in out_sync in vc4_queue_submit since
* the render job could execute immediately after that call.
* If it finishes before our ioctl processing resumes the
* render job fence could already have been freed.
*/
}
/* Clear this out of the struct we'll be putting in the queue, /* Clear this out of the struct we'll be putting in the queue,
* since it's part of our stack. * since it's part of our stack.
*/ */
exec->args = NULL; exec->args = NULL;
ret = vc4_queue_submit(dev, exec, &acquire_ctx); ret = vc4_queue_submit(dev, exec, &acquire_ctx, out_sync);
/* The syncobj isn't part of the exec data and we need to free our
* reference even if job submission failed.
*/
if (out_sync)
drm_syncobj_put(out_sync);
if (ret) if (ret)
goto fail; goto fail;
......
...@@ -187,6 +187,12 @@ struct drm_vc4_submit_cl { ...@@ -187,6 +187,12 @@ struct drm_vc4_submit_cl {
* will not start until the syncobj is signaled. 0 means ignore. * will not start until the syncobj is signaled. 0 means ignore.
*/ */
__u32 in_sync; __u32 in_sync;
/* Syncobj handle to export fence to. If set, the fence in the syncobj
* will be replaced with a fence that signals upon completion of this
* render job. 0 means ignore.
*/
__u32 out_sync;
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment