summaryrefslogtreecommitdiff
path: root/tests/i915/gem_ctx_engines.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2020-05-28 09:45:15 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2020-05-28 09:58:30 +0100
commitab32fdc01274591c4b3f531b929bc243d7e0c536 (patch)
tree473c279a6fe188f54b9eab2b456958bf62fecd49 /tests/i915/gem_ctx_engines.c
parent2991a5d60b1bbf2b2b6004669cd0f9471bd687a2 (diff)
i915/gem_ctx_engines: Take GPU relocations into account for batch busyness
If we are using GPU relocations, then the batch may legitimately be marked as having been written to by the GPU. As this is expected, remove the write marker, which may be a different engine to that we execute on, and the corresponding read engine if different. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Acked-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Diffstat (limited to 'tests/i915/gem_ctx_engines.c')
-rw-r--r--tests/i915/gem_ctx_engines.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/tests/i915/gem_ctx_engines.c b/tests/i915/gem_ctx_engines.c
index 7d6d8e66..e6def511 100644
--- a/tests/i915/gem_ctx_engines.c
+++ b/tests/i915/gem_ctx_engines.c
@@ -251,6 +251,29 @@ static uint32_t batch_create(int i915)
return handle;
}
+static uint32_t batch_busy(uint32_t busy)
+{
+ unsigned int write;
+
+ /*
+ * If we use GPU relocations, we may then write into the batch,
+ * and the batch will correspondingly have a write flag. We may
+ * not even use the same engine to perform the relocations
+ */
+ write = busy & 0xfffff;
+ busy >>= 16; /* strip off the write marker */
+
+ if (write) {
+ write = 1 << (write - 1); /* writer => reader bit */
+
+ /* If we wrote using a different engine, remove it */
+ if (busy & ~write)
+ busy &= ~write;
+ }
+
+ return busy;
+}
+
static void none(int i915)
{
struct i915_context_param_engines engines = {};
@@ -349,7 +372,8 @@ static void execute_one(int i915)
}
do_ioctl(i915, DRM_IOCTL_I915_GEM_BUSY, &busy);
- igt_assert_eq(busy.busy, i != -1 ? 1 << (e->class + 16) : 0);
+ igt_assert_eq(batch_busy(busy.busy),
+ i != -1 ? 1 << e->class : 0);
igt_spin_free(i915, spin);
@@ -398,7 +422,7 @@ static void execute_oneforall(int i915)
busy.handle = spin->handle;
do_ioctl(i915, DRM_IOCTL_I915_GEM_BUSY, &busy);
- igt_assert_eq(busy.busy, 1 << (e->class + 16));
+ igt_assert_eq(batch_busy(busy.busy), 1 << e->class);
igt_spin_free(i915, spin);
}
@@ -439,7 +463,7 @@ static void execute_allforone(int i915)
busy.handle = spin->handle;
do_ioctl(i915, DRM_IOCTL_I915_GEM_BUSY, &busy);
- igt_assert_eq(busy.busy, 1 << (e->class + 16));
+ igt_assert_eq(batch_busy(busy.busy), 1 << e->class);
igt_spin_free(i915, spin);
}