From patchwork Mon Jul 6 09:59:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 11645321 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E42592A for ; Mon, 6 Jul 2020 09:59:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 106C82074F for ; Mon, 6 Jul 2020 09:59:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 106C82074F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=chris-wilson.co.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D2B66E184; Mon, 6 Jul 2020 09:59:12 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5519C6E047; Mon, 6 Jul 2020 09:59:10 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 21726691-1500050 for multiple; Mon, 06 Jul 2020 10:58:57 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Mon, 6 Jul 2020 10:59:00 +0100 Message-Id: <20200706095900.802304-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t] i915/gem_close: Adapt to allow duplicate handles X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org, Chris Wilson Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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 --- 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..7765d0d90 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 sam 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 */