tests: Add drm_import_export
PATCH 1/2 tests: Add drm_import_export
Multithreaded test to validate the (lack of) locking in the flink/open code in libdrm-intel. Based on a testcase from Rafel Sapala.
Cc Rafal Sapala <[email protected]>
Signed-off-by Daniel Vetter <[email protected]>
--- tests/.gitignore | 1 + tests/Makefile.am | 2 + tests/Makefile.sources | 1 + tests/drm_import_export.c | 145 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 149 insertions(+) create mode 100644 tests/drm_import_export.c
tests/.gitignore +1 -0
@@ -4,6 +4,7 @@ core_getclient core_getstats core_getversion ddi_compute_wrpll +drm_import_export drm_vma_limiter drm_vma_limiter_cached drm_vma_limiter_cpu
tests/Makefile.am +2 -0
@@ -44,6 +44,8 @@ LDADD = ../lib/libintel_tools.la $(PCIACCESS_LIBS) $(DRM_LIBS) LDADD += $(CAIRO_LIBS) $(LIBUDEV_LIBS) $(GLIB_LIBS) AM_CFLAGS += $(CAIRO_CFLAGS) $(LIBUDEV_CFLAGS) $(GLIB_CFLAGS) +drm_import_export_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS) +drm_import_export_LDADD = $(LDADD) -lpthread gem_close_race_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS) gem_close_race_LDADD = $(LDADD) -lpthread gem_ctx_basic_CFLAGS = $(AM_CFLAGS) $(THREAD_CFLAGS)
tests/Makefile.sources +1 -0
@@ -89,6 +89,7 @@ TESTS_progs = \ core_getclient \ core_getstats \ core_getversion \ + drm_import_export \ drm_vma_limiter \ drm_vma_limiter_cached \ drm_vma_limiter_cpu \
tests/drm_import_export.c new file +145 -0
145 lines not on this page · raw message
Signature · 6 lines
1.9.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 tests/drm_import_export: Add subtest for prime
Cc Rafal Sapala <[email protected]>
Signed-off-by Daniel Vetter <[email protected]>
--- tests/drm_import_export.c | 90 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 28 deletions(-)
tests/drm_import_export.c +62 -28
@@ -48,6 +48,8 @@ drm_intel_bufmgr *bufmgr;int fd1;drm_intel_bufmgr *bufmgr1; +bool use_flink; +static void new_buffers (void ) {unsigned int *buf1;
@@ -82,12 +84,24 @@ static void test_surfaces(drm_intel_bo *bo_shared)int loop=2 ;while (loop--) { -struct drm_gem_open op; - -drm_intel_bo_flink (bo_shared, &op.name); - bo =drm_intel_bo_gem_create_from_name ( bufmgr,"shared resource" , op.name ); +if (use_flink) { +uint32_t name; +drm_intel_bo_flink (bo_shared, &name); + bo =drm_intel_bo_gem_create_from_name (bufmgr, +"shared resource" , + name); + }else { +int prime_fd; + +drm_intel_bo_gem_export_to_prime (bo_shared, &prime_fd); + bo =drm_intel_bo_gem_create_from_prime (bufmgr, + prime_fd,4096 ); +close (prime_fd); + } + +igt_assert (bo);new_buffers (); -drm_intel_bo_unreference ( bo ); +drm_intel_bo_unreference (bo); } }
@@ -113,33 +127,53 @@ static void * test_thread(void * par)return NULL ; } -igt_simple_main { -pthread_t test_thread_id1; -pthread_t test_thread_id2; -pthread_t test_thread_id3; -pthread_t test_thread_id4; +pthread_t test_thread_id1; +pthread_t test_thread_id2; +pthread_t test_thread_id3; +pthread_t test_thread_id4; - fd1 =drm_open_any (); -igt_assert (fd1 >=0 ); - bufmgr1 =drm_intel_bufmgr_gem_init ( fd1,8 *1024 ); -igt_assert (bufmgr1); +igt_main { + igt_fixture { + fd1 =drm_open_any (); +igt_assert (fd1 >=0 ); + bufmgr1 =drm_intel_bufmgr_gem_init (fd1,8 *1024 ); +igt_assert (bufmgr1); -drm_intel_bufmgr_gem_enable_reuse ( bufmgr1); +drm_intel_bufmgr_gem_enable_reuse (bufmgr1); - fd =drm_open_any (); -igt_assert (fd >=0 ); - bufmgr =drm_intel_bufmgr_gem_init ( fd,8 *1024 ); -igt_assert (bufmgr); + fd =drm_open_any (); +igt_assert (fd >=0 ); + bufmgr =drm_intel_bufmgr_gem_init (fd,8 *1024 ); +igt_assert (bufmgr); -drm_intel_bufmgr_gem_enable_reuse ( bufmgr); +drm_intel_bufmgr_gem_enable_reuse (bufmgr); + } -pthread_create (&test_thread_id1,NULL , test_thread,NULL ); -pthread_create (&test_thread_id2,NULL , test_thread,NULL ); -pthread_create (&test_thread_id3,NULL , test_thread,NULL ); -pthread_create (&test_thread_id4,NULL , test_thread,NULL ); + igt_subtest("flink") { + use_flink = true; -pthread_join (test_thread_id1,NULL ); -pthread_join (test_thread_id2,NULL ); -pthread_join (test_thread_id3,NULL ); -pthread_join (test_thread_id4,NULL ); +pthread_create (&test_thread_id1,NULL , test_thread,NULL ); +pthread_create (&test_thread_id2,NULL , test_thread,NULL ); +pthread_create (&test_thread_id3,NULL , test_thread,NULL ); +pthread_create (&test_thread_id4,NULL , test_thread,NULL ); + +pthread_join (test_thread_id1,NULL ); +pthread_join (test_thread_id2,NULL ); +pthread_join (test_thread_id3,NULL ); +pthread_join (test_thread_id4,NULL ); + } + + igt_subtest("prime") { + use_flink = false; + +pthread_create (&test_thread_id1,NULL , test_thread,NULL ); +pthread_create (&test_thread_id2,NULL , test_thread,NULL ); +pthread_create (&test_thread_id3,NULL , test_thread,NULL ); +pthread_create (&test_thread_id4,NULL , test_thread,NULL ); + +pthread_join (test_thread_id1,NULL ); +pthread_join (test_thread_id2,NULL ); +pthread_join (test_thread_id3,NULL ); +pthread_join (test_thread_id4,NULL ); + } }
Signature · 1 line
1.9.3