Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: janga.rahul.kumar@intel.com
To: igt-dev@lists.freedesktop.org, ramadevi.gandi@intel.com,
	janga.rahul.kumar@intel.com
Cc: sai.gowtham.ch@intel.com, kunal1.joshi@intel.com
Subject: [igt-dev] [PATCH i-g-t 2/3] lib/xe: Add hang library support
Date: Wed, 16 Aug 2023 15:54:30 +0530	[thread overview]
Message-ID: <20230816102431.2014326-3-janga.rahul.kumar@intel.com> (raw)
In-Reply-To: <20230816102431.2014326-1-janga.rahul.kumar@intel.com>

From: Janga Rahul Kumar <janga.rahul.kumar@intel.com>

Add helper library support to submit hanging batch and clean
state post hang.

An hanging batch is a spinning batch that never gets stopped.

Cc: Sai Gowtham Ch <sai.gowtham.ch@intel.com>
Cc: Kunal Joshi <kunal1.joshi@intel.com>
Cc: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Cc: Anna Karas <anna.karas@intel.com>
Signed-off-by: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
Tested-by: Kunal Joshi <kunal1.joshi@intel.com>
Reviewed-by: Sai Gowtham Ch <sai.gowtham.ch@intel.com>
---
 lib/xe/xe_gt.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/xe/xe_gt.h |  6 ++++-
 2 files changed, 75 insertions(+), 1 deletion(-)

diff --git a/lib/xe/xe_gt.c b/lib/xe/xe_gt.c
index eb5a6c12a..743d7a26e 100644
--- a/lib/xe/xe_gt.c
+++ b/lib/xe/xe_gt.c
@@ -11,6 +11,7 @@
 
 #include "igt_core.h"
 #include "igt_sysfs.h"
+#include "lib/intel_chipset.h"
 #include "xe_gt.h"
 #include "xe_ioctl.h"
 #include "xe_query.h"
@@ -71,3 +72,72 @@ void xe_force_gt_reset_all(int xe_fd)
 		xe_force_gt_reset(xe_fd, gt);
 }
 
+/**
+ * xe_hang_ring:
+ * @fd: open xe drm file descriptor
+ * @ring: execbuf ring flag
+ *
+ * This helper function injects a hanging batch into @ring. It returns a
+ * #igt_hang_t structure which must be passed to xe_post_hang_ring() for
+ * hang post-processing (after the gpu hang interaction has been tested).
+ *
+ * Returns:
+ * Structure with helper internal state for xe_post_hang_ring().
+ */
+igt_hang_t xe_hang_ring(int fd, uint64_t ahnd, uint32_t ctx, int ring,
+				unsigned int flags)
+{
+	uint16_t class;
+	uint32_t vm;
+	unsigned int exec_queue;
+	igt_spin_t *spin_t;
+
+	vm = xe_vm_create(fd, 0, 0);
+
+	switch (ring) {
+	case I915_EXEC_DEFAULT:
+		if (IS_PONTEVECCHIO(intel_get_drm_devid(fd)))
+			class = DRM_XE_ENGINE_CLASS_COPY;
+		else
+			class = DRM_XE_ENGINE_CLASS_RENDER;
+		break;
+	case I915_EXEC_RENDER:
+		if (IS_PONTEVECCHIO(intel_get_drm_devid(fd)))
+			igt_skip("Render engine not supported on this platform.\n");
+		else
+			class = DRM_XE_ENGINE_CLASS_RENDER;
+		break;
+	case I915_EXEC_BLT:
+		class = DRM_XE_ENGINE_CLASS_COPY;
+		break;
+	case I915_EXEC_BSD:
+		class = DRM_XE_ENGINE_CLASS_VIDEO_DECODE;
+		break;
+	case I915_EXEC_VEBOX:
+		class = DRM_XE_ENGINE_CLASS_VIDEO_ENHANCE;
+		break;
+	default:
+		igt_assert_f(false, "Unknown engine: %x", (uint32_t) flags);
+	}
+
+	exec_queue = xe_exec_queue_create_class(fd, vm, class);
+
+	spin_t = igt_spin_new(fd, .ahnd = ahnd, .engine = exec_queue, .vm = vm,
+				.flags = IGT_SPIN_NO_PREEMPTION);
+	return (igt_hang_t){ spin_t, exec_queue, 0, flags };
+}
+
+/**
+ * xe_post_hang_ring:
+ * @fd: open xe drm file descriptor
+ * @arg: hang state from xe_hang_ring()
+ *
+ * This function does the necessary post-processing after a gpu hang injected
+ * with xe_hang_ring().
+ */
+void xe_post_hang_ring(int fd, igt_hang_t arg)
+{
+	xe_exec_queue_destroy(fd, arg.ctx);
+	xe_vm_destroy(fd, arg.spin->vm);
+}
+
diff --git a/lib/xe/xe_gt.h b/lib/xe/xe_gt.h
index d05ed1ed5..6fa05d6a9 100644
--- a/lib/xe/xe_gt.h
+++ b/lib/xe/xe_gt.h
@@ -6,6 +6,10 @@
  *    Janga Rahul Kumar <janga.rahul.kumar@intel.com>
  */
 
+#include "lib/igt_gt.h"
+
 bool has_xe_gt_reset(int fd);
 void xe_force_gt_reset_all(int fd);
-
+igt_hang_t xe_hang_ring(int fd, uint64_t ahnd, uint32_t ctx, int ring,
+				unsigned int flags);
+void xe_post_hang_ring(int fd, igt_hang_t arg);
-- 
2.25.1

  parent reply	other threads:[~2023-08-16 10:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-16 10:24 [igt-dev] [PATCH i-g-t 0/3] Add Xe lib support for hang & GT reset janga.rahul.kumar
2023-08-16 10:24 ` [igt-dev] [PATCH i-g-t 1/3] lib/xe: Add support to reset all GT's janga.rahul.kumar
2023-08-16 10:24 ` janga.rahul.kumar [this message]
2023-08-16 10:24 ` [igt-dev] [PATCH i-g-t 3/3] lib/igt_gt: Extend hang library support to XE janga.rahul.kumar
2023-08-16 11:00 ` [igt-dev] ✗ GitLab.Pipeline: warning for Add Xe lib support for hang & GT reset (rev6) Patchwork
2023-08-16 11:37 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-08-16 12:36 ` [igt-dev] ○ CI.xeBAT: info " Patchwork
2023-08-16 16:50 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2023-08-17 18:08   ` Kamil Konieczny
2023-08-18 12:35     ` Yedireswarapu, SaiX Nandan
  -- strict thread matches above, loose matches on Subject: below --
2023-08-14 17:29 [igt-dev] [PATCH i-g-t 0/3] Add Xe lib support for hang & GT reset janga.rahul.kumar
2023-08-14 17:29 ` [igt-dev] [PATCH i-g-t 2/3] lib/xe: Add hang library support janga.rahul.kumar
2023-08-10 21:25 [igt-dev] [PATCH i-g-t 0/3] Add Xe lib support for hang & GT reset janga.rahul.kumar
2023-08-10 21:25 ` [igt-dev] [PATCH i-g-t 2/3] lib/xe: Add hang library support janga.rahul.kumar
2023-08-11  9:21   ` Ch, Sai Gowtham
2023-08-07  3:58 [igt-dev] [PATCH i-g-t 0/3] Add Xe lib support for hang & GT reset janga.rahul.kumar
2023-08-07  3:58 ` [igt-dev] [PATCH i-g-t 2/3] lib/xe: Add hang library support janga.rahul.kumar
2023-08-10 13:11   ` Ch, Sai Gowtham

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=20230816102431.2014326-3-janga.rahul.kumar@intel.com \
    --to=janga.rahul.kumar@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kunal1.joshi@intel.com \
    --cc=ramadevi.gandi@intel.com \
    --cc=sai.gowtham.ch@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