summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-09-25 20:59:54 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2017-09-26 15:34:38 +0100
commit2885b10f99b4beeb046e75af8b8488c229f629d3 (patch)
tree46ed4eb86a06ec78102573f70ef30f067f15514e
parent9fe6ea91fd6e4ff3d95dfd4f46c2d3080be6a405 (diff)
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>
-rw-r--r--tests/gem_exec_schedule.c43
1 files changed, 23 insertions, 20 deletions
diff --git a/tests/gem_exec_schedule.c b/tests/gem_exec_schedule.c
index e9b928f1..79738ee1 100644
--- a/tests/gem_exec_schedule.c
+++ b/tests/gem_exec_schedule.c
@@ -152,33 +152,36 @@ static void unplug(struct cork *c)
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;
-
- 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);
+ igt_spin_t *spin[BUSY_QLEN];
+
+ 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)