diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2020-07-06 10:54:30 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2020-07-10 15:53:38 +0100 |
commit | 6c008a2fe5c8c46ad8c1871b030987eddaa17bd9 (patch) | |
tree | 60eb0b92e45d56fa7e65fa14af3fa6a5d5eff3b7 /tests | |
parent | bc81be6915e4e23a5dc52f50a0c67462e321963f (diff) |
i915/gem_close: Adapt to allow duplicate handles
With an upcoming change, we can relax the rule about handles not being
duplicated in the execocbj[]. Duplicate handles must not otherwise
conflict in their placements (e.g. two EXEC_OBJECT_PINNED at different
offsets), but otherwise if they are able to be resolved to the same GPU
address, then the operation is harmless and decreed legal.
Since this is a relaxation in the negative ABI, update the test case to
allow the permissible duplicate handles.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/i915/gem_close.c | 53 |
1 files changed, 45 insertions, 8 deletions
diff --git a/tests/i915/gem_close.c b/tests/i915/gem_close.c index 4fdc1ad79..58f2d4b3f 100644 --- a/tests/i915/gem_close.c +++ b/tests/i915/gem_close.c @@ -24,21 +24,57 @@ #include "i915/gem.h" #include "igt.h" -static bool has_duplicate(int err) +static int batch_create(int fd) +{ + const uint32_t bbe = MI_BATCH_BUFFER_END; + uint32_t handle; + + handle = gem_create(fd, 4096); + gem_write(fd, handle, 0, &bbe, sizeof(bbe)); + + return handle; +} + +static int allows_duplicate(int fd) +{ + struct drm_i915_gem_exec_object2 obj[2] = { + { .handle = batch_create(fd), }, + }; + struct drm_i915_gem_execbuffer2 execbuf = { + .buffers_ptr = to_user_pointer(obj), + .buffer_count = 1, + }; + int err; + + gem_execbuf(fd, &execbuf); + + obj[1] = obj[0]; + execbuf.buffer_count = 2; + + err = __gem_execbuf(fd, &execbuf); + gem_close(fd, obj[0].handle); + + return err; +} + +static bool is_duplicate(int err) { return err == -EINVAL || err == -EALREADY; } static void test_many_handles(int fd) { - uint32_t bbe = MI_BATCH_BUFFER_END; struct drm_i915_gem_execbuffer2 execbuf; struct drm_i915_gem_exec_object2 obj[2]; uint32_t clones[128]; /* XXX try with 1024 */ uint32_t original; + int expected; + + expected = allows_duplicate(fd); + if (expected) + igt_assert(is_duplicate(expected)); - original = gem_create(fd, 4096); - gem_write(fd, original, 0, &bbe, sizeof(bbe)); + original = batch_create(fd); memset(&execbuf, 0, sizeof(execbuf)); execbuf.buffers_ptr = to_user_pointer(obj); @@ -54,19 +90,20 @@ static void test_many_handles(int fd) gem_execbuf(fd, &execbuf); } - /* We do not allow the sam object to be referenced multiple times - * within an execbuf; hence why this practice of cloning a handle + /* + * We do not normally allow the same object to be referenced multiple + * times within an execbuf; hence why this practice of cloning a handle * is only found within test cases. */ execbuf.buffer_count = 2; obj[0].handle = original; for (int i = 0; i < ARRAY_SIZE(clones); i++) { obj[1].handle = clones[i]; - igt_assert(has_duplicate(__gem_execbuf(fd, &execbuf))); + igt_assert_eq(__gem_execbuf(fd, &execbuf), expected); } /* Any other clone pair should also be detected */ obj[1].handle = clones[0]; /* (last, first) */ - igt_assert(has_duplicate(__gem_execbuf(fd, &execbuf))); + igt_assert_eq(__gem_execbuf(fd, &execbuf), expected); execbuf.buffer_count = 1; /* Now close the original having used every clone */ |