From patchwork Mon Jun 17 11:14:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10998779 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 642B776 for ; Mon, 17 Jun 2019 11:15:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5488828862 for ; Mon, 17 Jun 2019 11:15:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48CAB288AC; Mon, 17 Jun 2019 11:15:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EC67F288AA for ; Mon, 17 Jun 2019 11:15:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2F9FC891B5; Mon, 17 Jun 2019 11:15:08 +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 CB5B989026; Mon, 17 Jun 2019 11:15:05 +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 16926061-1500050 for multiple; Mon, 17 Jun 2019 12:14:57 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Mon, 17 Jun 2019 12:14:57 +0100 Message-Id: <20190617111457.9226-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t] i915/gem_ctx_shared: Check for a large enough hole in the GTT X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 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 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP In the exec-shared-gtt test, we cheekily try to reference an object we placed in the GTT in an earlier execbuf (and avoid declaring it in the later call). For a global GTT, where there may be existing objects, we have to find a hole large enough to fit both and avoid and implicit guard pages. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110876 Signed-off-by: Chris Wilson Reviewed-by: Tvrtko Ursulin --- tests/i915/gem_ctx_shared.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/i915/gem_ctx_shared.c b/tests/i915/gem_ctx_shared.c index ed43e8903..4b1020b96 100644 --- a/tests/i915/gem_ctx_shared.c +++ b/tests/i915/gem_ctx_shared.c @@ -184,6 +184,7 @@ static void exhaust_shared_gtt(int i915, unsigned int flags) static void exec_shared_gtt(int i915, unsigned int ring) { const int gen = intel_gen(intel_get_drm_devid(i915)); + const uint32_t bbe = MI_BATCH_BUFFER_END; struct drm_i915_gem_exec_object2 obj = {}; struct drm_i915_gem_execbuffer2 execbuf = { .buffers_ptr = to_user_pointer(&obj), @@ -197,11 +198,19 @@ static void exec_shared_gtt(int i915, unsigned int ring) gem_require_ring(i915, ring); igt_require(gem_can_store_dword(i915, ring)); + /* Find a hole big enough for both objects later */ + scratch = gem_create(i915, 16384); + gem_write(i915, scratch, 0, &bbe, sizeof(bbe)); + obj.handle = scratch; + gem_execbuf(i915, &execbuf); + gem_close(i915, scratch); + obj.flags |= EXEC_OBJECT_PINNED; /* reuse this address */ + scratch = gem_create(i915, 4096); s = gem_mmap__cpu(i915, scratch, 0, 4096, PROT_WRITE); gem_set_domain(i915, scratch, I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU); - *s = MI_BATCH_BUFFER_END; + *s = bbe; /* Load object into place in the GTT */ obj.handle = scratch; @@ -224,11 +233,10 @@ static void exec_shared_gtt(int i915, unsigned int ring) batch[++i] = obj.offset; } batch[++i] = 0xc0ffee; - batch[++i] = MI_BATCH_BUFFER_END; + batch[++i] = bbe; gem_write(i915, obj.handle, 0, batch, sizeof(batch)); - obj.offset += 4096; /* make sure we don't cause an eviction! */ - obj.flags |= EXEC_OBJECT_PINNED; + obj.offset += 8192; /* make sure we don't cause an eviction! */ execbuf.rsvd1 = gem_context_clone(i915, 0, I915_CONTEXT_CLONE_VM, 0); if (gen > 3 && gen < 6) execbuf.flags |= I915_EXEC_SECURE;