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/2] lib/xe: Add hang library support
Date: Tue, 25 Jul 2023 12:46:22 +0530 [thread overview]
Message-ID: <20230725071622.206601-3-janga.rahul.kumar@intel.com> (raw)
In-Reply-To: <20230725071622.206601-1-janga.rahul.kumar@intel.com>
From: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
Add hang library support using spinners.
Cc: Sai Gowtham Ch <sai.gowtham.ch@intel.com>
Cc: Kunal Joshi <kunal1.joshi@intel.com>
Signed-off-by: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
---
lib/igt_gt.c | 21 +++++++++++++++++++++
lib/xe/xe_ioctl.c | 20 ++++++++++++++++++++
lib/xe/xe_ioctl.h | 6 ++++++
3 files changed, 47 insertions(+)
diff --git a/lib/igt_gt.c b/lib/igt_gt.c
index 2ce464ba6..6821179ca 100644
--- a/lib/igt_gt.c
+++ b/lib/igt_gt.c
@@ -170,6 +170,15 @@ static void context_set_ban(int fd, unsigned ctx, unsigned ban)
igt_hang_t igt_allow_hang(int fd, unsigned ctx, unsigned flags)
{
+ if (is_xe_device(fd)) {
+ if (!igt_check_boolean_env_var("IGT_HANG", true))
+ igt_skip("hang injection disabled by user [IGT_HANG=0]\n");
+
+ igt_require(has_gpu_reset(fd));
+
+ return (struct igt_hang){ 0, ctx, 0, flags };
+ }
+
struct drm_i915_gem_context_param param = {
.ctx_id = ctx,
};
@@ -219,6 +228,9 @@ igt_hang_t igt_allow_hang(int fd, unsigned ctx, unsigned flags)
void igt_disallow_hang(int fd, igt_hang_t arg)
{
+ if (is_xe_device(fd))
+ return;
+
context_set_ban(fd, arg.ctx, arg.ban);
if ((arg.flags & HANG_ALLOW_CAPTURE) == 0) {
@@ -290,6 +302,9 @@ static bool has_ctx_exec(int fd, unsigned ring, uint32_t ctx)
static igt_hang_t __igt_hang_ctx(int fd, uint64_t ahnd, uint32_t ctx, int ring,
unsigned flags)
{
+ if (is_xe_device(fd))
+ return xe_hang_engine(fd, ahnd, ctx, ring, flags);
+
struct drm_i915_gem_context_param param;
igt_spin_t *spin;
unsigned ban;
@@ -372,6 +387,12 @@ void igt_post_hang_ring(int fd, igt_hang_t arg)
if (!arg.spin)
return;
+ if (is_xe_device(fd)) {
+ igt_spin_free(fd, arg.spin);
+ xe_post_hang_ring(fd, arg);
+ return;
+ }
+
gem_sync(fd, arg.spin->handle); /* Wait until it hangs */
igt_spin_free(fd, arg.spin);
diff --git a/lib/xe/xe_ioctl.c b/lib/xe/xe_ioctl.c
index 488aa218e..5ec85239a 100644
--- a/lib/xe/xe_ioctl.c
+++ b/lib/xe/xe_ioctl.c
@@ -520,6 +520,26 @@ void xe_force_gt_reset(int fd, int gt)
system(reset_string);
}
+
+igt_hang_t xe_hang_engine(int fd, uint64_t ahnd, uint32_t ctx, int ring,
+ unsigned flags)
+{
+ uint32_t vm;
+ unsigned int engine;
+ igt_spin_t *spin_t;
+ vm = xe_vm_create(fd, 0, 0);
+ engine = xe_engine_create_class(fd, vm, DRM_XE_ENGINE_CLASS_COPY);
+
+ spin_t = igt_spin_new(fd, .ahnd = ahnd, .engine = engine, .vm = vm, .flags = IGT_SPIN_NO_PREEMPTION);
+ return (igt_hang_t){ spin_t, engine, 0, flags };
+}
+
+void xe_post_hang_ring(int fd, igt_hang_t arg)
+{
+ xe_engine_destroy(fd, arg.ctx);
+ xe_vm_destroy(fd, arg.spin->vm);
+}
+
void xe_vm_madvise(int fd, uint32_t vm, uint64_t addr, uint64_t size,
uint32_t property, uint32_t value)
{
diff --git a/lib/xe/xe_ioctl.h b/lib/xe/xe_ioctl.h
index 5a528b345..0e9708194 100644
--- a/lib/xe/xe_ioctl.h
+++ b/lib/xe/xe_ioctl.h
@@ -15,6 +15,9 @@
#include <stdint.h>
#include <xe_drm.h>
+#include "lib/igt_gt.h"
+#include "xe_spin.h"
+
uint32_t xe_cs_prefetch_size(int fd);
uint32_t xe_vm_create(int fd, uint32_t flags, uint64_t ext);
int __xe_vm_bind(int fd, uint32_t vm, uint32_t engine, uint32_t bo,
@@ -89,6 +92,9 @@ int64_t xe_wait_ufence_abstime(int fd, uint64_t *addr, uint64_t value,
void xe_force_gt_reset(int fd, int gt);
void xe_force_gt_reset_all(int fd);
bool has_xe_gt_reset(int fd);
+igt_hang_t xe_hang_engine(int fd, uint64_t ahnd, uint32_t ctx, int ring,
+ unsigned flags);
+void xe_post_hang_ring(int fd, igt_hang_t arg);
void xe_vm_madvise(int fd, uint32_t vm, uint64_t addr, uint64_t size,
uint32_t property, uint32_t value);
--
2.25.1
next prev parent reply other threads:[~2023-07-25 7:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-25 7:16 [igt-dev] [PATCH i-g-t 0/2] Add Xe lib support for hang & GT reset janga.rahul.kumar
2023-07-25 7:16 ` [igt-dev] [PATCH i-g-t 1/2] lib/xe: Add support to reset all GT's janga.rahul.kumar
2023-07-25 17:44 ` Kamil Konieczny
2023-07-26 19:59 ` Karas, Anna
2023-07-25 7:16 ` janga.rahul.kumar [this message]
2023-07-25 18:04 ` [igt-dev] [PATCH i-g-t 2/2] lib/xe: Add hang library support Kamil Konieczny
2023-07-26 20:44 ` Karas, Anna
2023-08-07 4:06 ` Kumar, Janga Rahul
2023-08-07 4:02 ` Kumar, Janga Rahul
2023-07-25 8:17 ` [igt-dev] ✗ Fi.CI.BAT: failure for Add Xe lib support for hang & GT reset Patchwork
2023-08-01 13:51 ` [igt-dev] [PATCH i-g-t 0/2] " Joshi, Kunal1
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=20230725071622.206601-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