From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t 4/6] i915/gem_close: Adapt to allow duplicate handles
Date: Fri, 10 Jul 2020 15:11:02 +0100 [thread overview]
Message-ID: <e872c938-9029-6722-e76e-435d134b1767@linux.intel.com> (raw)
In-Reply-To: <20200710093234.1438712-4-chris@chris-wilson.co.uk>
On 10/07/2020 10:32, Chris Wilson wrote:
> 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>
> ---
> tests/i915/gem_close.c | 51 ++++++++++++++++++++++++++++++++++++------
> 1 file changed, 44 insertions(+), 7 deletions(-)
>
> diff --git a/tests/i915/gem_close.c b/tests/i915/gem_close.c
> index 4fdc1ad79..a9bf2d2d4 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,7 +90,8 @@ static void test_many_handles(int fd)
> gem_execbuf(fd, &execbuf);
> }
>
> - /* We do not allow the sam object to be referenced multiple times
> + /*
> + * We do not 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.
> */
> @@ -62,11 +99,11 @@ static void test_many_handles(int fd)
> 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 */
>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Regards,
Tvrtko
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2020-07-10 14:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-10 9:32 [igt-dev] [PATCH i-g-t 1/6] lib/i915: Report unknown device as the future Chris Wilson
2020-07-10 9:32 ` [igt-dev] [PATCH i-g-t 2/6] tools: Use the gt number stored in the device info Chris Wilson
2020-07-10 9:32 ` [igt-dev] [PATCH i-g-t 3/6] lib/i915: Pick a subtest conformant name for an unknown engine Chris Wilson
2020-07-10 9:32 ` [igt-dev] [PATCH i-g-t 4/6] i915/gem_close: Adapt to allow duplicate handles Chris Wilson
2020-07-10 14:11 ` Tvrtko Ursulin [this message]
2020-07-10 9:32 ` [igt-dev] [PATCH i-g-t 5/6] i915/gem_exec_schedule: Try to spot unfairness Chris Wilson
2020-07-10 9:32 ` [igt-dev] [PATCH i-g-t 6/6] i915/gem_softpin: Active rebinds Chris Wilson
2020-07-10 10:17 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/6] lib/i915: Report unknown device as the future Patchwork
2020-07-10 12:06 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e872c938-9029-6722-e76e-435d134b1767@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=igt-dev@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox