tests/gem_wait_render_timeout: make sure the GPU is idle before exiting
PATCH 1/1 tests/gem_wait_render_timeout: make sure the GPU is idle before exiting
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
--- tests/gem_wait_render_timeout.c | 5 +++++ 1 file changed, 5 insertions(+)
tests/gem_wait_render_timeout.c +5 -0
@@ -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 ();
Signature · 1 line
1.8.1.2
Quoted 6 lines · Imre Deak
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 <[email protected]>
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
Quoted 27 lines
--- tests/gem_wait_render_timeout.c | 5 +++++ 1 file changed, 5 insertions(+)tests/gem_wait_render_timeout.c +5
-0@@ -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 ();Signature · 6 lines
1.8.1.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH v2 1/2 lib: make sure all rings are idle in gpu_quiescent_gpu()
In reply to Imre Deak--- lib/drmtest.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
lib/drmtest.c +16 -0
@@ -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); }
Signature · 1 line
1.8.1.2
PATCH v2 2/2 tests/lib: make sure the GPU is idle at test start and exit
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)
--- lib/drmtest.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
lib/drmtest.c +24 -1
@@ -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. */
Signature · 1 line
1.8.1.2
PATCH v3 2/2 tests/lib: make sure the GPU is idle at test start and exit
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
--- lib/drmtest.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
lib/drmtest.c +26 -1
@@ -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. */
Signature · 1 line
1.8.1.2
Re: [i-g-t PATCH v3 2/2] tests/lib: make sure the GPU is idle at test start and exit
Quoted 9 lines · Imre Deak
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 usingdrm_open_any(). (Daniel)
v3:
- actually callgem_quiescent_gpu()at exitSigned-off-by Imre Deak <[email protected]>
Both merged to igt, thanks.
-Daniel
Quoted 56 lines
--- lib/drmtest.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)lib/drmtest.c +26
-1@@ -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. */ Signature · 6 lines
1.8.1.2 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch