From: Andi Shyti <andi.shyti@intel.com>
To: IGT dev <igt-dev@lists.freedesktop.org>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>, Andi Shyti <andi@etezian.org>
Subject: [igt-dev] [PATCH v3 2/3] lib: implement new engine discovery interface
Date: Mon, 26 Nov 2018 22:43:48 +0200 [thread overview]
Message-ID: <20181126204349.6739-3-andi.shyti@intel.com> (raw)
In-Reply-To: <20181126204349.6739-1-andi.shyti@intel.com>
Kernel commits:
[1] ae8f4544dd8f ("drm/i915: Engine discovery query")
[2] 31e7d35667a0 ("drm/i915: Allow a context to define its set of engines")
from [*] repository, implement a new uapi for engine discovery
that consist in first querying the driver about the engines in
the gpu [1] and then binding a context to the set of engines that
it can access [2].
In igt the classic way for discovering engines is done through
the for_each_physical_engine() macro, that would be replaced by
the new for_each_engine_ctx().
[*] git://people.freedesktop.org/~tursulin/drm-intel
Signed-off-by: Andi Shyti <andi.shyti@intel.com>
---
lib/igt_gt.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++
lib/igt_gt.h | 5 ++++
2 files changed, 79 insertions(+)
diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index a2061924..e5543b27 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -650,3 +650,77 @@ bool gem_ring_has_physical_engine(int fd, unsigned ring)
return gem_has_ring(fd, ring);
}
+
+static struct drm_i915_query_engine_info *query_engines(int fd)
+{
+ struct drm_i915_query query = { };
+ struct drm_i915_query_item item = { };
+ struct drm_i915_query_engine_info *query_engines;
+
+ item.query_id = DRM_I915_QUERY_ENGINE_INFO;
+ query.items_ptr = to_user_pointer(&item);
+ query.num_items = 1;
+
+ /*
+ * The first ioctl is sent with item.length = 0
+ * which asks to the driver to store in length the
+ * memory needed for the engines. In the driver, length
+ * is equal to
+ *
+ * len = sizeof(struct drm_i915_query_engine_info) +
+ * INTEL_INFO(i915)->num_rings *
+ * sizeof(struct drm_i915_engine_info);
+ */
+ igt_require(!ioctl(fd, DRM_IOCTL_I915_QUERY, &query));
+
+ igt_assert((query_engines = calloc(item.length, 1)));
+ item.data_ptr = to_user_pointer(query_engines);
+
+ /* The second ioctl stores the engines in query_engines */
+ igt_require(!ioctl(fd, DRM_IOCTL_I915_QUERY, &query));
+
+ return query_engines;
+}
+
+static void set_param(int fd, uint32_t ctx_id,
+ struct drm_i915_query_engine_info *query_engine)
+{
+ int i;
+ struct drm_i915_gem_context_param ctx_param;
+ struct i915_context_param_engines *ctx_engine;
+ size_t size = sizeof(struct i915_context_param_engines) +
+ query_engine->num_engines *
+ sizeof(*ctx_engine->class_instance);
+
+ igt_assert((ctx_engine = malloc(size)));
+
+ ctx_engine->extensions = 0;
+ for (i = 0; i < query_engine->num_engines; i++) {
+ ctx_engine->class_instance[i].class = query_engine->engines[i].class;
+ ctx_engine->class_instance[i].instance = query_engine->engines[i].instance;
+ }
+
+ ctx_param.ctx_id = ctx_id;
+ ctx_param.size = size;
+ ctx_param.param = I915_CONTEXT_PARAM_ENGINES;
+ ctx_param.value = to_user_pointer(ctx_engine);
+
+ /* check whether we free the engines */
+ igt_require(!ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, &ctx_param));
+
+ free(ctx_engine);
+}
+
+int __gem_setup_ctx_engines(int fd, uint32_t ctx_id)
+{
+ struct drm_i915_query_engine_info *query_engine;
+ int n;
+
+ query_engine = query_engines(fd);
+ set_param(fd, ctx_id, query_engine);
+
+ n = query_engine->num_engines;
+ free(query_engine);
+
+ return n;
+}
diff --git a/lib/igt_gt.h b/lib/igt_gt.h
index 54e95da9..512f958d 100644
--- a/lib/igt_gt.h
+++ b/lib/igt_gt.h
@@ -86,8 +86,13 @@ extern const struct intel_execution_engine {
e__++) \
for_if (gem_ring_has_physical_engine(fd__, flags__ = e__->exec_id | e__->flags))
+#define for_each_engine_ctx(fd, ctx, e) \
+ for (int __m = __gem_setup_ctx_engines(fd, ctx), __e = e = 1; \
+ __e <= __m; e = ++__e)
+
bool gem_ring_is_physical_engine(int fd, unsigned int ring);
bool gem_ring_has_physical_engine(int fd, unsigned int ring);
+int __gem_setup_ctx_engines(int fd, uint32_t ctx_id);
bool gem_can_store_dword(int fd, unsigned int engine);
--
2.20.0.rc1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2018-11-26 20:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-26 20:43 [igt-dev] [PATCH v3 0/3] new engine discovery interface Andi Shyti
2018-11-26 20:43 ` [igt-dev] [PATCH v3 1/3] include/drm-uapi: import i915_drm.h header file Andi Shyti
2018-11-26 20:43 ` Andi Shyti [this message]
2018-11-27 12:00 ` [igt-dev] [PATCH v3 2/3] lib: implement new engine discovery interface Tvrtko Ursulin
2018-11-27 20:33 ` Andi Shyti
2018-11-28 8:29 ` Tvrtko Ursulin
2018-12-14 15:34 ` [igt-dev] [PATCH v3.5 " Andi Shyti
2018-12-21 11:48 ` Tvrtko Ursulin
2018-11-26 20:43 ` [igt-dev] [PATCH v3 3/3] tests: gem_exec_basic: add "exec-ctx" buffer execution demo test Andi Shyti
2018-11-26 21:10 ` Chris Wilson
2018-11-27 11:40 ` Tvrtko Ursulin
2018-11-26 22:23 ` [igt-dev] ✗ Fi.CI.BAT: failure for new engine discovery interface (rev3) Patchwork
2018-12-14 15:50 ` [igt-dev] ✗ Fi.CI.BAT: failure for new engine discovery interface (rev4) Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181126204349.6739-3-andi.shyti@intel.com \
--to=andi.shyti@intel.com \
--cc=andi@etezian.org \
--cc=igt-dev@lists.freedesktop.org \
--cc=tvrtko.ursulin@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox