[igt-dev] [PATCH i-g-t v5 3/4] lib/xe/xe_spin: Handle spinner timer for Xe as well

Jouni Högander jouni.hogander at intel.com
Mon Jun 19 12:56:32 UTC 2023


Current spinner implementation for Xe doesn't support setting
timeout. Fix this by handling timers same way as for i915 as well.

Cc: Sai Gowtham Ch <sai.gowtham.ch at intel.com>

Signed-off-by: Jouni Högander <jouni.hogander at intel.com>
---
 lib/xe/xe_spin.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/xe/xe_spin.c b/lib/xe/xe_spin.c
index 9f511e14f..d8c665f39 100644
--- a/lib/xe/xe_spin.c
+++ b/lib/xe/xe_spin.c
@@ -115,6 +115,7 @@ xe_spin_create(int fd, const struct igt_spin_factory *opt)
 	spin->syncobj = syncobj_create(fd, 0);
 	spin->vm = opt->vm;
 	spin->engine = opt->engine;
+	spin->timerfd = -1;
 
 	if (!spin->vm)
 		spin->vm = xe_vm_create(fd, 0, 0);
@@ -163,6 +164,13 @@ void xe_spin_sync_wait(int fd, struct igt_spin *spin)
 void xe_spin_free(int fd, struct igt_spin *spin)
 {
 	igt_assert(spin->driver == INTEL_DRIVER_XE);
+
+	if (spin->timerfd >= 0) {
+		pthread_cancel(spin->timer_thread);
+		igt_assert(pthread_join(spin->timer_thread, NULL) == 0);
+		close(spin->timerfd);
+	}
+
 	xe_spin_end(spin->xe_spin);
 	xe_spin_sync_wait(fd, spin);
 	xe_vm_unbind_sync(fd, spin->vm, 0, spin->address, spin->bo_size);
-- 
2.34.1



More information about the igt-dev mailing list