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 1/3] lib/xe: Add support to reset all GT's
Date: Fri, 11 Aug 2023 02:55:19 +0530	[thread overview]
Message-ID: <20230810212521.1405970-2-janga.rahul.kumar@intel.com> (raw)
In-Reply-To: <20230810212521.1405970-1-janga.rahul.kumar@intel.com>

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

Introduce xe gt library.

Add support to check GT reset and force reset all GT's.

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/meson.build |  1 +
 lib/xe/xe_gt.c  | 61 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/xe/xe_gt.h  | 27 ++++++++++++++++++++++
 3 files changed, 89 insertions(+)
 create mode 100644 lib/xe/xe_gt.c
 create mode 100644 lib/xe/xe_gt.h

diff --git a/lib/meson.build b/lib/meson.build
index ce11c0715..b7bfcf4f0 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -103,6 +103,7 @@ lib_sources = [
 	'igt_dsc.c',
 	'xe/xe_compute.c',
 	'xe/xe_compute_square_kernels.c',
+	'xe/xe_gt.c',
 	'xe/xe_ioctl.c',
 	'xe/xe_query.c',
 	'xe/xe_spin.c',
diff --git a/lib/xe/xe_gt.c b/lib/xe/xe_gt.c
new file mode 100644
index 000000000..a72f9bcc9
--- /dev/null
+++ b/lib/xe/xe_gt.c
@@ -0,0 +1,61 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2023 Intel Corporation
+ *
+ * Authors:
+ *    Janga Rahul Kumar <janga.rahul.kumar@intel.com>
+ */
+
+#include <fcntl.h>
+#include "xe_gt.h"
+
+/**
+ * has_xe_gt_reset:
+ * @fd: open xe drm file descriptor
+ *
+ * Check gt force reset sysfs entry is available or not
+ *
+ * Returns: reset sysfs entry available
+ */
+bool has_xe_gt_reset(int fd)
+{
+	char reset_sysfs_path[100];
+	struct stat st;
+	int gt;
+	int reset_sysfs_fd = -1;
+	int sysfs_fd = -1;
+
+	igt_assert_eq(fstat(fd, &st), 0);
+	sysfs_fd = igt_sysfs_open(fd);
+
+	igt_assert(sysfs_fd != -1);
+	xe_for_each_gt(fd, gt) {
+		sprintf(reset_sysfs_path, "/sys/kernel/debug/dri/%d/gt%d/force_reset",
+				minor(st.st_rdev), gt);
+		reset_sysfs_fd = openat(sysfs_fd, reset_sysfs_path, O_RDONLY);
+
+		if (reset_sysfs_fd == -1) {
+			close(sysfs_fd);
+			return 0;
+		}
+
+		close(reset_sysfs_fd);
+	}
+
+	close(sysfs_fd);
+	return 1;
+}
+
+/**
+ * xe_force_gt_reset_all:
+ *
+ * Forces reset of all the GT's.
+ */
+void xe_force_gt_reset_all(int xe_fd)
+{
+	int gt;
+
+	xe_for_each_gt(xe_fd, gt)
+		xe_force_gt_reset(xe_fd, gt);
+}
+
diff --git a/lib/xe/xe_gt.h b/lib/xe/xe_gt.h
new file mode 100644
index 000000000..e075ebf62
--- /dev/null
+++ b/lib/xe/xe_gt.h
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2023 Intel Corporation
+ *
+ * Authors:
+ *    Janga Rahul Kumar <janga.rahul.kumar@intel.com>
+ */
+
+#include <dirent.h>
+#include <stdint.h>
+#include <sys/stat.h>
+
+#include "igt_core.h"
+#include "igt_sysfs.h"
+#include "xe_ioctl.h"
+#include "xe_query.h"
+
+#ifdef __linux__
+#include <sys/sysmacros.h>
+#else
+#define major(__v__) (((__v__) >> 8) & 0xff)
+#define minor(__v__) ((__v__) & 0xff)
+#endif
+
+bool has_xe_gt_reset(int fd);
+void xe_force_gt_reset_all(int fd);
+
-- 
2.25.1

  reply	other threads:[~2023-08-10 21:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` janga.rahul.kumar [this message]
2023-08-11 15:55   ` [igt-dev] [PATCH i-g-t 1/3] lib/xe: Add support to reset all GT's Kamil Konieczny
2023-08-14 17:28     ` Kumar, Janga Rahul
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-10 21:25 ` [igt-dev] [PATCH i-g-t 3/3] lib/igt_gt: Extend hang library support to XE janga.rahul.kumar
2023-08-10 23:38 ` [igt-dev] ✓ Fi.CI.BAT: success for Add Xe lib support for hang & GT reset (rev4) Patchwork
2023-08-10 23:40 ` [igt-dev] ○ CI.xeBAT: info " Patchwork
2023-08-11 23:58 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
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-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 1/3] lib/xe: Add support to reset all GT's janga.rahul.kumar
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 1/3] lib/xe: Add support to reset all GT's janga.rahul.kumar
2023-08-10 10:17   ` Ch, Sai Gowtham
2023-08-11 13:52     ` Maarten Lankhorst
2023-08-11 14:01       ` Matthew Brost
2023-08-14 17:30         ` Kumar, Janga Rahul
2023-08-10 10:30   ` 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=20230810212521.1405970-2-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