From patchwork Thu Oct 12 00:06:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinay Belgaumkar X-Patchwork-Id: 10000779 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 C781E60216 for ; Thu, 12 Oct 2017 00:04:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6E1328BC8 for ; Thu, 12 Oct 2017 00:04:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A8BB28BF8; Thu, 12 Oct 2017 00:04:39 +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 227F128BC8 for ; Thu, 12 Oct 2017 00:04:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9E0696E1F7; Thu, 12 Oct 2017 00:04:37 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7155C6E1F7 for ; Thu, 12 Oct 2017 00:04:36 +0000 (UTC) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP; 11 Oct 2017 17:04:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,363,1503385200"; d="scan'208";a="162150503" Received: from vinaysim-desktop.fm.intel.com ([10.1.27.163]) by fmsmga006.fm.intel.com with ESMTP; 11 Oct 2017 17:04:35 -0700 From: Vinay Belgaumkar To: intel-gfx@lists.freedesktop.org Date: Wed, 11 Oct 2017 17:06:35 -0700 Message-Id: <1507766795-162356-1-git-send-email-vinay.belgaumkar@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [Intel-gfx] [PATCH i-g-t v4] lib/igt_gt: Allow non-default contexts to hang non-render rings X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP This limitation does not exist in latest kernel. It was removed by this patch- commit f7978a0c581a8a840a28306f8da43e06e7fef3bf v2: Added commit id that removes the limitation(Chris Wilson) V3: Generic way to find if kernel supports this instead of hardcoding gens(Chris Wilson) v4: Optimize the if block (Daniele) Cc: Michel Thierry Cc: Arkadiusz Hiler Cc: Petri Latvala Signed-off-by: Vinay Belgaumkar --- lib/igt_gt.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/lib/igt_gt.c b/lib/igt_gt.c index b3f3b38..555e4df 100644 --- a/lib/igt_gt.c +++ b/lib/igt_gt.c @@ -209,11 +209,51 @@ void igt_disallow_hang(int fd, igt_hang_t arg) } /** + * has_ctx_exec: + * @fd: open i915 drm file descriptor + * @ring: execbuf ring flag + * + * This helper function checks if non default context submission is allowed + * on a ring. + * + * Returns: + * True if allowed + * + */ +bool has_ctx_exec(int fd, unsigned ring) +{ + struct drm_i915_gem_execbuffer2 execbuf; + struct drm_i915_gem_exec_object2 exec; + bool supported; + + /* silly ABI, the kernel thinks everyone who has BSD also has BSD2 */ + if ((ring & ~(3<<13)) == I915_EXEC_BSD) { + if (ring & (3 << 13) && !gem_has_bsd2(fd)) + return false; + } + + memset(&exec, 0, sizeof(exec)); + memset(&execbuf, 0, sizeof(execbuf)); + execbuf.buffers_ptr = to_user_pointer(&exec); + execbuf.buffer_count = 1; + execbuf.flags = ring; + execbuf.rsvd1 = gem_context_create(fd); + /* If context submission is not allowed, this will return EINVAL + * Otherwise, this will return ENOENT on account of no gem obj + * being submitted */ + supported = __gem_execbuf(fd, &execbuf) == -ENOENT; + gem_context_destroy(fd, execbuf.rsvd1); + + return supported; +} + +/** * igt_hang_ring_ctx: * @fd: open i915 drm file descriptor * @ctx: the contxt specifier * @ring: execbuf ring flag * @flags: set of flags to control execution + * @offset: The resultant gtt offset of the exec obj * * This helper function injects a hanging batch associated with @ctx into @ring. * It returns a #igt_hang_t structure which must be passed to @@ -239,8 +279,8 @@ igt_hang_t igt_hang_ctx(int fd, igt_require_hang_ring(fd, ring); - /* One day the kernel ABI will be fixed! */ - igt_require(ctx == 0 || ring == I915_EXEC_RENDER); + /* check if non-default ctx submission is allowed */ + igt_require(ctx == 0 || (has_ctx_exec(fd, ring))); param.context = ctx; param.size = 0;