[i-g-t 27/27] tests/i915/kms_busy: Use execbuf3 spinner

Bhanuprakash Modem bhanuprakash.modem at intel.com
Mon Jan 23 09:43:35 UTC 2023


Add support to use execbuf3 spinner.

Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
---
 tests/i915/kms_busy.c | 96 +++++++++++++++++++++++++++++++++++++++----
 1 file changed, 87 insertions(+), 9 deletions(-)

diff --git a/tests/i915/kms_busy.c b/tests/i915/kms_busy.c
index b0642612..b578961a 100644
--- a/tests/i915/kms_busy.c
+++ b/tests/i915/kms_busy.c
@@ -26,6 +26,7 @@
 #include <time.h>
 
 #include "i915/gem.h"
+#include "i915/gem_vm.h"
 #include "igt.h"
 
 IGT_TEST_DESCRIPTION("Basic check of KMS ABI with busy framebuffers.");
@@ -79,16 +80,39 @@ static void flip_to_fb(igt_display_t *dpy, int pipe,
 	struct pollfd pfd = { .fd = dpy->drm_fd, .events = POLLIN };
 	struct drm_event_vblank ev;
 	IGT_CORK_FENCE(cork);
-	uint64_t ahnd = get_reloc_ahnd(dpy->drm_fd, 0);
+	uint64_t ahnd;
 	igt_spin_t *t;
 	int fence;
+	uint32_t vm_id = 0;
+	unsigned int spin_flags = IGT_SPIN_FENCE_IN;
+
+	if (gem_has_vm(dpy->drm_fd)) {
+		struct drm_i915_gem_context_param param = {
+			.param = I915_CONTEXT_PARAM_RECOVERABLE,
+			.value = 0,
+		};
+
+		vm_id = gem_vm_create_in_vm_bind_mode(dpy->drm_fd);
+
+		gem_context_set_param(dpy->drm_fd, &param);
+		gem_context_set_vm(dpy->drm_fd, 0, vm_id);
+
+		vm_id = gem_context_get_vm(dpy->drm_fd, 0);
+		ahnd = get_simple_ahnd(dpy->drm_fd, 0);
+
+		spin_flags |= IGT_SPIN_EXECBUF3 | IGT_SPIN_NO_PREEMPTION;
+	} else {
+		ahnd = get_reloc_ahnd(dpy->drm_fd, 0);
+	}
 
 	fence = igt_cork_plug(&cork, dpy->drm_fd);
 	t = igt_spin_new(dpy->drm_fd,
 			 .ahnd = ahnd,
+			 .ctx = 0,
+			 .vm_id = vm_id,
 			 .fence = fence,
 			 .dependency = fb->gem_handle,
-			 .flags = IGT_SPIN_FENCE_IN);
+			 .flags = spin_flags);
 	close(fence);
 
 	igt_fork(child, 1) {
@@ -133,6 +157,8 @@ static void flip_to_fb(igt_display_t *dpy, int pipe,
 	}
 
 	igt_spin_free(dpy->drm_fd, t);
+	if (vm_id)
+		gem_vm_destroy(dpy->drm_fd, vm_id);
 	put_ahnd(ahnd);
 }
 
@@ -187,14 +213,39 @@ static void test_flip(igt_display_t *dpy, int pipe, bool modeset)
 static void test_atomic_commit_hang(igt_display_t *dpy, igt_plane_t *primary,
 				    struct igt_fb *busy_fb)
 {
-	uint64_t ahnd = get_reloc_ahnd(dpy->drm_fd, 0);
-	igt_spin_t *t = igt_spin_new(dpy->drm_fd,
-				     .ahnd = ahnd,
-				     .dependency = busy_fb->gem_handle,
-				     .flags = IGT_SPIN_NO_PREEMPTION);
+	uint64_t ahnd;
+	uint32_t vm_id = 0;
+	igt_spin_t *t;
 	struct pollfd pfd = { .fd = dpy->drm_fd, .events = POLLIN };
 	unsigned flags = 0;
 	struct drm_event_vblank ev;
+	unsigned int spin_flags = IGT_SPIN_NO_PREEMPTION;
+
+	if (gem_has_vm(dpy->drm_fd)) {
+		struct drm_i915_gem_context_param param = {
+			.param = I915_CONTEXT_PARAM_RECOVERABLE,
+			.value = 0,
+		};
+
+		vm_id = gem_vm_create_in_vm_bind_mode(dpy->drm_fd);
+
+		gem_context_set_param(dpy->drm_fd, &param);
+		gem_context_set_vm(dpy->drm_fd, 0, vm_id);
+
+		vm_id = gem_context_get_vm(dpy->drm_fd, 0);
+		ahnd = get_simple_ahnd(dpy->drm_fd, 0);
+
+		spin_flags |= IGT_SPIN_EXECBUF3;
+	} else {
+		ahnd = get_reloc_ahnd(dpy->drm_fd, 0);
+	}
+
+	t = igt_spin_new(dpy->drm_fd,
+			 .ahnd = ahnd,
+			 .ctx = 0,
+			 .vm_id = vm_id,
+			 .dependency = busy_fb->gem_handle,
+			 .flags = spin_flags);
 
 	flags |= DRM_MODE_ATOMIC_ALLOW_MODESET;
 	flags |= DRM_MODE_ATOMIC_NONBLOCK;
@@ -220,6 +271,8 @@ static void test_atomic_commit_hang(igt_display_t *dpy, igt_plane_t *primary,
 	igt_assert(read(dpy->drm_fd, &ev, sizeof(ev)) == sizeof(ev));
 
 	igt_spin_end(t);
+	if (vm_id)
+		gem_vm_destroy(dpy->drm_fd, vm_id);
 	put_ahnd(ahnd);
 }
 
@@ -272,7 +325,28 @@ static void test_pageflip_modeset_hang(igt_display_t *dpy, enum pipe pipe)
 	igt_output_t *output;
 	igt_plane_t *primary;
 	igt_spin_t *t;
-	uint64_t ahnd = get_reloc_ahnd(dpy->drm_fd, 0);
+	uint64_t ahnd;
+	uint32_t vm_id = 0;
+	unsigned int spin_flags = IGT_SPIN_NO_PREEMPTION;
+
+	if (gem_has_vm(dpy->drm_fd)) {
+		struct drm_i915_gem_context_param param = {
+			.param = I915_CONTEXT_PARAM_RECOVERABLE,
+			.value = 0,
+		};
+
+		vm_id = gem_vm_create_in_vm_bind_mode(dpy->drm_fd);
+
+		gem_context_set_param(dpy->drm_fd, &param);
+		gem_context_set_vm(dpy->drm_fd, 0, vm_id);
+
+		vm_id = gem_context_get_vm(dpy->drm_fd, 0);
+		ahnd = get_simple_ahnd(dpy->drm_fd, 0);
+
+		spin_flags |= IGT_SPIN_EXECBUF3;
+	} else {
+		ahnd = get_reloc_ahnd(dpy->drm_fd, 0);
+	}
 
 	output = set_fb_on_crtc(dpy, pipe, &fb);
 	primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
@@ -281,8 +355,10 @@ static void test_pageflip_modeset_hang(igt_display_t *dpy, enum pipe pipe)
 
 	t = igt_spin_new(dpy->drm_fd,
 			 .ahnd = ahnd,
+			 .ctx = 0,
+			 .vm_id = vm_id,
 			 .dependency = fb.gem_handle,
-			 .flags = IGT_SPIN_NO_PREEMPTION);
+			 .flags = spin_flags);
 
 	do_or_die(drmModePageFlip(dpy->drm_fd, dpy->pipes[pipe].crtc_id, fb.fb_id, DRM_MODE_PAGE_FLIP_EVENT, &fb));
 
@@ -294,6 +370,8 @@ static void test_pageflip_modeset_hang(igt_display_t *dpy, enum pipe pipe)
 	igt_assert(read(dpy->drm_fd, &ev, sizeof(ev)) == sizeof(ev));
 
 	igt_spin_end(t);
+	if (vm_id)
+		gem_vm_destroy(dpy->drm_fd, vm_id);
 	put_ahnd(ahnd);
 
 	igt_remove_fb(dpy->drm_fd, &fb);
-- 
2.39.0



More information about the Intel-gfx-trybot mailing list