[igt-dev] [PATCH i-g-t 2/3] lib/xe: Add hang library support
Ch, Sai Gowtham
sai.gowtham.ch at intel.com
Fri Aug 11 09:21:09 UTC 2023
>-----Original Message-----
>From: Kumar, Janga Rahul <janga.rahul.kumar at intel.com>
>Sent: Friday, August 11, 2023 2:55 AM
>To: igt-dev at lists.freedesktop.org; Gandi, Ramadevi
><ramadevi.gandi at intel.com>; Kumar, Janga Rahul
><janga.rahul.kumar at intel.com>
>Cc: Ch, Sai Gowtham <sai.gowtham.ch at intel.com>; Joshi, Kunal1
><kunal1.joshi at intel.com>; kamil.konieczny at linux.intel.com; Karas, Anna
><anna.karas at intel.com>
>Subject: [PATCH i-g-t 2/3] lib/xe: Add hang library support
>
>From: Janga Rahul Kumar <janga.rahul.kumar at 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 at intel.com>
>Cc: Kunal Joshi <kunal1.joshi at intel.com>
>Cc: Kamil Konieczny <kamil.konieczny at linux.intel.com>
>Cc: Anna Karas <anna.karas at intel.com>
>Signed-off-by: Janga Rahul Kumar <janga.rahul.kumar at intel.com>
>Tested-by: Kunal Joshi <kunal1.joshi at intel.com>
>---
> lib/xe/xe_gt.c | 69
>++++++++++++++++++++++++++++++++++++++++++++++++++
> lib/xe/xe_gt.h | 7 ++++-
> 2 files changed, 75 insertions(+), 1 deletion(-)
>
>diff --git a/lib/xe/xe_gt.c b/lib/xe/xe_gt.c index a72f9bcc9..10ffb00d5 100644
>--- a/lib/xe/xe_gt.c
>+++ b/lib/xe/xe_gt.c
>@@ -59,3 +59,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.
Close the Parentheses here.
Rest looks good to me with the above fix.
Reviewed-by: Sai Gowtham Ch <sai.gowtham.ch at intel.com>
>+ *
>+ * 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 e075ebf62..26bbe23d4
>100644
>--- a/lib/xe/xe_gt.h
>+++ b/lib/xe/xe_gt.h
>@@ -12,6 +12,9 @@
>
> #include "igt_core.h"
> #include "igt_sysfs.h"
>+#include "lib/igt_gt.h"
>+#include "lib/intel_chipset.h"
>+#include "xe_spin.h"
> #include "xe_ioctl.h"
> #include "xe_query.h"
>
>@@ -24,4 +27,6 @@
>
> 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
More information about the igt-dev
mailing list