From patchwork Fri Jan 24 12:17:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 11350171 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 2EBA6109A for ; Fri, 24 Jan 2020 12:18:07 +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 16FB2206D4 for ; Fri, 24 Jan 2020 12:18:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 16FB2206D4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com 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 2552E6E362; Fri, 24 Jan 2020 12:18:05 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id E50376E362; Fri, 24 Jan 2020 12:18:03 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jan 2020 04:18:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,357,1574150400"; d="scan'208";a="245692861" Received: from wmszyfel-mobl2.ger.corp.intel.com (HELO localhost.localdomain) ([10.252.10.247]) by orsmga002.jf.intel.com with ESMTP; 24 Jan 2020 04:18:01 -0800 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Fri, 24 Jan 2020 12:17:58 +0000 Message-Id: <20200124121759.22308-1-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 1/2] lib/i915: Add helper for copying engine maps from one context to another 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: Intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Tvrtko Ursulin We also need to support copying across file descriptors. Signed-off-by: Tvrtko Ursulin Cc: Chris Wilson Cc: Sreedhar Telukuntla Reviewed-by: Chris Wilson --- lib/i915/gem_context.c | 30 ++++++++++++++++++++++++++++++ lib/i915/gem_context.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/lib/i915/gem_context.c b/lib/i915/gem_context.c index 0b6a554dfe27..41957b66ca52 100644 --- a/lib/i915/gem_context.c +++ b/lib/i915/gem_context.c @@ -462,3 +462,33 @@ bool gem_context_has_engine(int fd, uint32_t ctx, uint64_t engine) return __gem_execbuf(fd, &execbuf) == -ENOENT; } + +/** + * gem_context_copy_engines: + * @src_fd: open i915 drm file descriptor where @src context belongs to + * @src: source engine map context id + * @dst_fd: open i915 drm file descriptor where @dst context belongs to + * @dst: destination engine map context id + * + * Special purpose wrapper for copying engine map from one context to another. + * + * In can be called regardless of whether the kernel supports context engine + * maps and is a no-op if not supported. + */ +void +gem_context_copy_engines(int src_fd, uint32_t src, int dst_fd, uint32_t dst) +{ + I915_DEFINE_CONTEXT_PARAM_ENGINES(engines, I915_EXEC_RING_MASK + 1); + struct drm_i915_gem_context_param param = { + .param = I915_CONTEXT_PARAM_ENGINES, + .ctx_id = src, + .size = sizeof(engines), + .value = to_user_pointer(&engines), + }; + + if (__gem_context_get_param(src_fd, ¶m) || !param.size) + return; + + param.ctx_id = dst; + gem_context_set_param(dst_fd, ¶m); +} diff --git a/lib/i915/gem_context.h b/lib/i915/gem_context.h index cf2ba33fee8f..15e5db281b79 100644 --- a/lib/i915/gem_context.h +++ b/lib/i915/gem_context.h @@ -42,6 +42,8 @@ uint32_t gem_context_clone(int i915, uint32_t src, unsigned int share, unsigned int flags); uint32_t gem_context_clone_with_engines(int i915, uint32_t src); +void gem_context_copy_engines(int src_fd, uint32_t src, + int dst_fd, uint32_t dst); uint32_t gem_queue_create(int i915); uint32_t gem_queue_clone_with_engines(int i915, uint32_t src); From patchwork Fri Jan 24 12:17:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 11350173 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 8ADCD13A4 for ; Fri, 24 Jan 2020 12:18:09 +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 73453206D4 for ; Fri, 24 Jan 2020 12:18:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73453206D4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com 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 2FC136FA4D; Fri, 24 Jan 2020 12:18:07 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id A762F6E362; Fri, 24 Jan 2020 12:18:04 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jan 2020 04:18:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,357,1574150400"; d="scan'208";a="245692868" Received: from wmszyfel-mobl2.ger.corp.intel.com (HELO localhost.localdomain) ([10.252.10.247]) by orsmga002.jf.intel.com with ESMTP; 24 Jan 2020 04:18:03 -0800 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Fri, 24 Jan 2020 12:17:59 +0000 Message-Id: <20200124121759.22308-2-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200124121759.22308-1-tvrtko.ursulin@linux.intel.com> References: <20200124121759.22308-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 2/2] tests/i915/gem_exec_parallel:Set engine map to default context 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: Intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Sreedhar Telukuntla Set the potential engine map of the parent client's default context to the newly created DRM client's default context. Without doing so there is a mismatch between the intended and actual engine used by the *-fds subtests. v2: Fix FDS flags check Tvrtko: v3: Use new helper gem_context_copy_engines. Signed-off-by: Sreedhar Telukuntla Cc: Tvrtko Ursulin Reviewed-by: Chris Wilson --- tests/i915/gem_exec_parallel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/i915/gem_exec_parallel.c b/tests/i915/gem_exec_parallel.c index cfbe78070873..0d4d6c6283e0 100644 --- a/tests/i915/gem_exec_parallel.c +++ b/tests/i915/gem_exec_parallel.c @@ -83,10 +83,12 @@ static void *thread(void *data) pthread_cond_wait(t->cond, t->mutex); pthread_mutex_unlock(t->mutex); - if (t->flags & FDS) + if (t->flags & FDS) { fd = drm_open_driver(DRIVER_INTEL); - else + gem_context_copy_engines(t->fd, 0, fd, 0); + } else { fd = t->fd; + } i = 0; batch[i] = MI_STORE_DWORD_IMM | (t->gen < 6 ? 1 << 22 : 0);