All of lore.kernel.org
 help / color / mirror / Atom feed
From: priyanka.dandamudi@intel.com
To: priyanka.dandamudi@intel.com, petri.latvala@intel.com,
	ashutosh.dixit@intel.com, umesh.nerlige.ramappa@intel.com,
	arjun.melkaveri@intel.com, krishnaiah.bommu@intel.com,
	igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 5/6] lib/intel_ctx: Create intel_ctx with physical engines in a single gt
Date: Thu, 21 Apr 2022 20:22:10 +0530	[thread overview]
Message-ID: <20220421145211.464313-6-priyanka.dandamudi@intel.com> (raw)
In-Reply-To: <20220421145211.464313-1-priyanka.dandamudi@intel.com>

From: Ashutosh Dixit <ashutosh.dixit@intel.com>

Introduce intel_ctx_create_for_gt for creating an intel_ctx_t containing
all physical engines belonging to a single gt.

Cc: Zbigniew Kempczynski <zbigniew.kempczynski@intel.com>
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
---
 lib/intel_ctx.c | 41 +++++++++++++++++++++++++++++++++++++++++
 lib/intel_ctx.h |  2 ++
 2 files changed, 43 insertions(+)

diff --git a/lib/intel_ctx.c b/lib/intel_ctx.c
index e19a54a8..14866511 100644
--- a/lib/intel_ctx.c
+++ b/lib/intel_ctx.c
@@ -61,6 +61,27 @@ intel_ctx_cfg_t intel_ctx_cfg_all_physical(int fd)
 	return cfg;
 }
 
+/**
+ * intel_ctx_cfg_for_gt:
+ * @fd: open i915 drm file descriptor
+ * @gt: gt id
+ *
+ * Returns an intel_ctx_cfg_t containing all physical engines belonging to @gt
+ */
+intel_ctx_cfg_t intel_ctx_cfg_for_gt(int fd, int gt)
+{
+	struct i915_engine_class_instance *ci;
+	intel_ctx_cfg_t cfg = {};
+	unsigned int count;
+
+	ci = gem_list_engines(fd, 1u << gt, ~0u, &count);
+	memcpy(&cfg.engines, ci, count * sizeof(*ci));
+	cfg.num_engines = count;
+	free(ci);
+
+	return cfg;
+}
+
 /**
  * intel_ctx_cfg_for_engine:
  * @class: engine class
@@ -295,6 +316,26 @@ const intel_ctx_t *intel_ctx_create_all_physical(int fd)
 	return intel_ctx_create(fd, &cfg);
 }
 
+/**
+ * intel_ctx_create_for_gt:
+ * @fd: open i915 drm file descriptor
+ * @gt: gt id
+ *
+ * Creates an intel_ctx_t containing all physical engines belonging to @gt
+ */
+const intel_ctx_t *intel_ctx_create_for_gt(int fd, int gt)
+{
+	intel_ctx_cfg_t cfg;
+
+	igt_require(gem_has_contexts(fd) || !gt);
+
+	if (!gem_has_contexts(fd))
+		return intel_ctx_0(fd);
+
+	cfg = intel_ctx_cfg_for_gt(fd, gt);
+	return intel_ctx_create(fd, &cfg);
+}
+
 /**
  * intel_ctx_cfg_engine_class:
  * @cfg: an intel_ctx_cfg_t
diff --git a/lib/intel_ctx.h b/lib/intel_ctx.h
index 89c65fcd..3cfeaae8 100644
--- a/lib/intel_ctx.h
+++ b/lib/intel_ctx.h
@@ -54,6 +54,7 @@ typedef struct intel_ctx_cfg {
 
 intel_ctx_cfg_t intel_ctx_cfg_for_engine(unsigned int class, unsigned int inst);
 intel_ctx_cfg_t intel_ctx_cfg_all_physical(int fd);
+intel_ctx_cfg_t intel_ctx_cfg_for_gt(int fd, int gt);
 int intel_ctx_cfg_engine_class(const intel_ctx_cfg_t *cfg, unsigned int engine);
 
 /**
@@ -75,6 +76,7 @@ const intel_ctx_t *intel_ctx_0(int fd);
 const intel_ctx_t *intel_ctx_create_for_engine(int fd, unsigned int class,
 					       unsigned int inst);
 const intel_ctx_t *intel_ctx_create_all_physical(int fd);
+const intel_ctx_t *intel_ctx_create_for_gt(int fd, int gt);
 void intel_ctx_destroy(int fd, const intel_ctx_t *ctx);
 
 unsigned int intel_ctx_engine_class(const intel_ctx_t *ctx, unsigned int engine);
-- 
2.25.1

  parent reply	other threads:[~2022-04-21 15:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21 14:52 [igt-dev] [PATCH i-g-t 0/6] Test for shared reset domain priyanka.dandamudi
2022-04-21 14:52 ` [igt-dev] [PATCH i-g-t 1/6] lib/i915/i915_drm_local : Add DRM_I915_QUERY_DISTANCE_INFO query priyanka.dandamudi
2022-04-21 16:34   ` Matt Roper
2022-04-21 16:41     ` Dixit, Ashutosh
2022-04-21 14:52 ` [igt-dev] [PATCH i-g-t 2/6] lib/igt_sysfs: Add helpers to iterate over GTs priyanka.dandamudi
2022-04-22  5:45   ` Dixit, Ashutosh
2022-04-22  5:58     ` Dixit, Ashutosh
2022-04-25 20:07     ` Umesh Nerlige Ramappa
2022-04-25 23:13       ` Dixit, Ashutosh
2022-04-21 14:52 ` [igt-dev] [PATCH i-g-t 3/6] lib/sysfs: helper for number of gts priyanka.dandamudi
2022-04-26  8:33   ` Kamil Konieczny
2022-04-26 15:33     ` Dandamudi, Priyanka
2022-04-26 16:02       ` Dandamudi, Priyanka
2022-04-21 14:52 ` [igt-dev] [PATCH i-g-t 4/6] lib/i915/gem_engine_topology: Add helper to list engines priyanka.dandamudi
2022-04-21 14:52 ` priyanka.dandamudi [this message]
2022-04-21 14:52 ` [igt-dev] [PATCH i-g-t 6/6] tests/gem_reset_stats: Test for shared reset domain priyanka.dandamudi
2022-04-21 21:14   ` Umesh Nerlige Ramappa
2022-04-21 16:15 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2022-04-21 21:26 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2022-04-22  5:06 ` [igt-dev] ✓ Fi.CI.IGT: success " Patchwork
2022-04-22  5:36 ` 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=20220421145211.464313-6-priyanka.dandamudi@intel.com \
    --to=priyanka.dandamudi@intel.com \
    --cc=arjun.melkaveri@intel.com \
    --cc=ashutosh.dixit@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=krishnaiah.bommu@intel.com \
    --cc=petri.latvala@intel.com \
    --cc=umesh.nerlige.ramappa@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.