All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH libdrm v2 1/2] etnaviv: sync uapi header
@ 2017-04-07 12:06 Philipp Zabel
  2017-04-07 12:06 ` [PATCH libdrm v2 2/2] etnaviv: add fence fd support Philipp Zabel
  2017-04-08 19:55 ` [PATCH libdrm v2 1/2] etnaviv: sync uapi header Emil Velikov
  0 siblings, 2 replies; 5+ messages in thread
From: Philipp Zabel @ 2017-04-07 12:06 UTC (permalink / raw)
  To: dri-devel, etnaviv; +Cc: Emil Velikov

Import the etnaviv header changes from kernel commits 9ad59fea162c
("drm/etnaviv: submit support for in-fences") and 78ec187f64fa
("drm/etnaviv: submit support for out-fences") for fence fd support.

The drm_etnaviv_gem_submit structure was extended to include a flags
field, new flags for in-fence and out-fence fds and an input/output
fence fd field.

This is one-way backwards compatible because old userspace code passing
a short structure not including the flags field to new kernels will
cause the remaining fields to be zero-filled. New userspace code must
make sure to only pass the short structure to old kernels, though.

Not generated using make headers_install, since the drm/etnaviv_drm.h
uapi header is not installed yet by the kernel.
Copied from the airlied/drm-next commit 78ec187f64fa.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
---
v2: improved commit message
---
 etnaviv/etnaviv_drm.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/etnaviv/etnaviv_drm.h b/etnaviv/etnaviv_drm.h
index 2584c1cc..76f6f78a 100644
--- a/etnaviv/etnaviv_drm.h
+++ b/etnaviv/etnaviv_drm.h
@@ -154,6 +154,12 @@ struct drm_etnaviv_gem_submit_bo {
  * one or more cmdstream buffers.  This allows for conditional execution
  * (context-restore), and IB buffers needed for per tile/bin draw cmds.
  */
+#define ETNA_SUBMIT_NO_IMPLICIT         0x0001
+#define ETNA_SUBMIT_FENCE_FD_IN         0x0002
+#define ETNA_SUBMIT_FENCE_FD_OUT        0x0004
+#define ETNA_SUBMIT_FLAGS		(ETNA_SUBMIT_NO_IMPLICIT | \
+					 ETNA_SUBMIT_FENCE_FD_IN | \
+					 ETNA_SUBMIT_FENCE_FD_OUT)
 #define ETNA_PIPE_3D      0x00
 #define ETNA_PIPE_2D      0x01
 #define ETNA_PIPE_VG      0x02
@@ -167,6 +173,8 @@ struct drm_etnaviv_gem_submit {
 	__u64 bos;            /* in, ptr to array of submit_bo's */
 	__u64 relocs;         /* in, ptr to array of submit_reloc's */
 	__u64 stream;         /* in, ptr to cmdstream */
+	__u32 flags;          /* in, mask of ETNA_SUBMIT_x */
+	__s32 fence_fd;       /* in/out, fence fd (see ETNA_SUBMIT_FENCE_FD_x) */
 };
 
 /* The normal way to synchronize with the GPU is just to CPU_PREP on
-- 
2.11.0

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

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

* [PATCH libdrm v2 2/2] etnaviv: add fence fd support
  2017-04-07 12:06 [PATCH libdrm v2 1/2] etnaviv: sync uapi header Philipp Zabel
@ 2017-04-07 12:06 ` Philipp Zabel
  2017-04-08 19:50   ` Emil Velikov
  2017-04-08 19:55 ` [PATCH libdrm v2 1/2] etnaviv: sync uapi header Emil Velikov
  1 sibling, 1 reply; 5+ messages in thread
From: Philipp Zabel @ 2017-04-07 12:06 UTC (permalink / raw)
  To: dri-devel, etnaviv; +Cc: Emil Velikov

Add etna_cmd_stream_flush2 with in-fence fd and out-fence fd support for
explicit fencing.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
---
v2: renamed etna_cmd_stream_flush_explicit to etna_cmd_stream_flush2
---
 etnaviv/etnaviv_cmd_stream.c | 33 +++++++++++++++++++++++++++++----
 etnaviv/etnaviv_drmif.h      |  2 ++
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/etnaviv/etnaviv_cmd_stream.c b/etnaviv/etnaviv_cmd_stream.c
index 9ce3f363..3c7b0ed6 100644
--- a/etnaviv/etnaviv_cmd_stream.c
+++ b/etnaviv/etnaviv_cmd_stream.c
@@ -177,7 +177,8 @@ static uint32_t bo2idx(struct etna_cmd_stream *stream, struct etna_bo *bo,
 	return idx;
 }
 
-static void flush(struct etna_cmd_stream *stream)
+static void flush(struct etna_cmd_stream *stream, int in_fence_fd,
+		  int *out_fence_fd)
 {
 	struct etna_cmd_stream_priv *priv = etna_cmd_stream_priv(stream);
 	int ret, id = priv->pipe->id;
@@ -194,8 +195,22 @@ static void flush(struct etna_cmd_stream *stream)
 		.stream_size = stream->offset * 4, /* in bytes */
 	};
 
+	if (in_fence_fd != -1) {
+		req.flags |= ETNA_SUBMIT_FENCE_FD_IN | ETNA_SUBMIT_NO_IMPLICIT;
+		req.fence_fd = in_fence_fd;
+	}
+
+	if (out_fence_fd)
+		req.flags |= ETNA_SUBMIT_FENCE_FD_OUT;
+
+	/*
+	 * Pass the complete submit structure only if flags are set. Otherwise,
+	 * only pass the fields up to, but not including the flags field for
+	 * backwards compatiblity with older kernels.
+	 */
 	ret = drmCommandWriteRead(gpu->dev->fd, DRM_ETNAVIV_GEM_SUBMIT,
-			&req, sizeof(req));
+			&req, req.flags ? sizeof(req) :
+			offsetof(struct drm_etnaviv_gem_submit, flags));
 
 	if (ret)
 		ERROR_MSG("submit failed: %d (%s)", ret, strerror(errno));
@@ -208,11 +223,21 @@ static void flush(struct etna_cmd_stream *stream)
 		bo->current_stream = NULL;
 		etna_bo_del(bo);
 	}
+
+	if (out_fence_fd)
+		*out_fence_fd = req.fence_fd;
 }
 
 void etna_cmd_stream_flush(struct etna_cmd_stream *stream)
 {
-	flush(stream);
+	flush(stream, -1, NULL);
+	reset_buffer(stream);
+}
+
+void etna_cmd_stream_flush2(struct etna_cmd_stream *stream, int in_fence_fd,
+			    int *out_fence_fd)
+{
+	flush(stream, in_fence_fd, out_fence_fd);
 	reset_buffer(stream);
 }
 
@@ -220,7 +245,7 @@ void etna_cmd_stream_finish(struct etna_cmd_stream *stream)
 {
 	struct etna_cmd_stream_priv *priv = etna_cmd_stream_priv(stream);
 
-	flush(stream);
+	flush(stream, -1, NULL);
 	etna_pipe_wait(priv->pipe, priv->last_timestamp, 5000);
 	reset_buffer(stream);
 }
diff --git a/etnaviv/etnaviv_drmif.h b/etnaviv/etnaviv_drmif.h
index 8119baad..87704acd 100644
--- a/etnaviv/etnaviv_drmif.h
+++ b/etnaviv/etnaviv_drmif.h
@@ -142,6 +142,8 @@ struct etna_cmd_stream *etna_cmd_stream_new(struct etna_pipe *pipe, uint32_t siz
 void etna_cmd_stream_del(struct etna_cmd_stream *stream);
 uint32_t etna_cmd_stream_timestamp(struct etna_cmd_stream *stream);
 void etna_cmd_stream_flush(struct etna_cmd_stream *stream);
+void etna_cmd_stream_flush2(struct etna_cmd_stream *stream, int in_fence_fd,
+			    int *out_fence_fd);
 void etna_cmd_stream_finish(struct etna_cmd_stream *stream);
 
 static inline uint32_t etna_cmd_stream_avail(struct etna_cmd_stream *stream)
-- 
2.11.0

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

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

* Re: [PATCH libdrm v2 2/2] etnaviv: add fence fd support
  2017-04-07 12:06 ` [PATCH libdrm v2 2/2] etnaviv: add fence fd support Philipp Zabel
@ 2017-04-08 19:50   ` Emil Velikov
  0 siblings, 0 replies; 5+ messages in thread
From: Emil Velikov @ 2017-04-08 19:50 UTC (permalink / raw)
  To: Philipp Zabel; +Cc: The etnaviv authors, ML dri-devel

On 7 April 2017 at 13:06, Philipp Zabel <p.zabel@pengutronix.de> wrote:
> Add etna_cmd_stream_flush2 with in-fence fd and out-fence fd support for
> explicit fencing.
>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
> ---
> v2: renamed etna_cmd_stream_flush_explicit to etna_cmd_stream_flush2

Please add the new symbol to etnaviv/etnaviv-symbol-check.

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

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

* Re: [PATCH libdrm v2 1/2] etnaviv: sync uapi header
  2017-04-07 12:06 [PATCH libdrm v2 1/2] etnaviv: sync uapi header Philipp Zabel
  2017-04-07 12:06 ` [PATCH libdrm v2 2/2] etnaviv: add fence fd support Philipp Zabel
@ 2017-04-08 19:55 ` Emil Velikov
  2017-04-10  8:48   ` Philipp Zabel
  1 sibling, 1 reply; 5+ messages in thread
From: Emil Velikov @ 2017-04-08 19:55 UTC (permalink / raw)
  To: Philipp Zabel; +Cc: The etnaviv authors, ML dri-devel

On 7 April 2017 at 13:06, Philipp Zabel <p.zabel@pengutronix.de> wrote:
> Import the etnaviv header changes from kernel commits 9ad59fea162c
> ("drm/etnaviv: submit support for in-fences") and 78ec187f64fa
> ("drm/etnaviv: submit support for out-fences") for fence fd support.
>
> The drm_etnaviv_gem_submit structure was extended to include a flags
> field, new flags for in-fence and out-fence fds and an input/output
> fence fd field.
>
> This is one-way backwards compatible because old userspace code passing
> a short structure not including the flags field to new kernels will
> cause the remaining fields to be zero-filled. New userspace code must
> make sure to only pass the short structure to old kernels, though.
>
> Not generated using make headers_install, since the drm/etnaviv_drm.h
> uapi header is not installed yet by the kernel.
IIRC all the other drivers should already install the header, so we
want to fix this, right?
If we're too late for this kernel cycle, we will land the patch as-is.

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

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

* Re: [PATCH libdrm v2 1/2] etnaviv: sync uapi header
  2017-04-08 19:55 ` [PATCH libdrm v2 1/2] etnaviv: sync uapi header Emil Velikov
@ 2017-04-10  8:48   ` Philipp Zabel
  0 siblings, 0 replies; 5+ messages in thread
From: Philipp Zabel @ 2017-04-10  8:48 UTC (permalink / raw)
  To: Emil Velikov; +Cc: The etnaviv authors, ML dri-devel

On Sat, 2017-04-08 at 20:55 +0100, Emil Velikov wrote:
> On 7 April 2017 at 13:06, Philipp Zabel <p.zabel@pengutronix.de> wrote:
> > Import the etnaviv header changes from kernel commits 9ad59fea162c
> > ("drm/etnaviv: submit support for in-fences") and 78ec187f64fa
> > ("drm/etnaviv: submit support for out-fences") for fence fd support.
> >
> > The drm_etnaviv_gem_submit structure was extended to include a flags
> > field, new flags for in-fence and out-fence fds and an input/output
> > fence fd field.
> >
> > This is one-way backwards compatible because old userspace code passing
> > a short structure not including the flags field to new kernels will
> > cause the remaining fields to be zero-filled. New userspace code must
> > make sure to only pass the short structure to old kernels, though.
> >
> > Not generated using make headers_install, since the drm/etnaviv_drm.h
> > uapi header is not installed yet by the kernel.
> IIRC all the other drivers should already install the header, so we
> want to fix this, right?
> If we're too late for this kernel cycle, we will land the patch as-is.

Yes, I'll send a kernel patch for the next cycle. For now I'll just
resend the patch as-is but with the new symbol added to symbol-check.

regards
Philipp

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

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

end of thread, other threads:[~2017-04-10  8:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-07 12:06 [PATCH libdrm v2 1/2] etnaviv: sync uapi header Philipp Zabel
2017-04-07 12:06 ` [PATCH libdrm v2 2/2] etnaviv: add fence fd support Philipp Zabel
2017-04-08 19:50   ` Emil Velikov
2017-04-08 19:55 ` [PATCH libdrm v2 1/2] etnaviv: sync uapi header Emil Velikov
2017-04-10  8:48   ` Philipp Zabel

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.