diff options
Diffstat (limited to 'tests/gem_busy.c')
-rw-r--r-- | tests/gem_busy.c | 189 |
1 files changed, 173 insertions, 16 deletions
diff --git a/tests/gem_busy.c b/tests/gem_busy.c index 22d38793..c2fae6d7 100644 --- a/tests/gem_busy.c +++ b/tests/gem_busy.c @@ -66,7 +66,6 @@ static uint32_t busy_blt(int fd) struct drm_i915_gem_execbuffer2 execbuf; struct drm_i915_gem_exec_object2 object[2]; struct drm_i915_gem_relocation_entry reloc[200], *r; - uint32_t read, write; uint32_t *map; int factor = 100; int i = 0; @@ -127,10 +126,7 @@ static uint32_t busy_blt(int fd) if (gen >= 6) execbuf.flags = I915_EXEC_BLT; gem_execbuf(fd, &execbuf); - - __gem_busy(fd, object[0].handle, &read, &write); - igt_assert_eq(read, 1 << write); - igt_assert_eq(write, gen >= 6 ? I915_EXEC_BLT : I915_EXEC_RENDER); + igt_assert(gem_bo_busy(fd, object[0].handle)); igt_debug("Created busy handle %d\n", object[0].handle); gem_close(fd, object[1].handle); @@ -460,6 +456,141 @@ static bool has_semaphores(int fd) return val > 0; } +static bool has_extended_busy_ioctl(int fd) +{ + const int gen = intel_gen(intel_get_drm_devid(fd)); + struct drm_i915_gem_exec_object2 obj; + struct drm_i915_gem_relocation_entry reloc; + struct drm_i915_gem_execbuffer2 execbuf; + uint32_t read, write; + uint32_t *batch; + int i; + + memset(&execbuf, 0, sizeof(execbuf)); + execbuf.buffers_ptr = (uintptr_t)&obj; + execbuf.buffer_count = 1; + + memset(&obj, 0, sizeof(obj)); + obj.handle = gem_create(fd, 4096); + + obj.relocs_ptr = (uintptr_t)&reloc; + obj.relocation_count = 1; + memset(&reloc, 0, sizeof(reloc)); + + batch = gem_mmap__gtt(fd, obj.handle, 4096, PROT_WRITE); + gem_set_domain(fd, obj.handle, + I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); + + reloc.target_handle = obj.handle; /* recurse */ + reloc.presumed_offset = 0; + reloc.offset = sizeof(uint32_t); + reloc.delta = 0; + reloc.read_domains = I915_GEM_DOMAIN_COMMAND; + reloc.write_domain = 0; + + i = 0; + batch[i] = MI_BATCH_BUFFER_START; + if (gen >= 8) { + batch[i] |= 1 << 8 | 1; + batch[++i] = 0; + batch[++i] = 0; + } else if (gen >= 6) { + batch[i] |= 1 << 8; + batch[++i] = 0; + } else { + batch[i] |= 2 << 6; + batch[++i] = 0; + if (gen < 4) { + batch[i] |= 1; + reloc.delta = 1; + } + } + i++; + + gem_execbuf(fd, &execbuf); + __gem_busy(fd, obj.handle, &read, &write); + + *batch = MI_BATCH_BUFFER_END; + __sync_synchronize(); + munmap(batch, 4096); + + gem_close(fd, obj.handle); + + return read != 0; +} + +static void basic(int fd, unsigned ring, unsigned flags) +{ + const int gen = intel_gen(intel_get_drm_devid(fd)); + struct drm_i915_gem_exec_object2 obj; + struct drm_i915_gem_relocation_entry reloc; + struct drm_i915_gem_execbuffer2 execbuf; + struct timespec tv; + uint32_t *batch; + int i, timeout; + bool busy; + + memset(&execbuf, 0, sizeof(execbuf)); + execbuf.buffers_ptr = (uintptr_t)&obj; + execbuf.buffer_count = 1; + execbuf.flags = ring; + + memset(&obj, 0, sizeof(obj)); + obj.handle = gem_create(fd, 4096); + + obj.relocs_ptr = (uintptr_t)&reloc; + obj.relocation_count = 1; + memset(&reloc, 0, sizeof(reloc)); + + batch = gem_mmap__gtt(fd, obj.handle, 4096, PROT_WRITE); + gem_set_domain(fd, obj.handle, + I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); + + reloc.target_handle = obj.handle; /* recurse */ + reloc.presumed_offset = 0; + reloc.offset = sizeof(uint32_t); + reloc.delta = 0; + reloc.read_domains = I915_GEM_DOMAIN_COMMAND; + reloc.write_domain = 0; + + i = 0; + batch[i] = MI_BATCH_BUFFER_START; + if (gen >= 8) { + batch[i] |= 1 << 8 | 1; + batch[++i] = 0; + batch[++i] = 0; + } else if (gen >= 6) { + batch[i] |= 1 << 8; + batch[++i] = 0; + } else { + batch[i] |= 2 << 6; + batch[++i] = 0; + if (gen < 4) { + batch[i] |= 1; + reloc.delta = 1; + } + } + i++; + + gem_execbuf(fd, &execbuf); + busy = gem_bo_busy(fd, obj.handle); + + timeout = 120; + if ((flags & HANG) == 0) { + *batch = MI_BATCH_BUFFER_END; + __sync_synchronize(); + timeout = 1; + } + munmap(batch, 4096); + + igt_assert(busy); + memset(&tv, 0, sizeof(tv)); + while (gem_bo_busy(fd, obj.handle)) + igt_assert(igt_seconds_elapsed(&tv) < timeout); + + gem_close(fd, obj.handle); +} + igt_main { const struct intel_execution_engine *e; @@ -474,11 +605,23 @@ igt_main igt_fixture { igt_fork_hang_detector(fd); } + for (e = intel_execution_engines; e->name; e++) { + igt_subtest_group { + igt_subtest_f("%sbusy-%s", + e->exec_id == 0 ? "basic-" : "", + e->name) { + igt_require(gem_has_ring(fd, e->exec_id | e->flags)); + gem_quiescent_gpu(fd); + basic(fd, e->exec_id | e->flags, 0); + } + } + } igt_subtest_group { int gen = 0; igt_fixture { + igt_require(has_extended_busy_ioctl(fd)); gem_require_mmap_wc(fd); gen = intel_gen(intel_get_drm_devid(fd)); } @@ -488,7 +631,7 @@ igt_main if (e->exec_id == 0) continue; - igt_subtest_f("basic-%s", e->name) { + igt_subtest_f("extended-%s", e->name) { gem_require_ring(fd, e->exec_id | e->flags); igt_skip_on_f(gen == 6 && e->exec_id == I915_EXEC_BSD, @@ -504,7 +647,7 @@ igt_main if (e->exec_id == 0) continue; - igt_subtest_f("basic-parallel-%s", e->name) { + igt_subtest_f("extended-parallel-%s", e->name) { gem_require_ring(fd, e->exec_id | e->flags); igt_skip_on_f(gen == 6 && e->exec_id == I915_EXEC_BSD, @@ -517,27 +660,47 @@ igt_main } igt_subtest_group { - igt_fixture + igt_fixture { + igt_require(has_extended_busy_ioctl(fd)); igt_require(has_semaphores(fd)); + } for (e = intel_execution_engines; e->name; e++) { /* default exec-id is purely symbolic */ if (e->exec_id == 0) continue; - igt_subtest_f("semaphore-%s", e->name) + igt_subtest_f("extended-semaphore-%s", e->name) semaphore(fd, e->exec_id, e->flags); } } + igt_subtest_group { + igt_subtest("close-race") + close_race(fd); + } + igt_fixture { igt_stop_hang_detector(); } + for (e = intel_execution_engines; e->name; e++) { + igt_subtest_group { + igt_subtest_f("%shang-%s", + e->exec_id == 0 ? "basic-" : "", + e->name) { + igt_require(gem_has_ring(fd, e->exec_id | e->flags)); + gem_quiescent_gpu(fd); + basic(fd, e->exec_id | e->flags, 0); + } + } + } + igt_subtest_group { int gen = 0; igt_fixture { + igt_require(has_extended_busy_ioctl(fd)); gem_require_mmap_wc(fd); gen = intel_gen(intel_get_drm_devid(fd)); } @@ -547,7 +710,7 @@ igt_main if (e->exec_id == 0) continue; - igt_subtest_f("hang-%s", e->name) { + igt_subtest_f("extended-hang-%s", e->name) { gem_require_ring(fd, e->exec_id | e->flags); igt_skip_on_f(gen == 6 && e->exec_id == I915_EXEC_BSD, @@ -559,12 +722,6 @@ igt_main } } - igt_subtest_group { - igt_subtest("close-race") { - close_race(fd); - } - } - igt_fixture { close(fd); } |