All of lore.kernel.org
 help / color / mirror / Atom feed
* [i-g-t PATCH] tests/gem_wait_render_timeout: make sure the GPU is idle before exiting
@ 2013-05-27 15:42 Imre Deak
  2013-05-28  9:31 ` Daniel Vetter
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Imre Deak @ 2013-05-27 15:42 UTC (permalink / raw)
  To: intel-gfx

Leaving the GPU running after we exit can mess up timing dependent tests
we run afterwards.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64270

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 tests/gem_wait_render_timeout.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tests/gem_wait_render_timeout.c b/tests/gem_wait_render_timeout.c
index 14482e3..9ec4e49 100644
--- a/tests/gem_wait_render_timeout.c
+++ b/tests/gem_wait_render_timeout.c
@@ -216,6 +216,11 @@ int main(int argc, char **argv)
 	assert(gem_bo_wait_timeout(fd, dst2->handle, &timeout) == -ETIME);
 	assert(timeout == 0);
 
+	/* Make sure we exit only after the GPU is idle. Apply some fuzz
+	 * to the timeout since the calibrated iteration count can be
+	 * twice the amount the GPU can execute in a second. */
+	timeout = 5 * ENOUGH_WORK_IN_SECONDS * NSEC_PER_SEC;
+	assert(gem_bo_wait_timeout(fd, dst2->handle, &timeout) == 0);
 
 	if (do_signals)
 		drmtest_stop_signal_helper();
-- 
1.8.1.2

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

* Re: [i-g-t PATCH] tests/gem_wait_render_timeout: make sure the GPU is idle before exiting
  2013-05-27 15:42 [i-g-t PATCH] tests/gem_wait_render_timeout: make sure the GPU is idle before exiting Imre Deak
@ 2013-05-28  9:31 ` Daniel Vetter
  2013-05-28 14:22 ` [i-g-t PATCH v2 1/2] lib: make sure all rings are idle in gpu_quiescent_gpu() Imre Deak
  2013-05-28 14:22 ` [i-g-t PATCH v2 2/2] tests/lib: make sure the GPU is idle at test start and exit Imre Deak
  2 siblings, 0 replies; 6+ messages in thread
From: Daniel Vetter @ 2013-05-28  9:31 UTC (permalink / raw)
  To: Imre Deak; +Cc: intel-gfx

On Mon, May 27, 2013 at 06:42:42PM +0300, Imre Deak wrote:
> Leaving the GPU running after we exit can mess up timing dependent tests
> we run afterwards.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64270
> 
> Signed-off-by: Imre Deak <imre.deak@intel.com>

I've flailed around in this area since forever, see gem_quiescent_gpu in
drmtest.c. I wonder whether we shouldn't just install an atexit handler
with this and maybe for full paranoia run it in drm_open_any, too?

One ugly bug with that function is that it doesn't quiescent all rings on
gen6+ though. So I guess that needs fixing.
-Daniel

> ---
>  tests/gem_wait_render_timeout.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/tests/gem_wait_render_timeout.c b/tests/gem_wait_render_timeout.c
> index 14482e3..9ec4e49 100644
> --- a/tests/gem_wait_render_timeout.c
> +++ b/tests/gem_wait_render_timeout.c
> @@ -216,6 +216,11 @@ int main(int argc, char **argv)
>  	assert(gem_bo_wait_timeout(fd, dst2->handle, &timeout) == -ETIME);
>  	assert(timeout == 0);
>  
> +	/* Make sure we exit only after the GPU is idle. Apply some fuzz
> +	 * to the timeout since the calibrated iteration count can be
> +	 * twice the amount the GPU can execute in a second. */
> +	timeout = 5 * ENOUGH_WORK_IN_SECONDS * NSEC_PER_SEC;
> +	assert(gem_bo_wait_timeout(fd, dst2->handle, &timeout) == 0);
>  
>  	if (do_signals)
>  		drmtest_stop_signal_helper();
> -- 
> 1.8.1.2
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

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

* [i-g-t PATCH v2 1/2] lib: make sure all rings are idle in gpu_quiescent_gpu()
  2013-05-27 15:42 [i-g-t PATCH] tests/gem_wait_render_timeout: make sure the GPU is idle before exiting Imre Deak
  2013-05-28  9:31 ` Daniel Vetter
@ 2013-05-28 14:22 ` Imre Deak
  2013-05-28 14:22 ` [i-g-t PATCH v2 2/2] tests/lib: make sure the GPU is idle at test start and exit Imre Deak
  2 siblings, 0 replies; 6+ messages in thread
From: Imre Deak @ 2013-05-28 14:22 UTC (permalink / raw)
  To: intel-gfx

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 lib/drmtest.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 16f5be1..2d37fb6 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -109,6 +109,7 @@ int gem_available_fences(int fd)
 }
 
 
+#define LOCAL_I915_EXEC_VEBOX	(4 << 0)
 /* Ensure the gpu is idle by launching a nop execbuf and stalling for it. */
 void gem_quiescent_gpu(int fd)
 {
@@ -143,6 +144,21 @@ void gem_quiescent_gpu(int fd)
 
 	do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
 
+	if (gem_has_blt(fd)) {
+		execbuf.flags = I915_EXEC_BLT;
+		do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+	}
+
+	if (gem_has_bsd(fd)) {
+		execbuf.flags = I915_EXEC_BSD;
+		do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+	}
+
+	if (gem_has_vebox(fd)) {
+		execbuf.flags = LOCAL_I915_EXEC_VEBOX;
+		do_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+	}
+
 	gem_sync(fd, handle);
 }
 
-- 
1.8.1.2

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

* [i-g-t PATCH v2 2/2] tests/lib: make sure the GPU is idle at test start and exit
  2013-05-27 15:42 [i-g-t PATCH] tests/gem_wait_render_timeout: make sure the GPU is idle before exiting Imre Deak
  2013-05-28  9:31 ` Daniel Vetter
  2013-05-28 14:22 ` [i-g-t PATCH v2 1/2] lib: make sure all rings are idle in gpu_quiescent_gpu() Imre Deak
@ 2013-05-28 14:22 ` Imre Deak
  2013-05-28 14:35   ` [i-g-t PATCH v3 " Imre Deak
  2 siblings, 1 reply; 6+ messages in thread
From: Imre Deak @ 2013-05-28 14:22 UTC (permalink / raw)
  To: intel-gfx

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64270

v2:
- Make sure also that the GPU is idle at start and error exit of any
  test using drm_open_any(). (Daniel)

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 lib/drmtest.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 2d37fb6..198104d 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -228,7 +228,7 @@ int drm_get_card(int master)
 }
 
 /** Open the first DRM device we can find, searching up to 16 device nodes */
-int drm_open_any(void)
+static int __drm_open_any(void)
 {
 	char *name;
 	int ret, fd;
@@ -248,6 +248,29 @@ int drm_open_any(void)
 	return fd;
 }
 
+static void quiescent_gpu_at_exit(int sig)
+{
+	int fd;
+
+	fd = __drm_open_any();
+	if (fd >= 0)
+		close(fd);
+}
+
+int drm_open_any(void)
+{
+	static int open_count;
+	int fd = __drm_open_any();
+
+	if (fd < 0 || __sync_fetch_and_add(&open_count, 1))
+		return fd;
+
+	gem_quiescent_gpu(fd);
+	drmtest_install_exit_handler(quiescent_gpu_at_exit);
+
+	return fd;
+}
+
 /**
  * Open the first DRM device we can find where we end up being the master.
  */
-- 
1.8.1.2

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

* [i-g-t PATCH v3 2/2] tests/lib: make sure the GPU is idle at test start and exit
  2013-05-28 14:22 ` [i-g-t PATCH v2 2/2] tests/lib: make sure the GPU is idle at test start and exit Imre Deak
@ 2013-05-28 14:35   ` Imre Deak
  2013-05-28 16:33     ` Daniel Vetter
  0 siblings, 1 reply; 6+ messages in thread
From: Imre Deak @ 2013-05-28 14:35 UTC (permalink / raw)
  To: intel-gfx

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64270

v2:
- Make sure also that the GPU is idle at start and error exit of any
  test using drm_open_any(). (Daniel)
v3:
- actually call gem_quiescent_gpu() at exit

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 lib/drmtest.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 2d37fb6..d17dbb0 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -228,7 +228,7 @@ int drm_get_card(int master)
 }
 
 /** Open the first DRM device we can find, searching up to 16 device nodes */
-int drm_open_any(void)
+static int __drm_open_any(void)
 {
 	char *name;
 	int ret, fd;
@@ -248,6 +248,31 @@ int drm_open_any(void)
 	return fd;
 }
 
+static void quiescent_gpu_at_exit(int sig)
+{
+	int fd;
+
+	fd = __drm_open_any();
+	if (fd >= 0) {
+		gem_quiescent_gpu(fd);
+		close(fd);
+	}
+}
+
+int drm_open_any(void)
+{
+	static int open_count;
+	int fd = __drm_open_any();
+
+	if (fd < 0 || __sync_fetch_and_add(&open_count, 1))
+		return fd;
+
+	gem_quiescent_gpu(fd);
+	drmtest_install_exit_handler(quiescent_gpu_at_exit);
+
+	return fd;
+}
+
 /**
  * Open the first DRM device we can find where we end up being the master.
  */
-- 
1.8.1.2

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

* Re: [i-g-t PATCH v3 2/2] tests/lib: make sure the GPU is idle at test start and exit
  2013-05-28 14:35   ` [i-g-t PATCH v3 " Imre Deak
@ 2013-05-28 16:33     ` Daniel Vetter
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Vetter @ 2013-05-28 16:33 UTC (permalink / raw)
  To: Imre Deak; +Cc: intel-gfx

On Tue, May 28, 2013 at 05:35:32PM +0300, Imre Deak wrote:
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64270
> 
> v2:
> - Make sure also that the GPU is idle at start and error exit of any
>   test using drm_open_any(). (Daniel)
> v3:
> - actually call gem_quiescent_gpu() at exit
> 
> Signed-off-by: Imre Deak <imre.deak@intel.com>

Both merged to igt, thanks.
-Daniel

> ---
>  lib/drmtest.c | 27 ++++++++++++++++++++++++++-
>  1 file changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/drmtest.c b/lib/drmtest.c
> index 2d37fb6..d17dbb0 100644
> --- a/lib/drmtest.c
> +++ b/lib/drmtest.c
> @@ -228,7 +228,7 @@ int drm_get_card(int master)
>  }
>  
>  /** Open the first DRM device we can find, searching up to 16 device nodes */
> -int drm_open_any(void)
> +static int __drm_open_any(void)
>  {
>  	char *name;
>  	int ret, fd;
> @@ -248,6 +248,31 @@ int drm_open_any(void)
>  	return fd;
>  }
>  
> +static void quiescent_gpu_at_exit(int sig)
> +{
> +	int fd;
> +
> +	fd = __drm_open_any();
> +	if (fd >= 0) {
> +		gem_quiescent_gpu(fd);
> +		close(fd);
> +	}
> +}
> +
> +int drm_open_any(void)
> +{
> +	static int open_count;
> +	int fd = __drm_open_any();
> +
> +	if (fd < 0 || __sync_fetch_and_add(&open_count, 1))
> +		return fd;
> +
> +	gem_quiescent_gpu(fd);
> +	drmtest_install_exit_handler(quiescent_gpu_at_exit);
> +
> +	return fd;
> +}
> +
>  /**
>   * Open the first DRM device we can find where we end up being the master.
>   */
> -- 
> 1.8.1.2
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

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

end of thread, other threads:[~2013-05-28 16:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-27 15:42 [i-g-t PATCH] tests/gem_wait_render_timeout: make sure the GPU is idle before exiting Imre Deak
2013-05-28  9:31 ` Daniel Vetter
2013-05-28 14:22 ` [i-g-t PATCH v2 1/2] lib: make sure all rings are idle in gpu_quiescent_gpu() Imre Deak
2013-05-28 14:22 ` [i-g-t PATCH v2 2/2] tests/lib: make sure the GPU is idle at test start and exit Imre Deak
2013-05-28 14:35   ` [i-g-t PATCH v3 " Imre Deak
2013-05-28 16:33     ` Daniel Vetter

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.