From ecf8476f3102ad6194d9ac05a5fa8d466ddc0b65 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 13 May 2020 20:37:44 +0100 Subject: i915/gem_exec_params: Check that FENCE_IN | FENCE_SUBMIT is rejected Since both the in-fence and the submit-fence utilise the same slot in execbuf.rsvd2, we can only enable one of the two. If the user accidentally, tries to use both with the same fence, we expect EINVAL. Signed-off-by: Chris Wilson Acked-by: Mika Kuoppala --- tests/i915/gem_exec_params.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'tests/i915/gem_exec_params.c') diff --git a/tests/i915/gem_exec_params.c b/tests/i915/gem_exec_params.c index 83194be7..86d50489 100644 --- a/tests/i915/gem_exec_params.c +++ b/tests/i915/gem_exec_params.c @@ -41,6 +41,7 @@ #include "i915/gem.h" #include "igt.h" #include "igt_device.h" +#include "sw_sync.h" static bool has_ring(int fd, unsigned ring_exec_flags) { @@ -196,6 +197,20 @@ static int has_secure_batches(const int fd) return v > 0; } +static bool has_submit_fence(int fd) +{ + int v = 0; + struct drm_i915_getparam gp = { + .param = I915_PARAM_HAS_EXEC_SUBMIT_FENCE, + .value = &v, + }; + + ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)); + errno = 0; + + return v > 0; +} + static uint32_t batch_create(int i915) { const uint32_t bbe = MI_BATCH_BUFFER_END; @@ -535,6 +550,28 @@ igt_main RUN_FAIL(EINVAL); } + igt_subtest("invalid-fence-in-submit") { + int timeline; + + igt_require(gem_has_exec_fence(fd)); + igt_require(has_submit_fence(fd)); + + timeline = sw_sync_timeline_create(); + execbuf.rsvd2 = sw_sync_timeline_create_fence(timeline, 1); + + execbuf.flags = I915_EXEC_FENCE_IN; + gem_execbuf(fd, &execbuf); + + execbuf.flags = I915_EXEC_FENCE_SUBMIT; + gem_execbuf(fd, &execbuf); + + execbuf.flags = I915_EXEC_FENCE_IN | I915_EXEC_FENCE_SUBMIT; + RUN_FAIL(EINVAL); + + close(execbuf.rsvd2); + close(timeline); + } + igt_subtest("rsvd2-dirt") { igt_require(!gem_has_exec_fence(fd)); execbuf.flags = 0; -- cgit v1.2.3