When an out-fence is returned we expect that the in-fence is not
overwritten. Add a test to check for that.

Cc: Chris Wilson <ch...@chris-wilson.co.uk>
Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospu...@intel.com>
---
 tests/gem_exec_fence.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/tests/gem_exec_fence.c b/tests/gem_exec_fence.c
index bd7b1263..f7478c55 100644
--- a/tests/gem_exec_fence.c
+++ b/tests/gem_exec_fence.c
@@ -586,6 +586,42 @@ static void test_parallel(int fd, unsigned int master)
        gem_close(fd, handle[0]);
 }
 
+/* check that a fence in doesn't get clobbered when a fence out is returned */
+static void test_keep_fence_in(int fd, unsigned int engine)
+{
+       struct drm_i915_gem_execbuffer2 execbuf;
+       struct drm_i915_gem_exec_object2 obj;
+       const uint32_t bbe = MI_BATCH_BUFFER_END;
+       int fence;
+
+       memset(&obj, 0, sizeof(obj));
+       memset(&execbuf, 0, sizeof(execbuf));
+
+       obj.handle = gem_create(fd, 4096);
+       gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe));
+
+       execbuf.buffers_ptr = to_user_pointer(&obj);
+       execbuf.buffer_count = 1;
+       execbuf.flags = engine | LOCAL_EXEC_FENCE_OUT;
+
+       gem_execbuf_wr(fd, &execbuf);
+       fence = execbuf.rsvd2 >> 32;
+
+       gem_close(fd, obj.handle);
+       obj.handle = gem_create(fd, 4096);
+       gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe));
+
+       execbuf.flags |= LOCAL_EXEC_FENCE_IN;
+       execbuf.rsvd2 = fence;
+
+       gem_execbuf_wr(fd, &execbuf);
+       igt_assert_eq(fence, execbuf.rsvd2 & 0xFFFFFFFF);
+
+       gem_close(fd, obj.handle);
+       close(fence);
+       close(execbuf.rsvd2 >> 32);
+}
+
 #define EXPIRED 0x10000
 static void test_long_history(int fd, long ring_size, unsigned flags)
 {
@@ -1499,6 +1535,9 @@ igt_main
                                        }
                                }
 
+                               igt_subtest_f("keep-fence-in-%s", e->name)
+                                       test_keep_fence_in(i915, e->exec_id | 
e->flags);
+
                                igt_fixture {
                                        igt_stop_hang_detector();
                                }
-- 
2.16.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to