All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] drm/vc4: Syncobj import export
@ 2018-04-21 22:50 Stefan Schake
  2018-04-21 22:50 ` [PATCH 1/4] drm/vc4: Enable syncobj support Stefan Schake
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Stefan Schake @ 2018-04-21 22:50 UTC (permalink / raw)
  To: eric; +Cc: airlied, linux-rpi-kernel, dri-devel, Stefan Schake

This series allows userspace to submit syncobj handles for importing
a fence to wait on or exporting the job fence as part of submission.

The primary use of this is to enable native fence fd support in Mesa.
Initial userspace implementation is under review and available here:

https://patchwork.freedesktop.org/series/42081/

Stefan Schake (4):
  drm/vc4: Enable syncobj support
  drm/vc4: Syncobj import support
  drm/vc4: Export fence through syncobj
  drm/vc4: Add parameter for syncobj support

 drivers/gpu/drm/vc4/vc4_drv.c |  4 ++-
 drivers/gpu/drm/vc4/vc4_drv.h |  2 ++
 drivers/gpu/drm/vc4/vc4_gem.c | 59 ++++++++++++++++++++++++++++++++++++++++---
 include/uapi/drm/vc4_drm.h    | 15 +++++++++++
 4 files changed, 76 insertions(+), 4 deletions(-)

-- 
2.14.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/4] drm/vc4: Enable syncobj support
  2018-04-21 22:50 [PATCH 0/4] drm/vc4: Syncobj import export Stefan Schake
@ 2018-04-21 22:50 ` Stefan Schake
  2018-04-21 22:50 ` [PATCH 2/4] drm/vc4: Syncobj import support Stefan Schake
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Stefan Schake @ 2018-04-21 22:50 UTC (permalink / raw)
  To: eric; +Cc: airlied, linux-rpi-kernel, dri-devel, Stefan Schake

This doesn't require any additional functionality from the driver but
is a prerequisite to userland calling the syncobj ioctls.

Signed-off-by: Stefan Schake <stschake@gmail.com>
---
 drivers/gpu/drm/vc4/vc4_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index 94b99c90425a..806c8004b793 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -175,7 +175,8 @@ static struct drm_driver vc4_drm_driver = {
 			    DRIVER_GEM |
 			    DRIVER_HAVE_IRQ |
 			    DRIVER_RENDER |
-			    DRIVER_PRIME),
+			    DRIVER_PRIME |
+			    DRIVER_SYNCOBJ),
 	.lastclose = drm_fb_helper_lastclose,
 	.open = vc4_open,
 	.postclose = vc4_close,
-- 
2.14.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] drm/vc4: Syncobj import support
  2018-04-21 22:50 [PATCH 0/4] drm/vc4: Syncobj import export Stefan Schake
  2018-04-21 22:50 ` [PATCH 1/4] drm/vc4: Enable syncobj support Stefan Schake
@ 2018-04-21 22:50 ` Stefan Schake
  2018-04-23 18:59   ` Eric Anholt
  2018-04-21 22:50 ` [PATCH 3/4] drm/vc4: Export fence through syncobj Stefan Schake
  2018-04-21 22:50 ` [PATCH 4/4] drm/vc4: Add parameter for syncobj support Stefan Schake
  3 siblings, 1 reply; 8+ messages in thread
From: Stefan Schake @ 2018-04-21 22:50 UTC (permalink / raw)
  To: eric; +Cc: airlied, linux-rpi-kernel, dri-devel, Stefan Schake

Allow userland to specify a syncobj that is waited on before a render job
starts processing.

Signed-off-by: Stefan Schake <stschake@gmail.com>
---
 drivers/gpu/drm/vc4/vc4_drv.h |  2 ++
 drivers/gpu/drm/vc4/vc4_gem.c | 33 +++++++++++++++++++++++++++------
 include/uapi/drm/vc4_drm.h    |  9 +++++----
 3 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
index 4288615b66a2..3105df99cb12 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.h
+++ b/drivers/gpu/drm/vc4/vc4_drv.h
@@ -10,6 +10,8 @@
 #include <drm/drmP.h>
 #include <drm/drm_encoder.h>
 #include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_syncobj.h>
+
 
 #include "uapi/drm/vc4_drm.h"
 
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
index 2107b0daf8ef..232363488125 100644
--- a/drivers/gpu/drm/vc4/vc4_gem.c
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
@@ -27,6 +27,7 @@
 #include <linux/device.h>
 #include <linux/io.h>
 #include <linux/sched/signal.h>
+#include <linux/dma-fence-array.h>
 
 #include "uapi/drm/vc4_drm.h"
 #include "vc4_drv.h"
@@ -1115,21 +1116,18 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
 	struct drm_vc4_submit_cl *args = data;
 	struct vc4_exec_info *exec;
 	struct ww_acquire_ctx acquire_ctx;
+	struct dma_fence *in_fence;
 	int ret = 0;
 
 	if ((args->flags & ~(VC4_SUBMIT_CL_USE_CLEAR_COLOR |
 			     VC4_SUBMIT_CL_FIXED_RCL_ORDER |
 			     VC4_SUBMIT_CL_RCL_ORDER_INCREASING_X |
-			     VC4_SUBMIT_CL_RCL_ORDER_INCREASING_Y)) != 0) {
+			     VC4_SUBMIT_CL_RCL_ORDER_INCREASING_Y |
+			     VC4_SUBMIT_CL_IMPORT_SYNCOBJ)) != 0) {
 		DRM_DEBUG("Unknown flags: 0x%02x\n", args->flags);
 		return -EINVAL;
 	}
 
-	if (args->pad2 != 0) {
-		DRM_DEBUG("->pad2 must be set to zero\n");
-		return -EINVAL;
-	}
-
 	exec = kcalloc(1, sizeof(*exec), GFP_KERNEL);
 	if (!exec) {
 		DRM_ERROR("malloc failure on exec struct\n");
@@ -1164,6 +1162,29 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
 		}
 	}
 
+	if (args->flags & VC4_SUBMIT_CL_IMPORT_SYNCOBJ) {
+		ret = drm_syncobj_find_fence(file_priv, args->in_sync,
+					     &in_fence);
+		if (ret)
+			goto fail;
+
+		/* When the fence (or fence array) is exclusively from our
+		 * context we can skip the wait since jobs are executed in
+		 * order of their submission through this ioctl and this can
+		 * only have fences from a prior job.
+		 */
+		if (!dma_fence_match_context(in_fence,
+					     vc4->dma_fence_context)) {
+			ret = dma_fence_wait(in_fence, true);
+			if (ret) {
+				dma_fence_put(in_fence);
+				goto fail;
+			}
+		}
+
+		dma_fence_put(in_fence);
+	}
+
 	if (exec->args->bin_cl_size != 0) {
 		ret = vc4_get_bcl(dev, exec);
 		if (ret)
diff --git a/include/uapi/drm/vc4_drm.h b/include/uapi/drm/vc4_drm.h
index b95a0e11cb07..389f21931c25 100644
--- a/include/uapi/drm/vc4_drm.h
+++ b/include/uapi/drm/vc4_drm.h
@@ -173,6 +173,7 @@ struct drm_vc4_submit_cl {
 #define VC4_SUBMIT_CL_FIXED_RCL_ORDER			(1 << 1)
 #define VC4_SUBMIT_CL_RCL_ORDER_INCREASING_X		(1 << 2)
 #define VC4_SUBMIT_CL_RCL_ORDER_INCREASING_Y		(1 << 3)
+#define VC4_SUBMIT_CL_IMPORT_SYNCOBJ			(1 << 4)
 	__u32 flags;
 
 	/* Returned value of the seqno of this render job (for the
@@ -183,11 +184,11 @@ struct drm_vc4_submit_cl {
 	/* ID of the perfmon to attach to this job. 0 means no perfmon. */
 	__u32 perfmonid;
 
-	/* Unused field to align this struct on 64 bits. Must be set to 0.
-	 * If one ever needs to add an u32 field to this struct, this field
-	 * can be used.
+	/* Syncobj handle to wait on. Set together with IMPORT_SYNCOBJ flag.
+	 * If set, processing of this render job will not start until the
+	 * syncobj is signalled.
 	 */
-	__u32 pad2;
+	__u32 in_sync;
 };
 
 /**
-- 
2.14.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] drm/vc4: Export fence through syncobj
  2018-04-21 22:50 [PATCH 0/4] drm/vc4: Syncobj import export Stefan Schake
  2018-04-21 22:50 ` [PATCH 1/4] drm/vc4: Enable syncobj support Stefan Schake
  2018-04-21 22:50 ` [PATCH 2/4] drm/vc4: Syncobj import support Stefan Schake
@ 2018-04-21 22:50 ` Stefan Schake
  2018-04-23 19:01   ` Eric Anholt
  2018-04-21 22:50 ` [PATCH 4/4] drm/vc4: Add parameter for syncobj support Stefan Schake
  3 siblings, 1 reply; 8+ messages in thread
From: Stefan Schake @ 2018-04-21 22:50 UTC (permalink / raw)
  To: eric; +Cc: airlied, linux-rpi-kernel, dri-devel, Stefan Schake

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

Signed-off-by: Stefan Schake <stschake@gmail.com>
---
 drivers/gpu/drm/vc4/vc4_gem.c | 38 +++++++++++++++++++++++++++++++++++---
 include/uapi/drm/vc4_drm.h    | 13 +++++++++++++
 2 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
index 232363488125..b39515a4ddcb 100644
--- a/drivers/gpu/drm/vc4/vc4_gem.c
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
@@ -656,7 +656,8 @@ vc4_lock_bo_reservations(struct drm_device *dev,
  */
 static int
 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_exec_info *renderjob;
@@ -679,6 +680,9 @@ vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec,
 	fence->seqno = exec->seqno;
 	exec->fence = &fence->base;
 
+	if (out_sync)
+		drm_syncobj_replace_fence(out_sync, exec->fence);
+
 	vc4_update_bo_seqnos(exec, seqno);
 
 	vc4_unlock_bo_reservations(dev, exec, acquire_ctx);
@@ -1114,6 +1118,7 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
 	struct vc4_dev *vc4 = to_vc4_dev(dev);
 	struct vc4_file *vc4file = file_priv->driver_priv;
 	struct drm_vc4_submit_cl *args = data;
+	struct drm_syncobj *out_sync = NULL;
 	struct vc4_exec_info *exec;
 	struct ww_acquire_ctx acquire_ctx;
 	struct dma_fence *in_fence;
@@ -1123,11 +1128,17 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
 			     VC4_SUBMIT_CL_FIXED_RCL_ORDER |
 			     VC4_SUBMIT_CL_RCL_ORDER_INCREASING_X |
 			     VC4_SUBMIT_CL_RCL_ORDER_INCREASING_Y |
-			     VC4_SUBMIT_CL_IMPORT_SYNCOBJ)) != 0) {
+			     VC4_SUBMIT_CL_IMPORT_SYNCOBJ |
+			     VC4_SUBMIT_CL_EXPORT_SYNCOBJ)) != 0) {
 		DRM_DEBUG("Unknown flags: 0x%02x\n", args->flags);
 		return -EINVAL;
 	}
 
+	if (args->pad2 != 0) {
+		DRM_DEBUG("->pad2 must be set to zero\n");
+		return -EINVAL;
+	}
+
 	exec = kcalloc(1, sizeof(*exec), GFP_KERNEL);
 	if (!exec) {
 		DRM_ERROR("malloc failure on exec struct\n");
@@ -1202,12 +1213,33 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
 	if (ret)
 		goto fail;
 
+	if (args->flags & VC4_SUBMIT_CL_EXPORT_SYNCOBJ) {
+		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,
 	 * since it's part of our stack.
 	 */
 	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)
 		goto fail;
 
diff --git a/include/uapi/drm/vc4_drm.h b/include/uapi/drm/vc4_drm.h
index 389f21931c25..3a2ef9b5b60b 100644
--- a/include/uapi/drm/vc4_drm.h
+++ b/include/uapi/drm/vc4_drm.h
@@ -174,6 +174,7 @@ struct drm_vc4_submit_cl {
 #define VC4_SUBMIT_CL_RCL_ORDER_INCREASING_X		(1 << 2)
 #define VC4_SUBMIT_CL_RCL_ORDER_INCREASING_Y		(1 << 3)
 #define VC4_SUBMIT_CL_IMPORT_SYNCOBJ			(1 << 4)
+#define VC4_SUBMIT_CL_EXPORT_SYNCOBJ			(1 << 5)
 	__u32 flags;
 
 	/* Returned value of the seqno of this render job (for the
@@ -189,6 +190,18 @@ struct drm_vc4_submit_cl {
 	 * syncobj is signalled.
 	 */
 	__u32 in_sync;
+
+	/* Syncobj handle to export fence to. Set together with EXPORT_SYNCOBJ
+	 * flag. If set, the fence in the syncobj will be replaced with a fence
+	 * that signals upon completion of this render job.
+	 */
+	__u32 out_sync;
+
+	/* Unused field to align this struct on 64 bits. Must be set to 0.
+	 * If one ever needs to add an u32 field to this struct, this field
+	 * can be used.
+	 */
+	__u32 pad2;
 };
 
 /**
-- 
2.14.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] drm/vc4: Add parameter for syncobj support
  2018-04-21 22:50 [PATCH 0/4] drm/vc4: Syncobj import export Stefan Schake
                   ` (2 preceding siblings ...)
  2018-04-21 22:50 ` [PATCH 3/4] drm/vc4: Export fence through syncobj Stefan Schake
@ 2018-04-21 22:50 ` Stefan Schake
  2018-04-23 19:05   ` Eric Anholt
  3 siblings, 1 reply; 8+ messages in thread
From: Stefan Schake @ 2018-04-21 22:50 UTC (permalink / raw)
  To: eric; +Cc: airlied, linux-rpi-kernel, dri-devel, Stefan Schake

This allows runtime detection of syncobj submission support.

Signed-off-by: Stefan Schake <stschake@gmail.com>
---
 drivers/gpu/drm/vc4/vc4_drv.c | 1 +
 include/uapi/drm/vc4_drm.h    | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index 806c8004b793..4e2ae2a9a164 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -102,6 +102,7 @@ static int vc4_get_param_ioctl(struct drm_device *dev, void *data,
 	case DRM_VC4_PARAM_SUPPORTS_FIXED_RCL_ORDER:
 	case DRM_VC4_PARAM_SUPPORTS_MADVISE:
 	case DRM_VC4_PARAM_SUPPORTS_PERFMON:
+	case DRM_VC4_PARAM_SUPPORTS_SYNCOBJ:
 		args->value = true;
 		break;
 	default:
diff --git a/include/uapi/drm/vc4_drm.h b/include/uapi/drm/vc4_drm.h
index 3a2ef9b5b60b..6f81cf05f7a3 100644
--- a/include/uapi/drm/vc4_drm.h
+++ b/include/uapi/drm/vc4_drm.h
@@ -338,6 +338,7 @@ struct drm_vc4_get_hang_state {
 #define DRM_VC4_PARAM_SUPPORTS_FIXED_RCL_ORDER	6
 #define DRM_VC4_PARAM_SUPPORTS_MADVISE		7
 #define DRM_VC4_PARAM_SUPPORTS_PERFMON		8
+#define DRM_VC4_PARAM_SUPPORTS_SYNCOBJ		9
 
 struct drm_vc4_get_param {
 	__u32 param;
-- 
2.14.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] drm/vc4: Syncobj import support
  2018-04-21 22:50 ` [PATCH 2/4] drm/vc4: Syncobj import support Stefan Schake
@ 2018-04-23 18:59   ` Eric Anholt
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Anholt @ 2018-04-23 18:59 UTC (permalink / raw)
  Cc: airlied, linux-rpi-kernel, dri-devel, Stefan Schake


[-- Attachment #1.1: Type: text/plain, Size: 3279 bytes --]

Stefan Schake <stschake@gmail.com> writes:

> Allow userland to specify a syncobj that is waited on before a render job
> starts processing.
>
> Signed-off-by: Stefan Schake <stschake@gmail.com>
> ---
>  drivers/gpu/drm/vc4/vc4_drv.h |  2 ++
>  drivers/gpu/drm/vc4/vc4_gem.c | 33 +++++++++++++++++++++++++++------
>  include/uapi/drm/vc4_drm.h    |  9 +++++----
>  3 files changed, 34 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
> index 4288615b66a2..3105df99cb12 100644
> --- a/drivers/gpu/drm/vc4/vc4_drv.h
> +++ b/drivers/gpu/drm/vc4/vc4_drv.h
> @@ -10,6 +10,8 @@
>  #include <drm/drmP.h>
>  #include <drm/drm_encoder.h>
>  #include <drm/drm_gem_cma_helper.h>
> +#include <drm/drm_syncobj.h>
> +

Drop the extra \n?

>  #include "uapi/drm/vc4_drm.h"
>  
> diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
> index 2107b0daf8ef..232363488125 100644
> --- a/drivers/gpu/drm/vc4/vc4_gem.c
> +++ b/drivers/gpu/drm/vc4/vc4_gem.c
> @@ -27,6 +27,7 @@
>  #include <linux/device.h>
>  #include <linux/io.h>
>  #include <linux/sched/signal.h>
> +#include <linux/dma-fence-array.h>
>  
>  #include "uapi/drm/vc4_drm.h"
>  #include "vc4_drv.h"
> @@ -1115,21 +1116,18 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
>  	struct drm_vc4_submit_cl *args = data;
>  	struct vc4_exec_info *exec;
>  	struct ww_acquire_ctx acquire_ctx;
> +	struct dma_fence *in_fence;
>  	int ret = 0;
>  
>  	if ((args->flags & ~(VC4_SUBMIT_CL_USE_CLEAR_COLOR |
>  			     VC4_SUBMIT_CL_FIXED_RCL_ORDER |
>  			     VC4_SUBMIT_CL_RCL_ORDER_INCREASING_X |
> -			     VC4_SUBMIT_CL_RCL_ORDER_INCREASING_Y)) != 0) {
> +			     VC4_SUBMIT_CL_RCL_ORDER_INCREASING_Y |
> +			     VC4_SUBMIT_CL_IMPORT_SYNCOBJ)) != 0) {
>  		DRM_DEBUG("Unknown flags: 0x%02x\n", args->flags);
>  		return -EINVAL;
>  	}
>  
> -	if (args->pad2 != 0) {
> -		DRM_DEBUG("->pad2 must be set to zero\n");
> -		return -EINVAL;
> -	}
> -
>  	exec = kcalloc(1, sizeof(*exec), GFP_KERNEL);
>  	if (!exec) {
>  		DRM_ERROR("malloc failure on exec struct\n");
> @@ -1164,6 +1162,29 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
>  		}
>  	}
>  
> +	if (args->flags & VC4_SUBMIT_CL_IMPORT_SYNCOBJ) {
> +		ret = drm_syncobj_find_fence(file_priv, args->in_sync,
> +					     &in_fence);
> +		if (ret)
> +			goto fail;
> +
> +		/* When the fence (or fence array) is exclusively from our
> +		 * context we can skip the wait since jobs are executed in
> +		 * order of their submission through this ioctl and this can
> +		 * only have fences from a prior job.
> +		 */
> +		if (!dma_fence_match_context(in_fence,
> +					     vc4->dma_fence_context)) {
> +			ret = dma_fence_wait(in_fence, true);
> +			if (ret) {
> +				dma_fence_put(in_fence);
> +				goto fail;
> +			}
> +		}
> +
> +		dma_fence_put(in_fence);
> +	}

I don't think we need an extra flag here.  0 is an invalid syncobj
handle, so that could be the indication that there's no input syncobj.

Long term, we should probably only block once we're ready to exec the
job, not at submit time.  However, I think we can wait on fixing that
until we start using the GPU scheduler.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/4] drm/vc4: Export fence through syncobj
  2018-04-21 22:50 ` [PATCH 3/4] drm/vc4: Export fence through syncobj Stefan Schake
@ 2018-04-23 19:01   ` Eric Anholt
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Anholt @ 2018-04-23 19:01 UTC (permalink / raw)
  Cc: airlied, linux-rpi-kernel, dri-devel, Stefan Schake


[-- Attachment #1.1: Type: text/plain, Size: 4734 bytes --]

Stefan Schake <stschake@gmail.com> writes:

> Allow specifying a syncobj on render job submission where we store the
> fence for the job. This gives userland flexible access to the fence.
>
> Signed-off-by: Stefan Schake <stschake@gmail.com>
> ---
>  drivers/gpu/drm/vc4/vc4_gem.c | 38 +++++++++++++++++++++++++++++++++++---
>  include/uapi/drm/vc4_drm.h    | 13 +++++++++++++
>  2 files changed, 48 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
> index 232363488125..b39515a4ddcb 100644
> --- a/drivers/gpu/drm/vc4/vc4_gem.c
> +++ b/drivers/gpu/drm/vc4/vc4_gem.c
> @@ -656,7 +656,8 @@ vc4_lock_bo_reservations(struct drm_device *dev,
>   */
>  static int
>  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_exec_info *renderjob;
> @@ -679,6 +680,9 @@ vc4_queue_submit(struct drm_device *dev, struct vc4_exec_info *exec,
>  	fence->seqno = exec->seqno;
>  	exec->fence = &fence->base;
>  
> +	if (out_sync)
> +		drm_syncobj_replace_fence(out_sync, exec->fence);
> +
>  	vc4_update_bo_seqnos(exec, seqno);
>  
>  	vc4_unlock_bo_reservations(dev, exec, acquire_ctx);
> @@ -1114,6 +1118,7 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
>  	struct vc4_dev *vc4 = to_vc4_dev(dev);
>  	struct vc4_file *vc4file = file_priv->driver_priv;
>  	struct drm_vc4_submit_cl *args = data;
> +	struct drm_syncobj *out_sync = NULL;
>  	struct vc4_exec_info *exec;
>  	struct ww_acquire_ctx acquire_ctx;
>  	struct dma_fence *in_fence;
> @@ -1123,11 +1128,17 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
>  			     VC4_SUBMIT_CL_FIXED_RCL_ORDER |
>  			     VC4_SUBMIT_CL_RCL_ORDER_INCREASING_X |
>  			     VC4_SUBMIT_CL_RCL_ORDER_INCREASING_Y |
> -			     VC4_SUBMIT_CL_IMPORT_SYNCOBJ)) != 0) {
> +			     VC4_SUBMIT_CL_IMPORT_SYNCOBJ |
> +			     VC4_SUBMIT_CL_EXPORT_SYNCOBJ)) != 0) {
>  		DRM_DEBUG("Unknown flags: 0x%02x\n", args->flags);
>  		return -EINVAL;
>  	}
>  
> +	if (args->pad2 != 0) {
> +		DRM_DEBUG("->pad2 must be set to zero\n");
> +		return -EINVAL;
> +	}
> +
>  	exec = kcalloc(1, sizeof(*exec), GFP_KERNEL);
>  	if (!exec) {
>  		DRM_ERROR("malloc failure on exec struct\n");
> @@ -1202,12 +1213,33 @@ vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
>  	if (ret)
>  		goto fail;
>  
> +	if (args->flags & VC4_SUBMIT_CL_EXPORT_SYNCOBJ) {
> +		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.
> +		 */
> +	}

Same comment about not needing the exec flag.

> +
>  	/* Clear this out of the struct we'll be putting in the queue,
>  	 * since it's part of our stack.
>  	 */
>  	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)
>  		goto fail;
>  
> diff --git a/include/uapi/drm/vc4_drm.h b/include/uapi/drm/vc4_drm.h
> index 389f21931c25..3a2ef9b5b60b 100644
> --- a/include/uapi/drm/vc4_drm.h
> +++ b/include/uapi/drm/vc4_drm.h
> @@ -174,6 +174,7 @@ struct drm_vc4_submit_cl {
>  #define VC4_SUBMIT_CL_RCL_ORDER_INCREASING_X		(1 << 2)
>  #define VC4_SUBMIT_CL_RCL_ORDER_INCREASING_Y		(1 << 3)
>  #define VC4_SUBMIT_CL_IMPORT_SYNCOBJ			(1 << 4)
> +#define VC4_SUBMIT_CL_EXPORT_SYNCOBJ			(1 << 5)
>  	__u32 flags;
>  
>  	/* Returned value of the seqno of this render job (for the
> @@ -189,6 +190,18 @@ struct drm_vc4_submit_cl {
>  	 * syncobj is signalled.
>  	 */
>  	__u32 in_sync;
> +
> +	/* Syncobj handle to export fence to. Set together with EXPORT_SYNCOBJ
> +	 * flag. If set, the fence in the syncobj will be replaced with a fence
> +	 * that signals upon completion of this render job.
> +	 */
> +	__u32 out_sync;
> +
> +	/* Unused field to align this struct on 64 bits. Must be set to 0.
> +	 * If one ever needs to add an u32 field to this struct, this field
> +	 * can be used.
> +	 */
> +	__u32 pad2;

As far as I know, there's no need to align the struct to 64 bits.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 4/4] drm/vc4: Add parameter for syncobj support
  2018-04-21 22:50 ` [PATCH 4/4] drm/vc4: Add parameter for syncobj support Stefan Schake
@ 2018-04-23 19:05   ` Eric Anholt
  0 siblings, 0 replies; 8+ messages in thread
From: Eric Anholt @ 2018-04-23 19:05 UTC (permalink / raw)
  Cc: airlied, linux-rpi-kernel, dri-devel, Stefan Schake


[-- Attachment #1.1: Type: text/plain, Size: 306 bytes --]

Stefan Schake <stschake@gmail.com> writes:

> This allows runtime detection of syncobj submission support.
>
> Signed-off-by: Stefan Schake <stschake@gmail.com>

I think if we move patch 1 after 2+3, then we can just drop this one and
use drmGetCap(fd, DRM_CAP_SYNCOBJ, &value) in userspace for detection.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-04-23 19:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-21 22:50 [PATCH 0/4] drm/vc4: Syncobj import export Stefan Schake
2018-04-21 22:50 ` [PATCH 1/4] drm/vc4: Enable syncobj support Stefan Schake
2018-04-21 22:50 ` [PATCH 2/4] drm/vc4: Syncobj import support Stefan Schake
2018-04-23 18:59   ` Eric Anholt
2018-04-21 22:50 ` [PATCH 3/4] drm/vc4: Export fence through syncobj Stefan Schake
2018-04-23 19:01   ` Eric Anholt
2018-04-21 22:50 ` [PATCH 4/4] drm/vc4: Add parameter for syncobj support Stefan Schake
2018-04-23 19:05   ` Eric Anholt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.