[igt-dev] [PATCH i-g-t 08/10] tests/i915/exec_fence: add timeline fence tests

Chris Wilson chris at chris-wilson.co.uk
Wed Nov 20 21:40:21 UTC 2019


Quoting Lionel Landwerlin (2019-11-20 21:21:41)
> +static void test_syncobj_timeline_signal(int fd)
> +{
> +       const uint32_t bbe = MI_BATCH_BUFFER_END;
> +       struct drm_i915_gem_exec_object2 obj;
> +       struct drm_i915_gem_execbuffer2 execbuf;
> +       struct drm_i915_gem_execbuffer_ext_timeline_fences timeline_fences;
> +       struct drm_i915_gem_exec_fence fence = {
> +               .handle = syncobj_create(fd, 0),
> +       };
> +       uint64_t value = 42, query_value;
> +       igt_spin_t *spin = igt_spin_new(fd);
> +
> +       /* Check that the syncobj is signaled only when our request/fence is */
> +
> +       memset(&timeline_fences, 0, sizeof(timeline_fences));
> +       timeline_fences.base.name = DRM_I915_GEM_EXECBUFFER_EXT_TIMELINE_FENCES;
> +       timeline_fences.fence_count = 1;
> +       timeline_fences.handles_ptr = to_user_pointer(&fence);
> +       timeline_fences.values_ptr = to_user_pointer(&value);
> +
> +       memset(&execbuf, 0, sizeof(execbuf));
> +       execbuf.buffers_ptr = to_user_pointer(&obj);
> +       execbuf.buffer_count = 1;
> +       execbuf.flags = I915_EXEC_USE_EXTENSIONS;
> +       execbuf.cliprects_ptr = to_user_pointer(&timeline_fences);
> +       execbuf.num_cliprects = 0;
> +
> +       memset(&obj, 0, sizeof(obj));
> +       obj.handle = gem_create(fd, 4096);
> +       gem_write(fd, obj.handle, 0, &bbe, sizeof(bbe));
> +
> +       fence.flags = I915_EXEC_FENCE_SIGNAL;
> +       gem_execbuf(fd, &execbuf);
> +
> +       igt_assert(gem_bo_busy(fd, obj.handle));
> +       igt_assert(syncobj_busy(fd, fence.handle));
> +
> +       igt_spin_free(fd, spin);
> +
> +       gem_sync(fd, obj.handle);
> +       igt_assert(!gem_bo_busy(fd, obj.handle));
> +       igt_assert(!syncobj_busy(fd, fence.handle));

I'd reverse the order of these asserts - we waited on the handle, so we
first assert the syncobj. And I'd have another test that waited on the
syncobj and assert the obj.handle was idle (maybe you already do).
-Chris


More information about the igt-dev mailing list