[PATCH i-g-t 1/3] lib/xe_gt: Move reset related function to xe_gt.c
Michal Wajdeczko
michal.wajdeczko at intel.com
Wed May 28 21:26:16 UTC 2025
Those helper functions are per GT and related query function is
already there. While around add simple documentation.
Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
---
lib/xe/xe_gt.c | 39 +++++++++++++++++++++++++++++++++++++++
lib/xe/xe_gt.h | 3 +++
lib/xe/xe_ioctl.c | 23 -----------------------
lib/xe/xe_ioctl.h | 2 --
lib/xe/xe_legacy.c | 1 +
tests/intel/xe_wedged.c | 1 +
6 files changed, 44 insertions(+), 25 deletions(-)
diff --git a/lib/xe/xe_gt.c b/lib/xe/xe_gt.c
index a1e080b88..8bceca10d 100644
--- a/lib/xe/xe_gt.c
+++ b/lib/xe/xe_gt.c
@@ -57,6 +57,45 @@ bool has_xe_gt_reset(int fd)
return 1;
}
+static void xe_force_gt_reset(int fd, int gt, bool sync)
+{
+ char reset_string[128];
+ struct stat st;
+
+ igt_assert_eq(fstat(fd, &st), 0);
+
+ snprintf(reset_string, sizeof(reset_string),
+ "cat /sys/kernel/debug/dri/%d/gt%d/force_reset%s",
+ minor(st.st_rdev), gt, sync ? "_sync" : "");
+ system(reset_string);
+}
+
+/**
+ * xe_force_gt_reset_async:
+ * @fd: the Xe DRM file descriptor
+ * @gt: the GT identifier
+ *
+ * This function forces a reset on the selected GT.
+ * It does not wait for the reset completion.
+ */
+void xe_force_gt_reset_async(int fd, int gt)
+{
+ xe_force_gt_reset(fd, gt, false);
+}
+
+/**
+ * xe_force_gt_reset_async:
+ * @fd: the Xe DRM file descriptor
+ * @gt: the GT identifier
+ *
+ * This function forces a reset on the selected GT.
+ * It will wait until the reset completes.
+ */
+void xe_force_gt_reset_sync(int fd, int gt)
+{
+ xe_force_gt_reset(fd, gt, true);
+}
+
/**
* xe_force_gt_reset_all:
*
diff --git a/lib/xe/xe_gt.h b/lib/xe/xe_gt.h
index 06a59281c..93525ea35 100644
--- a/lib/xe/xe_gt.h
+++ b/lib/xe/xe_gt.h
@@ -12,6 +12,9 @@
bool has_xe_gt_reset(int fd);
void xe_force_gt_reset_all(int fd);
+void xe_force_gt_reset_async(int fd, int gt);
+void xe_force_gt_reset_sync(int fd, int gt);
+
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);
diff --git a/lib/xe/xe_ioctl.c b/lib/xe/xe_ioctl.c
index 53a53cd0d..1e95af409 100644
--- a/lib/xe/xe_ioctl.c
+++ b/lib/xe/xe_ioctl.c
@@ -585,26 +585,3 @@ int64_t xe_wait_ufence(int fd, uint64_t *addr, uint64_t value,
igt_assert_eq(__xe_wait_ufence(fd, addr, value, exec_queue, &timeout), 0);
return timeout;
}
-
-static void xe_force_gt_reset(int fd, int gt, bool sync)
-{
- char reset_string[128];
- struct stat st;
-
- igt_assert_eq(fstat(fd, &st), 0);
-
- snprintf(reset_string, sizeof(reset_string),
- "cat /sys/kernel/debug/dri/%d/gt%d/force_reset%s",
- minor(st.st_rdev), gt, sync ? "_sync" : "");
- system(reset_string);
-}
-
-void xe_force_gt_reset_async(int fd, int gt)
-{
- xe_force_gt_reset(fd, gt, false);
-}
-
-void xe_force_gt_reset_sync(int fd, int gt)
-{
- xe_force_gt_reset(fd, gt, true);
-}
diff --git a/lib/xe/xe_ioctl.h b/lib/xe/xe_ioctl.h
index 522094ae2..6302d1a7d 100644
--- a/lib/xe/xe_ioctl.h
+++ b/lib/xe/xe_ioctl.h
@@ -99,7 +99,5 @@ int __xe_wait_ufence(int fd, uint64_t *addr, uint64_t value,
uint32_t exec_queue, int64_t *timeout);
int64_t xe_wait_ufence(int fd, uint64_t *addr, uint64_t value,
uint32_t exec_queue, int64_t timeout);
-void xe_force_gt_reset_async(int fd, int gt);
-void xe_force_gt_reset_sync(int fd, int gt);
#endif /* XE_IOCTL_H */
diff --git a/lib/xe/xe_legacy.c b/lib/xe/xe_legacy.c
index a3ff5da03..6570cf1e6 100644
--- a/lib/xe/xe_legacy.c
+++ b/lib/xe/xe_legacy.c
@@ -5,6 +5,7 @@
#include "lib/igt_syncobj.h"
#include "linux_scaffold.h"
+#include "xe/xe_gt.h"
#include "xe/xe_ioctl.h"
#include "xe/xe_legacy.h"
#include "xe/xe_spin.h"
diff --git a/tests/intel/xe_wedged.c b/tests/intel/xe_wedged.c
index 1d2c510b7..7fc7ca9eb 100644
--- a/tests/intel/xe_wedged.c
+++ b/tests/intel/xe_wedged.c
@@ -22,6 +22,7 @@
#include "igt_sysfs.h"
#include "xe_drm.h"
+#include "xe/xe_gt.h"
#include "xe/xe_ioctl.h"
#include "xe/xe_query.h"
#include "xe/xe_spin.h"
--
2.47.1
More information about the igt-dev
mailing list