diff mbox

[libdrm] etnaviv: add etna_pipe_wait2(..)

Message ID 1479851672-7019-1-git-send-email-christian.gmeiner@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Christian Gmeiner Nov. 22, 2016, 9:54 p.m. UTC
We need to pass through a timeout parameter to implement
pipe->fence_finish() properly. The new fxn accepts a timeout
in nanoseconds.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
---
 etnaviv/etnaviv-symbol-check |  1 +
 etnaviv/etnaviv_drmif.h      |  1 +
 etnaviv/etnaviv_pipe.c       | 24 ++++++++++++++++++++++++
 etnaviv/etnaviv_priv.h       |  9 +++++++++
 4 files changed, 35 insertions(+)

Comments

Christian Gmeiner Nov. 22, 2016, 10:19 p.m. UTC | #1
Please ignore... v2 is coming.

thanks
--
Christian Gmeiner, MSc

https://soundcloud.com/christian-gmeiner


2016-11-22 22:54 GMT+01:00 Christian Gmeiner <christian.gmeiner@gmail.com>:
> We need to pass through a timeout parameter to implement
> pipe->fence_finish() properly. The new fxn accepts a timeout
> in nanoseconds.
>
> Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
> ---
>  etnaviv/etnaviv-symbol-check |  1 +
>  etnaviv/etnaviv_drmif.h      |  1 +
>  etnaviv/etnaviv_pipe.c       | 24 ++++++++++++++++++++++++
>  etnaviv/etnaviv_priv.h       |  9 +++++++++
>  4 files changed, 35 insertions(+)
>
> diff --git a/etnaviv/etnaviv-symbol-check b/etnaviv/etnaviv-symbol-check
> index 72f2bc5..b16f629 100755
> --- a/etnaviv/etnaviv-symbol-check
> +++ b/etnaviv/etnaviv-symbol-check
> @@ -21,6 +21,7 @@ etna_gpu_get_param
>  etna_pipe_new
>  etna_pipe_del
>  etna_pipe_wait
> +etna_pipe_wait2
>  etna_bo_new
>  etna_bo_from_handle
>  etna_bo_from_name
> diff --git a/etnaviv/etnaviv_drmif.h b/etnaviv/etnaviv_drmif.h
> index fe9d5db..1bec762 100644
> --- a/etnaviv/etnaviv_drmif.h
> +++ b/etnaviv/etnaviv_drmif.h
> @@ -104,6 +104,7 @@ int etna_gpu_get_param(struct etna_gpu *gpu, enum etna_param_id param,
>  struct etna_pipe *etna_pipe_new(struct etna_gpu *gpu, enum etna_pipe_id id);
>  void etna_pipe_del(struct etna_pipe *pipe);
>  int etna_pipe_wait(struct etna_pipe *pipe, uint32_t timestamp, uint32_t ms);
> +int etna_pipe_wait2(struct etna_pipe *pipe, uint32_t timestamp, uint64_t ns);
>
>
>  /* buffer-object functions:
> diff --git a/etnaviv/etnaviv_pipe.c b/etnaviv/etnaviv_pipe.c
> index 402b71d..9e624c5 100644
> --- a/etnaviv/etnaviv_pipe.c
> +++ b/etnaviv/etnaviv_pipe.c
> @@ -54,6 +54,30 @@ int etna_pipe_wait(struct etna_pipe *pipe, uint32_t timestamp, uint32_t ms)
>         return 0;
>  }
>
> +int etna_pipe_wait2(struct etna_pipe *pipe, uint32_t timestamp, uint64_t ns)
> +{
> +       struct etna_device *dev = pipe->gpu->dev;
> +       int ret;
> +
> +       struct drm_etnaviv_wait_fence req = {
> +               .pipe = pipe->gpu->core,
> +               .fence = timestamp,
> +       };
> +
> +       if (ns == 0)
> +               req.flags |= ETNA_WAIT_NONBLOCK;
> +
> +       get_abs_timeout_ns(&req.timeout, ns);
> +
> +       ret = drmCommandWrite(dev->fd, DRM_ETNAVIV_WAIT_FENCE, &req, sizeof(req));
> +       if (ret) {
> +               ERROR_MSG("wait-fence failed! %d (%s)", ret, strerror(errno));
> +               return ret;
> +       }
> +
> +       return 0;
> +}
> +
>  void etna_pipe_del(struct etna_pipe *pipe)
>  {
>         free(pipe);
> diff --git a/etnaviv/etnaviv_priv.h b/etnaviv/etnaviv_priv.h
> index eb62ed3..30cc1bd 100644
> --- a/etnaviv/etnaviv_priv.h
> +++ b/etnaviv/etnaviv_priv.h
> @@ -198,4 +198,13 @@ static inline void get_abs_timeout(struct drm_etnaviv_timespec *tv, uint32_t ms)
>         tv->tv_nsec = t.tv_nsec + ((ms - (s * 1000)) * 1000000);
>  }
>
> +static inline void get_abs_timeout_ns(struct drm_etnaviv_timespec *tv, uint64_t ns)
> +{
> +       struct timespec t;
> +       uint32_t s = ns / 1000000000;
> +       clock_gettime(CLOCK_MONOTONIC, &t);
> +       tv->tv_sec = t.tv_sec + s;
> +       tv->tv_nsec = t.tv_nsec + ns - (s * 1000000000);
> +}
> +
>  #endif /* ETNAVIV_PRIV_H_ */
> --
> 2.7.4
>
diff mbox

Patch

diff --git a/etnaviv/etnaviv-symbol-check b/etnaviv/etnaviv-symbol-check
index 72f2bc5..b16f629 100755
--- a/etnaviv/etnaviv-symbol-check
+++ b/etnaviv/etnaviv-symbol-check
@@ -21,6 +21,7 @@  etna_gpu_get_param
 etna_pipe_new
 etna_pipe_del
 etna_pipe_wait
+etna_pipe_wait2
 etna_bo_new
 etna_bo_from_handle
 etna_bo_from_name
diff --git a/etnaviv/etnaviv_drmif.h b/etnaviv/etnaviv_drmif.h
index fe9d5db..1bec762 100644
--- a/etnaviv/etnaviv_drmif.h
+++ b/etnaviv/etnaviv_drmif.h
@@ -104,6 +104,7 @@  int etna_gpu_get_param(struct etna_gpu *gpu, enum etna_param_id param,
 struct etna_pipe *etna_pipe_new(struct etna_gpu *gpu, enum etna_pipe_id id);
 void etna_pipe_del(struct etna_pipe *pipe);
 int etna_pipe_wait(struct etna_pipe *pipe, uint32_t timestamp, uint32_t ms);
+int etna_pipe_wait2(struct etna_pipe *pipe, uint32_t timestamp, uint64_t ns);
 
 
 /* buffer-object functions:
diff --git a/etnaviv/etnaviv_pipe.c b/etnaviv/etnaviv_pipe.c
index 402b71d..9e624c5 100644
--- a/etnaviv/etnaviv_pipe.c
+++ b/etnaviv/etnaviv_pipe.c
@@ -54,6 +54,30 @@  int etna_pipe_wait(struct etna_pipe *pipe, uint32_t timestamp, uint32_t ms)
 	return 0;
 }
 
+int etna_pipe_wait2(struct etna_pipe *pipe, uint32_t timestamp, uint64_t ns)
+{
+	struct etna_device *dev = pipe->gpu->dev;
+	int ret;
+
+	struct drm_etnaviv_wait_fence req = {
+		.pipe = pipe->gpu->core,
+		.fence = timestamp,
+	};
+
+	if (ns == 0)
+		req.flags |= ETNA_WAIT_NONBLOCK;
+
+	get_abs_timeout_ns(&req.timeout, ns);
+
+	ret = drmCommandWrite(dev->fd, DRM_ETNAVIV_WAIT_FENCE, &req, sizeof(req));
+	if (ret) {
+		ERROR_MSG("wait-fence failed! %d (%s)", ret, strerror(errno));
+		return ret;
+	}
+
+	return 0;
+}
+
 void etna_pipe_del(struct etna_pipe *pipe)
 {
 	free(pipe);
diff --git a/etnaviv/etnaviv_priv.h b/etnaviv/etnaviv_priv.h
index eb62ed3..30cc1bd 100644
--- a/etnaviv/etnaviv_priv.h
+++ b/etnaviv/etnaviv_priv.h
@@ -198,4 +198,13 @@  static inline void get_abs_timeout(struct drm_etnaviv_timespec *tv, uint32_t ms)
 	tv->tv_nsec = t.tv_nsec + ((ms - (s * 1000)) * 1000000);
 }
 
+static inline void get_abs_timeout_ns(struct drm_etnaviv_timespec *tv, uint64_t ns)
+{
+	struct timespec t;
+	uint32_t s = ns / 1000000000;
+	clock_gettime(CLOCK_MONOTONIC, &t);
+	tv->tv_sec = t.tv_sec + s;
+	tv->tv_nsec = t.tv_nsec + ns - (s * 1000000000);
+}
+
 #endif /* ETNAVIV_PRIV_H_ */