igt/gem_exec_schedule: Ignore set-priority failures on old kernels

When plugging the device, we need to submit batches at highest priority
so that they cannot be gazumped by the queued requests. On older kernels
that do not support the user changing context priority, all contexts
therefore have the same default priority and we can ignore the error.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: MichaƂ Winiarski <michal.winiarski@intel.com>
diff --git a/tests/gem_exec_schedule.c b/tests/gem_exec_schedule.c
index e9b928f..79738ee 100644
--- a/tests/gem_exec_schedule.c
+++ b/tests/gem_exec_schedule.c
@@ -152,33 +152,36 @@
 	close(c->device);
 }
 
+static uint32_t create_highest_priority(int fd)
+{
+	uint32_t ctx = gem_context_create(fd);
+
+	/*
+	 * If there is no priority support, all contexts will have equal
+	 * priority (and therefore the max user priority), so no context
+	 * can overtake us, and we effectively can form a plug.
+	 */
+	__ctx_set_priority(fd, ctx, MAX_PRIO);
+
+	return ctx;
+}
+
 static void unplug_show_queue(int fd, struct cork *c, unsigned int engine)
 {
-	igt_spin_t *spin;
-	uint32_t ctx;
+	igt_spin_t *spin[BUSY_QLEN];
 
-	ctx = gem_context_create(fd);
-	ctx_set_priority(fd, ctx, MAX_PRIO);
-
-	spin = igt_spin_batch_new(fd, ctx, engine, 0);
-	for (int n = 0; n < BUSY_QLEN; n++) {
-		struct drm_i915_gem_exec_object2 obj = {
-			.handle = spin->handle,
-		};
-		struct drm_i915_gem_execbuffer2 execbuf = {
-			.buffers_ptr = to_user_pointer(&obj),
-			.buffer_count = 1,
-			.flags = engine,
-		};
-		gem_execbuf(fd, &execbuf);
+	for (int n = 0; n < ARRAY_SIZE(spin); n++) {
+		uint32_t ctx = create_highest_priority(fd);
+		spin[n] = __igt_spin_batch_new(fd, ctx, engine, 0);
+		gem_context_destroy(fd, ctx);
 	}
 
 	unplug(c); /* batches will now be queued on the engine */
-
 	igt_debugfs_dump(fd, "i915_engine_info");
-	igt_spin_batch_free(fd, spin);
 
-	gem_context_destroy(fd, ctx);
+	for (int n = 0; n < ARRAY_SIZE(spin); n++)
+		igt_spin_batch_free(fd, spin[n]);
+
 }
 
 static void fifo(int fd, unsigned ring)