diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2017-03-29 17:14:10 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2017-08-11 12:00:15 +0100 |
commit | da592c104d1bdfe1c60f90544aaf06b8961573f0 (patch) | |
tree | 28130406d576233de009926e153ca7f7d6f4f369 | |
parent | 75846e93173abb83d06d020687fa334d2c3ddd61 (diff) |
igt/gem_wait: Exercise waiting on only write hazards
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | tests/gem_wait.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/gem_wait.c b/tests/gem_wait.c index cf8c8154..8c2d48a4 100644 --- a/tests/gem_wait.c +++ b/tests/gem_wait.c @@ -28,6 +28,8 @@ #include "igt.h" #include "igt_vgem.h" +#define LOCAL_WAIT_READ_ONLY 0x1 + static int __gem_wait(int fd, struct drm_i915_gem_wait *w) { int err; @@ -160,6 +162,48 @@ static void basic(int fd, unsigned engine, unsigned flags) igt_spin_batch_free(fd, spin); } +static bool wait_has_readonly(int fd) +{ + struct drm_i915_gem_wait arg = { .flags = LOCAL_WAIT_READ_ONLY }; + int err = 0; + if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_WAIT, &arg)) + err = -errno; + errno = 0; + return err == -ENOENT; +} + +static void readonly(int fd) +{ + uint32_t scratch = gem_create(fd, 4096); + igt_spin_t *spin = igt_spin_batch_new(fd, 0, 0, scratch); + struct drm_i915_gem_wait wait = { spin->handle }; + + /* Test read-only batch */ + wait.flags = LOCAL_WAIT_READ_ONLY; + igt_assert_eq(__gem_wait(fd, &wait), 0); + wait.timeout_ns = -1; + igt_assert_eq(__gem_wait(fd, &wait), 0); + + wait.flags = 0; + wait.timeout_ns = 0; + igt_assert_eq(__gem_wait(fd, &wait), -ETIME); + + /* Test write hazard to scratch */ + wait.bo_handle = scratch; + igt_assert_eq(__gem_wait(fd, &wait), -ETIME); + + wait.flags = LOCAL_WAIT_READ_ONLY; + igt_assert_eq(__gem_wait(fd, &wait), -ETIME); + + igt_spin_batch_free(fd, spin); + + wait.timeout_ns = -1; + wait.flags = LOCAL_WAIT_READ_ONLY; + igt_assert_eq(__gem_wait(fd, &wait), 0); + + gem_close(fd, scratch); +} + igt_main { const struct intel_execution_engine *e; @@ -237,6 +281,15 @@ igt_main } igt_subtest_group { + igt_fixture { + igt_require(wait_has_readonly(fd)); + } + + igt_subtest("read-only") + readonly(fd); + } + + igt_subtest_group { igt_hang_t hang; igt_fixture { |