From patchwork Thu Mar 22 14:12:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10301601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 47446600F6 for ; Thu, 22 Mar 2018 14:13:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BC77285D8 for ; Thu, 22 Mar 2018 14:13:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2042F285FC; Thu, 22 Mar 2018 14:13:50 +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=-4.2 required=2.0 tests=BAYES_00, 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 96D76285D8 for ; Thu, 22 Mar 2018 14:13:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8185989D86; Thu, 22 Mar 2018 14:13:48 +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 A9F2D89D86; Thu, 22 Mar 2018 14:13:46 +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 11120695-1500050 for multiple; Thu, 22 Mar 2018 14:12:06 +0000 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Thu, 22 Mar 2018 14:12:06 +0000 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Thu, 22 Mar 2018 14:12:05 +0000 Message-Id: <20180322141205.16746-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.16.2 X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Subject: [Intel-gfx] [PATCH igt] lib: Run gem_test_engine() in an isolated context 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 MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Ignore the shennigans of the test surrounding the library call to gem_test_engine() and focus on answering the query of whether the engine exists and is operational. Signed-off-by: Chris Wilson Cc: Tvrtko Ursulin Reviewed-by: Tvrtko Ursulin Tested-by: Tvrtko Ursulin --- lib/i915/gem_submission.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/i915/gem_submission.c b/lib/i915/gem_submission.c index c5e96969..062b8b93 100644 --- a/lib/i915/gem_submission.c +++ b/lib/i915/gem_submission.c @@ -22,6 +22,7 @@ */ #include +#include #include #include @@ -164,6 +165,17 @@ bool gem_has_guc_submission(int fd) return gem_submission_method(fd) & GEM_SUBMISSION_GUC; } +static int reopen_driver(int fd) +{ + char path[256]; + + snprintf(path, sizeof(path), "/proc/self/fd/%d", fd); + fd = open(path, O_RDWR); + igt_assert_lte(0, fd); + + return fd; +} + static bool is_wedged(int i915) { int err = 0; @@ -183,19 +195,20 @@ static bool is_wedged(int i915) void gem_test_engine(int i915, unsigned int engine) { const uint32_t bbe = MI_BATCH_BUFFER_END; - struct drm_i915_gem_exec_object2 obj = { - .handle = gem_create(i915, 4096) - }; + struct drm_i915_gem_exec_object2 obj = { }; struct drm_i915_gem_execbuffer2 execbuf = { .buffers_ptr = to_user_pointer(&obj), .buffer_count = 1, }; + i915 = reopen_driver(i915); igt_assert(!is_wedged(i915)); + + obj.handle = gem_create(i915, 4096); gem_write(i915, obj.handle, 0, &bbe, sizeof(bbe)); if (engine == ALL_ENGINES) { - for_each_engine(i915, engine) { + for_each_physical_engine(i915, engine) { execbuf.flags = engine; gem_execbuf(i915, &execbuf); } @@ -207,4 +220,6 @@ void gem_test_engine(int i915, unsigned int engine) gem_close(i915, obj.handle); igt_assert(!is_wedged(i915)); + + close(i915); }