Skip to contentSkip to conversation

lib: Add some syncobj helpers (v2)

PATCH New Jason Ekstrand 2 participants 6 messages Aug 25, 2017 – Aug 26, 2017 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 lib: Add some syncobj helpers (v2)

---
 lib/Makefile.sources |   2 +
 lib/igt_syncobj.c    | 207 +++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_syncobj.h    |  71 ++++++++++++++++++
 3 files changed, 280 insertions(+)
 create mode 100644 lib/igt_syncobj.c
 create mode 100644 lib/igt_syncobj.h
lib/Makefile.sources +2 -0
index 53fdb54..692fe30 100644
@@ -83,6 +83,8 @@ lib_source_list =	 	\
 	uwildmat/uwildmat.c	\
 	igt_kmod.c		\
 	igt_kmod.h		\
+	igt_syncobj.c		\
+	igt_syncobj.h		\
 	$(NULL)
 
 .PHONY: version.h.tmp
lib/igt_syncobj.c new file +207 -0

207 lines not on this page · raw message

lib/igt_syncobj.h new file +71 -0

71 lines not on this page · raw message

Signature · 6 lines
2.5.0.400.gff86faf

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

PATCH 2/4 tests/syncobj: Convert the basic test over to the helpers

---
 tests/syncobj_basic.c | 77 +++++++++++++--------------------------------------
 1 file changed, 19 insertions(+), 58 deletions(-)
tests/syncobj_basic.c +19 -58
index a7a6742..0a304f1 100644
@@ -22,6 +22,7 @@
  */
 
 #include "igt.h"
+#include "igt_syncobj.h"
 #include <unistd.h>
 #include <sys/ioctl.h>
 #include "drm.h"
@@ -48,14 +49,11 @@ static void
 test_bad_handle_to_fd(int fd)
 {
 	struct drm_syncobj_handle handle;
-	int ret;
 
 	handle.handle = 0xdeadbeef;
 	handle.flags = 0;
 
-	ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &handle);
-
-	igt_assert(ret == -1 && errno == EINVAL);
+	igt_assert_eq(__syncobj_handle_to_fd(fd, &handle), -EINVAL);
 }
 
 /* fd to handle a bad fd */
@@ -63,14 +61,11 @@ static void
 test_bad_fd_to_handle(int fd)
 {
 	struct drm_syncobj_handle handle;
-	int ret;
 
 	handle.fd = -1;
 	handle.flags = 0;
 
-	ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &handle);
-
-	igt_assert(ret == -1 && errno == EINVAL);
+	igt_assert_eq(__syncobj_fd_to_handle(fd, &handle), -EINVAL);
 }
 
 /* fd to handle an fd but not a sync file one */
@@ -78,58 +73,47 @@ static void
 test_illegal_fd_to_handle(int fd)
 {
 	struct drm_syncobj_handle handle;
-	int ret;
 
 	handle.fd = fd;
 	handle.flags = 0;
 
-	ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &handle);
-
-	igt_assert(ret == -1 && errno == EINVAL);
+	igt_assert_eq(__syncobj_fd_to_handle(fd, &handle), -EINVAL);
 }
 
 static void
 test_bad_flags_fd_to_handle(int fd)
 {
 	struct drm_syncobj_handle handle = { 0 };
-	int ret;
 
 	handle.flags = 0xdeadbeef;
-	ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &handle);
-	igt_assert(ret == -1 && errno == EINVAL);
+	igt_assert_eq(__syncobj_fd_to_handle(fd, &handle), -EINVAL);
 }
 
 static void
 test_bad_flags_handle_to_fd(int fd)
 {
 	struct drm_syncobj_handle handle = { 0 };
-	int ret;
 
 	handle.flags = 0xdeadbeef;
-	ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &handle);
-	igt_assert(ret == -1 && errno == EINVAL);
+	igt_assert_eq(__syncobj_handle_to_fd(fd, &handle), -EINVAL);
 }
 
 static void
 test_bad_pad_handle_to_fd(int fd)
 {
 	struct drm_syncobj_handle handle = { 0 };
-	int ret;
 
 	handle.pad = 0xdeadbeef;
-	ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &handle);
-	igt_assert(ret == -1 && errno == EINVAL);
+	igt_assert_eq(__syncobj_handle_to_fd(fd, &handle), -EINVAL);
 }
 
 static void
 test_bad_pad_fd_to_handle(int fd)
 {
 	struct drm_syncobj_handle handle = { 0 };
-	int ret;
 
 	handle.pad = 0xdeadbeef;
-	ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &handle);
-	igt_assert(ret == -1 && errno == EINVAL);
+	igt_assert_eq(__syncobj_fd_to_handle(fd, &handle), -EINVAL);
 }
 
 
@@ -138,24 +122,17 @@ test_bad_pad_fd_to_handle(int fd)
 static void
 test_bad_destroy_pad(int fd)
 {
-	struct drm_syncobj_create create = { 0 };
 	struct drm_syncobj_destroy destroy;
 	int ret;
 
-	ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &create);
-
-	destroy.handle = create.handle;
+	destroy.handle = syncobj_create(fd, 0);
 	destroy.pad = 0xdeadbeef;
 
 	ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &destroy);
 
 	igt_assert(ret == -1 && errno == EINVAL);
 
-	destroy.handle = create.handle;
-	destroy.pad = 0;
-
-	ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &destroy);
-	igt_assert(ret == 0);
+	syncobj_destroy(fd, destroy.handle);
 }
 
 static void
@@ -176,34 +153,18 @@ test_bad_create_flags(int fd)
 static void
 test_valid_cycle(int fd)
 {
-	int ret;
-	struct drm_syncobj_create create = { 0 };
-	struct drm_syncobj_handle handle = { 0 };
-	struct drm_syncobj_destroy destroy = { 0 };
-	uint32_t first_handle;
-
-	ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &create);
-	igt_assert(ret == 0);
+	uint32_t first_handle, second_handle;
+	int syncobj_fd;
 
-	first_handle = create.handle;
+	first_handle = syncobj_create(fd, 0);
+	syncobj_fd = syncobj_handle_to_fd(fd, first_handle, 0);
+	second_handle = syncobj_fd_to_handle(fd, syncobj_fd, 0);
+	close(syncobj_fd);
 
-	handle.handle = create.handle;
-	ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &handle);
-	igt_assert(ret == 0);
-	handle.handle = 0;
-	ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &handle);
-	close(handle.fd);
-	igt_assert(ret == 0);
+	igt_assert(first_handle != second_handle);
 
-	igt_assert(handle.handle != first_handle);
-
-	destroy.handle = handle.handle;
-	ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &destroy);
-	igt_assert(ret == 0);
-
-	destroy.handle = first_handle;
-	ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &destroy);
-	igt_assert(ret == 0);
+	syncobj_destroy(fd, first_handle);
+	syncobj_destroy(fd, second_handle);
 }
 
 static bool has_syncobj(int fd)
Signature · 6 lines
2.5.0.400.gff86faf

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

PATCH 3/4 tests/syncobj: Add some wait and reset tests (v6)

In reply to Jason Ekstrand

This adds both trivial error-checking tests as well as more complex tests which actually test whether or not waits do what they're supposed to do. They only currently work on i915 but it should be simple to hook them up for other drivers by simply implementing the little function pointer hook provided at the top for triggering a syncobj.

v2:
- Actually add the reset tests.
v3:
- Only do one execbuf for trigger
- Use do_ioctl and do_ioctl_err
- Better check for syncobj support
- Add local_/LOCAL_ defines of things
- Use a timer instead of a pthread
v4:
- Use ioctl wrappers
- Use VGEM instead of i915
- Combine a bunch of the simple tests into one function
v5:
- Combinatorially generate basic tests
- Use sw_sync instead of using vgem directly
- Add even more tests

---
 tests/Makefile.sources |   1 +
 tests/syncobj_wait.c   | 909 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 910 insertions(+)
 create mode 100644 tests/syncobj_wait.c
tests/Makefile.sources +1 -0
index bb013c7..430b637 100644
@@ -230,6 +230,7 @@ TESTS_progs = \
 	prime_vgem \
 	sw_sync \
 	syncobj_basic \
+	syncobj_wait \
 	template \
 	tools_test \
 	vgem_basic \
tests/syncobj_wait.c new file +909 -0

909 lines not on this page · raw message

Signature · 6 lines
2.5.0.400.gff86faf

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

PATCH 4/4 syncobj: Add a test for SYNCOBJ_CREATE_SIGNALED

In reply to Jason Ekstrand
---
 tests/syncobj_basic.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tests/syncobj_basic.c +13 -0
index 0a304f1..acc4a64 100644
@@ -146,6 +146,16 @@ test_bad_create_flags(int fd)
 	igt_assert(ret == -1 && errno == EINVAL);
 }
 
+static void
+test_create_signaled(int fd)
+{
+	uint32_t syncobj = syncobj_create(fd, LOCAL_SYNCOBJ_CREATE_SIGNALED);
+
+	igt_assert_eq(syncobj_wait_err(fd, &syncobj, 1, 0, 0), 0);
+
+	syncobj_destroy(fd, syncobj);
+}
+
 /*
  * currently don't do handle deduplication
  * test we get a different handle back.
@@ -215,6 +225,9 @@ igt_main
 	igt_subtest("bad-destroy-pad")
 		test_bad_destroy_pad(fd);
 
+	igt_subtest("create-signaled")
+		test_create_signaled(fd);
+
 	igt_subtest("test-valid-cycle")
 		test_valid_cycle(fd);
 
Signature · 6 lines
2.5.0.400.gff86faf

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

✓ Fi.CI.BAT: success for series starting with [1/4] lib: Add some syncobj helpers (v2)

In reply to Jason Ekstrand
== Series Details ==

== Series Details ==

Series: series starting with [1/4] lib: Add some syncobj helpers (v2)
URL : https://patchwork.freedesktop.org/series/29370/
State : success

== Summary ==

IGT patchset tested on top of latest successful build 29d488034a50cd6fbad792cae61321995f0ab51c aubdump: Log some information about the execbuf calls

with latest DRM-Tip kernel build CI_DRM_3006
4823f19b979c drm-tip: 2017y-08m-25d-15h-55m-05s UTC integration manifest

Test gem_exec_flush:

        Subgroup basic-batch-kernel-default-uc:
                fail       -> PASS       (fi-snb-2600) fdo#100007
Test kms_cursor_legacy:
        Subgroup basic-busy-flip-before-cursor-atomic:
                fail       -> PASS       (fi-snb-2600) fdo#100215 +1

fdo#100007 https://bugs.freedesktop.org/show_bug.cgi?id=100007
fdo#100215 https://bugs.freedesktop.org/show_bug.cgi?id=100215

fi-bdw-5557u     total:279  pass:267  dwarn:1   dfail:0   fail:0   skip:11  time:455s
fi-bdw-gvtdvm    total:279  pass:265  dwarn:0   dfail:0   fail:0   skip:14  time:439s
fi-blb-e6850     total:279  pass:224  dwarn:1   dfail:0   fail:0   skip:54  time:365s
fi-bsw-n3050     total:279  pass:243  dwarn:0   dfail:0   fail:0   skip:36  time:555s
fi-bwr-2160      total:279  pass:184  dwarn:0   dfail:0   fail:0   skip:95  time:252s
fi-bxt-j4205     total:279  pass:260  dwarn:0   dfail:0   fail:0   skip:19  time:527s
fi-byt-j1900     total:279  pass:254  dwarn:1   dfail:0   fail:0   skip:24  time:527s
fi-byt-n2820     total:279  pass:250  dwarn:1   dfail:0   fail:0   skip:28  time:519s
fi-elk-e7500     total:279  pass:230  dwarn:0   dfail:0   fail:0   skip:49  time:438s
fi-glk-2a        total:279  pass:260  dwarn:0   dfail:0   fail:0   skip:19  time:615s
fi-hsw-4770      total:279  pass:263  dwarn:0   dfail:0   fail:0   skip:16  time:446s
fi-hsw-4770r     total:279  pass:263  dwarn:0   dfail:0   fail:0   skip:16  time:431s
fi-ilk-650       total:279  pass:229  dwarn:0   dfail:0   fail:0   skip:50  time:426s
fi-ivb-3520m     total:279  pass:261  dwarn:0   dfail:0   fail:0   skip:18  time:512s
fi-ivb-3770      total:279  pass:261  dwarn:0   dfail:0   fail:0   skip:18  time:482s
fi-kbl-7500u     total:279  pass:261  dwarn:0   dfail:0   fail:0   skip:18  time:481s
fi-kbl-7560u     total:279  pass:269  dwarn:0   dfail:0   fail:0   skip:10  time:602s
fi-kbl-r         total:279  pass:261  dwarn:0   dfail:0   fail:0   skip:18  time:603s
fi-pnv-d510      total:279  pass:223  dwarn:1   dfail:0   fail:0   skip:55  time:521s
fi-skl-6260u     total:279  pass:269  dwarn:0   dfail:0   fail:0   skip:10  time:476s
fi-skl-6700k     total:279  pass:261  dwarn:0   dfail:0   fail:0   skip:18  time:477s
fi-skl-6770hq    total:279  pass:269  dwarn:0   dfail:0   fail:0   skip:10  time:495s
fi-skl-gvtdvm    total:279  pass:266  dwarn:0   dfail:0   fail:0   skip:13  time:441s
fi-skl-x1585l    total:279  pass:268  dwarn:0   dfail:0   fail:0   skip:11  time:483s
fi-snb-2520m     total:279  pass:251  dwarn:0   dfail:0   fail:0   skip:28  time:555s
fi-snb-2600      total:279  pass:250  dwarn:0   dfail:0   fail:0   skip:29  time:408s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_103/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw

✓ Fi.CI.IGT: success for series starting with [1/4] lib: Add some syncobj helpers (v2)

In reply to Jason Ekstrand
== Series Details ==

== Series Details ==

Series: series starting with [1/4] lib: Add some syncobj helpers (v2)
URL : https://patchwork.freedesktop.org/series/29370/
State : success

== Summary ==

Test kms_setmode:

        Subgroup basic:
                fail       -> PASS       (shard-hsw) fdo#99912
Test perf:
        Subgroup polling:
                pass       -> FAIL       (shard-hsw) fdo#102252

fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252

shard-hsw total:2300 pass:1230 dwarn:0 dfail:0 fail:19 skip:1051 time:9632s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_103/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx