Skip to contentSkip to conversation

etna_pipe_wait_ns(..)

PATCH Superseded Christian Gmeiner 4 participants 12 messages Nov 23, 2016 – Nov 24, 2016

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover etna_pipe_wait_ns(..)

Add an API to pass the timeout value (ns) from pipe->fence_finish(..) to the kernel. The current API accepts ms and special handling is needed for PIPE_TIMEOUT_INFINITE.

The idea is not to break old mesa (out-of-tree) + new libdrm. It may be possible to break etnaviv's ABI as the gallium driver is not upstream yet but I am quite unsure whats the best solution.

Changes from v2 to v3:
- Builds at each step
- Keep the _ns postfix of get_abs_timeout_ns(..)

Christian Gmeiner (4):
etnaviv: add etna_pipe_wait_ns(..)
etnaviv: simplify etna_pipe_wait(..)
etnaviv: use get_abs_timeout_ns(..) internally
etnaviv: drop get_abs_timeout(..)

 etnaviv/etnaviv-symbol-check | 1 +
 etnaviv/etnaviv_bo.c         | 2 +-
 etnaviv/etnaviv_drmif.h      | 1 +
 etnaviv/etnaviv_pipe.c       | 9 +++++++--
 etnaviv/etnaviv_priv.h       | 6 +++---
 5 files changed, 13 insertions(+), 6 deletions(-)
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH v3 1/4 etnaviv: add etna_pipe_wait_ns(..)

We need to pass through a timeout parameter to implement pipe->fence_finish() properly. The new fxn accepts a timeout in nanoseconds.

---
 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(+)
etnaviv/etnaviv-symbol-check +1 -0
index 72f2bc5..22afd16 100755
@@ -21,6 +21,7 @@ etna_gpu_get_param
 etna_pipe_new
 etna_pipe_del
 etna_pipe_wait
+etna_pipe_wait_ns
 etna_bo_new
 etna_bo_from_handle
 etna_bo_from_name
etnaviv/etnaviv_drmif.h +1 -0
index fe9d5db..8119baa 100644
@@ -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_wait_ns(struct etna_pipe *pipe, uint32_t timestamp, uint64_t ns);
 
 
 /* buffer-object functions:
etnaviv/etnaviv_pipe.c +24 -0
index 402b71d..f2e417f 100644
@@ -54,6 +54,30 @@ int etna_pipe_wait(struct etna_pipe *pipe, uint32_t timestamp, uint32_t ms)
 	return 0;
 }
 
+int etna_pipe_wait_ns(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);
etnaviv/etnaviv_priv.h +9 -0
index eb62ed3..30cc1bd 100644
@@ -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_ */
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

PATCH v3 2/4 etnaviv: simplify etna_pipe_wait(..)

In reply to Christian Gmeiner

We can make use of etna_pipe_wait_ns(..).

---
 etnaviv/etnaviv_pipe.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)
etnaviv/etnaviv_pipe.c +1 -20
index f2e417f..6951362 100644
@@ -32,26 +32,7 @@
 
 int etna_pipe_wait(struct etna_pipe *pipe, uint32_t timestamp, uint32_t ms)
 {
-	struct etna_device *dev = pipe->gpu->dev;
-	int ret;
-
-	struct drm_etnaviv_wait_fence req = {
-		.pipe = pipe->gpu->core,
-		.fence = timestamp,
-	};
-
-	if (ms == 0)
-		req.flags |= ETNA_WAIT_NONBLOCK;
-
-	get_abs_timeout(&req.timeout, ms);
-
-	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;
+	return etna_pipe_wait_ns(pipe, timestamp, ms * 1000000);
 }
 
 int etna_pipe_wait_ns(struct etna_pipe *pipe, uint32_t timestamp, uint64_t ns)
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

PATCH v3 3/4 etnaviv: use get_abs_timeout_ns(..) internally

In reply to Christian Gmeiner
---
 etnaviv/etnaviv_bo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
etnaviv/etnaviv_bo.c +1 -1
index 833f8bd..ed1f516 100644
@@ -330,7 +330,7 @@ int etna_bo_cpu_prep(struct etna_bo *bo, uint32_t op)
 		.op = op,
 	};
 
-	get_abs_timeout(&req.timeout, 5000);
+	get_abs_timeout_ns(&req.timeout, 5000000000);
 
 	return drmCommandWrite(bo->dev->fd, DRM_ETNAVIV_GEM_CPU_PREP,
 			&req, sizeof(req));
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw

PATCH v3 4/4 etnaviv: drop get_abs_timeout(..)

In reply to Christian Gmeiner

It has no callers so drop it.

---
 etnaviv/etnaviv_priv.h | 9 ---------
 1 file changed, 9 deletions(-)
etnaviv/etnaviv_priv.h +0 -9
index 30cc1bd..667bf23 100644
@@ -189,15 +189,6 @@ struct etna_cmd_stream_priv {
 
 #define VOID2U64(x) ((uint64_t)(unsigned long)(x))
 
-static inline void get_abs_timeout(struct drm_etnaviv_timespec *tv, uint32_t ms)
-{
-	struct timespec t;
-	uint32_t s = ms / 1000;
-	clock_gettime(CLOCK_MONOTONIC, &t);
-	tv->tv_sec = t.tv_sec + s;
-	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;
Signature · 6 lines
2.7.4

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw
In reply to Christian Gmeiner
Quoted 8 lines · Christian Gmeiner

Add an API to pass the timeout value (ns) from pipe->fence_finish(..) to the kernel. The current API accepts ms and special handling is needed for PIPE_TIMEOUT_INFINITE.

The idea is not to break old mesa (out-of-tree) + new libdrm. It may be possible to break etnaviv's ABI as the gallium driver is not upstream yet but I am quite unsure whats the best solution.

I'm kind of split with a small inclination towards "break it" ;-)

IIRC tegra also had an ABI break and if there is nothing upstream then there's "nothing to break".
I'd check with Lucas [I believe he's using your github branch] and other prominent etnaviv users/devs. on the topic. IMHO whichever route you guys are happy with, goes.

Quoted 10 lines

Changes from v2 to v3:
- Builds at each step
- Keep the _ns postfix of get_abs_timeout_ns(..)

Christian Gmeiner (4):
etnaviv: add etna_pipe_wait_ns(..)
etnaviv: simplify etna_pipe_wait(..)
etnaviv: use get_abs_timeout_ns(..) internally
etnaviv: drop get_abs_timeout(..)

<nitpicking>

Just a suggestion.

How does the following approach sound:
- change get_abs_timeout to use ns/update callers
- (if you'd like having new API) add etna_pipe_wait_ns and implement
etna_pipe_wait via it (merge 1 and 2)
Then...

Quoted 6 lines
 etnaviv/etnaviv-symbol-check | 1 +
 etnaviv/etnaviv_bo.c         | 2 +-
 etnaviv/etnaviv_drmif.h      | 1 +
 etnaviv/etnaviv_pipe.c       | 9 +++++++--
 etnaviv/etnaviv_priv.h       | 6 +++---
 5 files changed, 13 insertions(+), 6 deletions(-)

... this diff will reflect reality. Atm it's more of

 5 files changed, 35 insertions(+) 29 deletions(-)

</nitpicking>

-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw
Quoted 11 lines · Emil Velikov
Quoted 8 lines · Christian Gmeiner

Add an API to pass the timeout value (ns) from pipe->fence_finish(..) to the kernel. The current API accepts ms and special handling is needed for PIPE_TIMEOUT_INFINITE.

The idea is not to break old mesa (out-of-tree) + new libdrm. It may be possible to break etnaviv's ABI as the gallium driver is not upstream yet but I am quite unsure whats the best solution.

I'm kind of split with a small inclination towards "break it" ;-)

fwiw, I suggested the "don't break it" approach.. in the early days of a new FOSS gfx driver, it is hard enough for end users to pull together the right combination of trees to make things work, so lets not make it harder for them. In the end, a FOSS driver is to enable the users ;-)

BR,
-R

Quoted 36 lines

IIRC tegra also had an ABI break and if there is nothing upstream then there's "nothing to break".
I'd check with Lucas [I believe he's using your github branch] and other prominent etnaviv users/devs. on the topic. IMHO whichever route you guys are happy with, goes.

Quoted 10 lines

Changes from v2 to v3:
- Builds at each step
- Keep the _ns postfix of get_abs_timeout_ns(..)

Christian Gmeiner (4):
etnaviv: add etna_pipe_wait_ns(..)
etnaviv: simplify etna_pipe_wait(..)
etnaviv: use get_abs_timeout_ns(..) internally
etnaviv: drop get_abs_timeout(..)

<nitpicking>

Just a suggestion.

How does the following approach sound:
- change get_abs_timeout to use ns/update callers
- (if you'd like having new API) add etna_pipe_wait_ns and implement
etna_pipe_wait via it (merge 1 and 2)
Then...

Quoted 6 lines
 etnaviv/etnaviv-symbol-check | 1 +
 etnaviv/etnaviv_bo.c         | 2 +-
 etnaviv/etnaviv_drmif.h      | 1 +
 etnaviv/etnaviv_pipe.c       | 9 +++++++--
 etnaviv/etnaviv_priv.h       | 6 +++---
 5 files changed, 13 insertions(+), 6 deletions(-)

... this diff will reflect reality. Atm it's more of

 5 files changed, 35 insertions(+) 29 deletions(-)
Quoted 7 lines

</nitpicking>

-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw
Quoted 11 lines · Rob Clark
Quoted 10 lines · Emil Velikov
Quoted 8 lines · Christian Gmeiner

Add an API to pass the timeout value (ns) from pipe->fence_finish(..) to the kernel. The current API accepts ms and special handling is needed for PIPE_TIMEOUT_INFINITE.

The idea is not to break old mesa (out-of-tree) + new libdrm. It may be possible to break etnaviv's ABI as the gallium driver is not upstream yet but I am quite unsure whats the best solution.

Quoted 8 lines
Quoted 1 line

I'm kind of split with a small inclination towards "break it" ;-)

fwiw, I suggested the "don't break it" approach.. in the early days of a new FOSS gfx driver, it is hard enough for end users to pull together the right combination of trees to make things work, so lets not make it harder for them. In the end, a FOSS driver is to enable the users ;-)

Which is kind of but not the same the thing I've mentioned - check if driver devs/users have a preference and go ahead with it :-P There is limited benefit in supporting "out of tree" code if most/all the people don't care about it ... and Mesa is likely to land ~soonish
;-)

I see your point, hopefully mine was clear as well. Emil
_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw
Quoted 20 lines · Emil Velikov
Quoted 11 lines · Rob Clark
Quoted 10 lines · Emil Velikov
Quoted 8 lines · Christian Gmeiner

Add an API to pass the timeout value (ns) from pipe->fence_finish(..) to the kernel. The current API accepts ms and special handling is needed for PIPE_TIMEOUT_INFINITE.

The idea is not to break old mesa (out-of-tree) + new libdrm. It may be possible to break etnaviv's ABI as the gallium driver is not upstream yet but I am quite unsure whats the best solution.

Quoted 8 lines
Quoted 1 line

I'm kind of split with a small inclination towards "break it" ;-)

fwiw, I suggested the "don't break it" approach.. in the early days of a new FOSS gfx driver, it is hard enough for end users to pull together the right combination of trees to make things work, so lets not make it harder for them. In the end, a FOSS driver is to enable the users ;-)

Quoted 5 lines

Which is kind of but not the same the thing I've mentioned - check if driver devs/users have a preference and go ahead with it :-P There is limited benefit in supporting "out of tree" code if most/all the people don't care about it ... and Mesa is likely to land ~soonish
;-)

judging by activity on #etnaviv there are users.. (and ofc that is why I want to get mesa parts landed as-soonish-as-possible ;-))

I think in this particular case, there isn't really much downside for not breaking things for existing out-of-tree users.. we can always garbage-collect the old API that was never used upstream later.

Quoted 1 line

I see your point, hopefully mine was clear as well.

yeah, I think taking extraordinary measures for out of tree code is worth cost/benefit analysis.. in this case not breaking things isn't so painful and causes less headache as we get etnaviv merged upstream.. so seems like a win/win to me ;-)

BR,
-R

Quoted 1 line

Emil

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#9 lore raw
Quoted 34 lines · Rob Clark
Quoted 20 lines · Emil Velikov
Quoted 11 lines · Rob Clark
Quoted 10 lines · Emil Velikov
Quoted 8 lines · Christian Gmeiner

Add an API to pass the timeout value (ns) from pipe->fence_finish(..) to the kernel. The current API accepts ms and special handling is needed for PIPE_TIMEOUT_INFINITE.

The idea is not to break old mesa (out-of-tree) + new libdrm. It may be possible to break etnaviv's ABI as the gallium driver is not upstream yet but I am quite unsure whats the best solution.

Quoted 8 lines
Quoted 1 line

I'm kind of split with a small inclination towards "break it" ;-)

fwiw, I suggested the "don't break it" approach.. in the early days of a new FOSS gfx driver, it is hard enough for end users to pull together the right combination of trees to make things work, so lets not make it harder for them. In the end, a FOSS driver is to enable the users ;-)

Quoted 5 lines

Which is kind of but not the same the thing I've mentioned - check if driver devs/users have a preference and go ahead with it :-P There is limited benefit in supporting "out of tree" code if most/all the people don't care about it ... and Mesa is likely to land ~soonish
;-)

judging by activity on #etnaviv there are users.. (and ofc that is why I want to get mesa parts landed as-soonish-as-possible ;-))

I think in this particular case, there isn't really much downside for not breaking things for existing out-of-tree users.. we can always garbage-collect the old API that was never used upstream later.

Quoted 6 lines
Quoted 1 line

I see your point, hopefully mine was clear as well.

yeah, I think taking extraordinary measures for out of tree code is worth cost/benefit analysis.. in this case not breaking things isn't so painful and causes less headache as we get etnaviv merged upstream.. so seems like a win/win to me ;-)

Mesa should just finally get merged, and then it's not out-of-tree and also clear that we should break abi. Christian promised this for last week, didn't seem to have materialized yet. Why is this so hard? -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#10 lore raw

2016-11-24 8:53 GMT+01:00 Daniel Vetter <[email protected]>:

Quoted 37 lines · Rob Clark
Quoted 36 lines · Emil Velikov
Quoted 20 lines · Rob Clark
Quoted 11 lines · Emil Velikov
Quoted 10 lines
Quoted 8 lines · Christian Gmeiner

Add an API to pass the timeout value (ns) from pipe->fence_finish(..) to the kernel. The current API accepts ms and special handling is needed for PIPE_TIMEOUT_INFINITE.

The idea is not to break old mesa (out-of-tree) + new libdrm. It may be possible to break etnaviv's ABI as the gallium driver is not upstream yet but I am quite unsure whats the best solution.

Quoted 8 lines
Quoted 1 line

I'm kind of split with a small inclination towards "break it" ;-)

fwiw, I suggested the "don't break it" approach.. in the early days of a new FOSS gfx driver, it is hard enough for end users to pull together the right combination of trees to make things work, so lets not make it harder for them. In the end, a FOSS driver is to enable the users ;-)

Quoted 5 lines

Which is kind of but not the same the thing I've mentioned - check if driver devs/users have a preference and go ahead with it :-P There is limited benefit in supporting "out of tree" code if most/all the people don't care about it ... and Mesa is likely to land ~soonish
;-)

judging by activity on #etnaviv there are users.. (and ofc that is why I want to get mesa parts landed as-soonish-as-possible ;-))

I think in this particular case, there isn't really much downside for not breaking things for existing out-of-tree users.. we can always garbage-collect the old API that was never used upstream later.

Quoted 1 line

I see your point, hopefully mine was clear as well.

Quoted 8 lines
Quoted 4 lines

yeah, I think taking extraordinary measures for out of tree code is worth cost/benefit analysis.. in this case not breaking things isn't so painful and causes less headache as we get etnaviv merged upstream.. so seems like a win/win to me ;-)

Mesa should just finally get merged, and then it's not out-of-tree and also clear that we should break abi. Christian promised this for last week, didn't seem to have materialized yet. Why is this so hard?

This was the last issue (in my eyes I want to get right). The patches are prepared so yes.. it should finally happen.

Greets
--
Christian Gmeiner, MSc

https://soundcloud.com/christian-gmeiner
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#11 lore raw
In reply to Emil Velikov

Hi Emil,

2016-11-23 19:18 GMT+01:00 Emil Velikov <[email protected]>:

Quoted 10 lines
Quoted 8 lines · Christian Gmeiner

Add an API to pass the timeout value (ns) from pipe->fence_finish(..) to the kernel. The current API accepts ms and special handling is needed for PIPE_TIMEOUT_INFINITE.

The idea is not to break old mesa (out-of-tree) + new libdrm. It may be possible to break etnaviv's ABI as the gallium driver is not upstream yet but I am quite unsure whats the best solution.

Quoted 8 lines

I'm kind of split with a small inclination towards "break it" ;-)

IIRC tegra also had an ABI break and if there is nothing upstream then there's "nothing to break".
I'd check with Lucas [I believe he's using your github branch] and other prominent etnaviv users/devs. on the topic. IMHO whichever route you guys are happy with, goes.

After more thinking about this topic I will go with the new API.

Quoted 10 lines
Quoted 10 lines

Changes from v2 to v3:
- Builds at each step
- Keep the _ns postfix of get_abs_timeout_ns(..)

Christian Gmeiner (4):
etnaviv: add etna_pipe_wait_ns(..)
etnaviv: simplify etna_pipe_wait(..)
etnaviv: use get_abs_timeout_ns(..) internally
etnaviv: drop get_abs_timeout(..)

Quoted 8 lines

<nitpicking>

Just a suggestion.

How does the following approach sound:
- change get_abs_timeout to use ns/update callers
- (if you'd like having new API) add etna_pipe_wait_ns and implement
etna_pipe_wait via it (merge 1 and 2)

Okay.. will go that route - Will send out v3 soon.

Quoted 9 lines

Then...

Quoted 6 lines
 etnaviv/etnaviv-symbol-check | 1 +
 etnaviv/etnaviv_bo.c         | 2 +-
 etnaviv/etnaviv_drmif.h      | 1 +
 etnaviv/etnaviv_pipe.c       | 9 +++++++--
 etnaviv/etnaviv_priv.h       | 6 +++---
 5 files changed, 13 insertions(+), 6 deletions(-)
Quoted 6 lines

... this diff will reflect reality. Atm it's more of

 5 files changed, 35 insertions(+) 29 deletions(-)

</nitpicking>

-Emil

Thanks
--
Christian Gmeiner, MSc

https://soundcloud.com/christian-gmeiner
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel