Skip to contentSkip to conversation

lib: Add some syncobj helpers

PATCH New Jason Ekstrand 2 participants 5 messages Aug 10, 2017 – Aug 11, 2017 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 lib: Add some syncobj helpers

---
 lib/Makefile.sources |   2 +
 lib/igt_syncobj.c    | 186 +++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_syncobj.h    |  66 ++++++++++++++++++
 3 files changed, 254 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 +186 -0

186 lines not on this page · raw message

lib/igt_syncobj.h new file +66 -0

66 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..b08dd2d 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);
 	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);
+	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 lib/igt_vgem: Add a syncobj attach helper

In reply to Jason Ekstrand
---
 lib/igt_vgem.c | 25 ++++++++++++++++++++++++-
 lib/igt_vgem.h |  1 +
 2 files changed, 25 insertions(+), 1 deletion(-)
lib/igt_vgem.c +24 -1
index 21cccb3..069c6dd 100644
@@ -101,8 +101,9 @@ void *vgem_mmap(int fd, struct vgem_bo *bo, unsigned prot)
 struct local_vgem_fence_attach {
 	uint32_t handle;
 	uint32_t flags;
+#define LOCAL_VGEM_FENCE_SYNCOBJ	0x2
 	uint32_t out_fence;
-	uint32_t pad;
+	uint32_t syncobj;
 };
 
 struct local_vgem_fence_signal {
@@ -167,6 +168,28 @@ uint32_t vgem_fence_attach(int fd, struct vgem_bo *bo, unsigned flags)
 	return arg.out_fence;
 }
 
+uint32_t vgem_fence_attach_syncobj(int fd, uint32_t syncobj)
+{
+	struct local_vgem_fence_attach arg;
+	struct vgem_bo bo;
+
+	/* Create a dummy BO so the import works */
+	bo.width = 1;
+	bo.height = 1;
+	bo.bpp = 4;
+	vgem_create(fd, &bo);
+
+	memset(&arg, 0, sizeof(arg));
+	arg.handle = bo.handle;
+	arg.syncobj = syncobj;
+	arg.flags = LOCAL_VGEM_FENCE_SYNCOBJ;
+	igt_assert_eq(__vgem_fence_attach(fd, &arg), 0);
+
+	gem_close(fd, bo.handle);
+
+	return arg.out_fence;
+}
+
 static int ioctl_vgem_fence_signal(int fd, struct local_vgem_fence_signal *arg)
 {
 	int err = 0;
lib/igt_vgem.h +1 -0
index 002ad7f..555674b 100644
@@ -44,6 +44,7 @@ bool vgem_fence_has_flag(int fd, unsigned flags);
 uint32_t vgem_fence_attach(int fd, struct vgem_bo *bo, unsigned flags);
 #define VGEM_FENCE_WRITE 0x1
 #define WIP_VGEM_FENCE_NOTIMEOUT 0x2
+uint32_t vgem_fence_attach_syncobj(int fd, uint32_t syncobj);
 int __vgem_fence_signal(int fd, uint32_t fence);
 void vgem_fence_signal(int fd, uint32_t fence);
 
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 tests/syncobj: Add some wait and reset tests (v5)

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   | 746 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 747 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 +746 -0

746 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
#4 lore raw

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

In reply to Jason Ekstrand
== Series Details ==

== Series Details ==

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

== Summary ==

IGT patchset tested on top of latest successful build 1385b31d9371fae02af2fd8adb0d9ea86a5bb0f2 tests/igt_command_line: Ignore subtest list for kms_ccs

with latest DRM-Tip kernel build CI_DRM_2948
fbb8288699ef drm-tip: 2017y-08m-11d-09h-03m-47s UTC integration manifest

Test kms_flip:

        Subgroup basic-flip-vs-modeset:
                skip       -> PASS       (fi-skl-x1585l) fdo#101781
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-b:
                dmesg-warn -> PASS       (fi-byt-n2820) fdo#101705

fdo#101781 https://bugs.freedesktop.org/show_bug.cgi?id=101781
fdo#101705 https://bugs.freedesktop.org/show_bug.cgi?id=101705

fi-bdw-5557u     total:279  pass:268  dwarn:0   dfail:0   fail:0   skip:11  time:449s
fi-bdw-gvtdvm    total:279  pass:265  dwarn:0   dfail:0   fail:0   skip:14  time:433s
fi-blb-e6850     total:279  pass:224  dwarn:1   dfail:0   fail:0   skip:54  time:358s
fi-bsw-n3050     total:279  pass:243  dwarn:0   dfail:0   fail:0   skip:36  time:544s
fi-bxt-j4205     total:279  pass:260  dwarn:0   dfail:0   fail:0   skip:19  time:512s
fi-byt-j1900     total:279  pass:254  dwarn:1   dfail:0   fail:0   skip:24  time:521s
fi-byt-n2820     total:279  pass:251  dwarn:0   dfail:0   fail:0   skip:28  time:511s
fi-glk-2a        total:279  pass:260  dwarn:0   dfail:0   fail:0   skip:19  time:604s
fi-hsw-4770      total:279  pass:263  dwarn:0   dfail:0   fail:0   skip:16  time:449s
fi-hsw-4770r     total:279  pass:263  dwarn:0   dfail:0   fail:0   skip:16  time:415s
fi-ilk-650       total:279  pass:229  dwarn:0   dfail:0   fail:0   skip:50  time:422s
fi-ivb-3520m     total:279  pass:261  dwarn:0   dfail:0   fail:0   skip:18  time:511s
fi-ivb-3770      total:279  pass:261  dwarn:0   dfail:0   fail:0   skip:18  time:478s
fi-kbl-7500u     total:279  pass:261  dwarn:0   dfail:0   fail:0   skip:18  time:473s
fi-kbl-7560u     total:279  pass:269  dwarn:0   dfail:0   fail:0   skip:10  time:587s
fi-kbl-r         total:279  pass:261  dwarn:0   dfail:0   fail:0   skip:18  time:591s
fi-pnv-d510      total:279  pass:223  dwarn:1   dfail:0   fail:0   skip:55  time:518s
fi-skl-6260u     total:279  pass:269  dwarn:0   dfail:0   fail:0   skip:10  time:465s
fi-skl-6700k     total:279  pass:261  dwarn:0   dfail:0   fail:0   skip:18  time:473s
fi-skl-6770hq    total:279  pass:269  dwarn:0   dfail:0   fail:0   skip:10  time:483s
fi-skl-gvtdvm    total:279  pass:266  dwarn:0   dfail:0   fail:0   skip:13  time:439s
fi-skl-x1585l    total:279  pass:269  dwarn:0   dfail:0   fail:0   skip:10  time:495s
fi-snb-2520m     total:279  pass:251  dwarn:0   dfail:0   fail:0   skip:28  time:548s
fi-snb-2600      total:279  pass:250  dwarn:0   dfail:0   fail:0   skip:29  time:409s

== Logs ==

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