Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe/debugfs: Make sysfs gt force reset synchronous
@ 2023-12-27  8:32 Karthik Poosa
  2023-12-27 10:17 ` Nilawar, Badal
                   ` (8 more replies)
  0 siblings, 9 replies; 15+ messages in thread
From: Karthik Poosa @ 2023-12-27  8:32 UTC (permalink / raw)
  To: intel-xe; +Cc: Karthik Poosa, rodrigo.vivi

Wait for gt reset to complete before returning from force_reset
sysfs call. Without this igt test freq_reset_multiple fails
sporadically in case xe_guc_pc is not started.

v2:
- Changed wait for completion to interruptible (Anshuman).
- Moved timeout to xe_gt.h (Anshuman).
- Created a debugfs for updating timeout (Rodrigo).

Testcase: igt@xe_guc_pc@freq_reset_multiple
Signed-off-by: Karthik Poosa <karthik.poosa@intel.com>
---
 drivers/gpu/drm/xe/xe_gt.c         |  2 ++
 drivers/gpu/drm/xe/xe_gt_debugfs.c | 12 ++++++++++++
 drivers/gpu/drm/xe/xe_gt_types.h   |  6 ++++++
 3 files changed, 20 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
index 3af2adec1295..47abb9336c58 100644
--- a/drivers/gpu/drm/xe/xe_gt.c
+++ b/drivers/gpu/drm/xe/xe_gt.c
@@ -65,6 +65,7 @@ struct xe_gt *xe_gt_alloc(struct xe_tile *tile)
 
 	gt->tile = tile;
 	gt->ordered_wq = alloc_ordered_workqueue("gt-ordered-wq", 0);
+	init_completion(&gt->reset_done);
 
 	return gt;
 }
@@ -633,6 +634,7 @@ static int gt_reset(struct xe_gt *gt)
 	xe_device_mem_access_put(gt_to_xe(gt));
 	XE_WARN_ON(err);
 
+	complete(&gt->reset_done);
 	xe_gt_info(gt, "reset done\n");
 
 	return 0;
diff --git a/drivers/gpu/drm/xe/xe_gt_debugfs.c b/drivers/gpu/drm/xe/xe_gt_debugfs.c
index c4b67cf09f8f..fbda886c8a95 100644
--- a/drivers/gpu/drm/xe/xe_gt_debugfs.c
+++ b/drivers/gpu/drm/xe/xe_gt_debugfs.c
@@ -58,8 +58,16 @@ static int hw_engines(struct seq_file *m, void *data)
 static int force_reset(struct seq_file *m, void *data)
 {
 	struct xe_gt *gt = node_to_gt(m->private);
+	struct xe_device *xe = gt_to_xe(gt);
+	long ret;
 
 	xe_gt_reset_async(gt);
+	ret = wait_for_completion_interruptible_timeout(&gt->reset_done,
+						msecs_to_jiffies(gt->reset_timeout_ms));
+	if (ret <= 0) {
+		drm_err(&xe->drm, "gt reset timed out/interrputed, ret %ld\n", ret);
+		return -ETIMEDOUT;
+	}
 
 	return 0;
 }
@@ -225,6 +233,10 @@ void xe_gt_debugfs_register(struct xe_gt *gt)
 		return;
 	}
 
+	/* set a default timeout */
+	gt->reset_timeout_ms = 1000;
+	debugfs_create_u32("gt_reset_timeout_ms", 0600, root,
+					&gt->reset_timeout_ms);
 	/*
 	 * Allocate local copy as we need to pass in the GT to the debugfs
 	 * entry and drm_debugfs_create_files just references the drm_info_list
diff --git a/drivers/gpu/drm/xe/xe_gt_types.h b/drivers/gpu/drm/xe/xe_gt_types.h
index f74684660475..824cefde20d2 100644
--- a/drivers/gpu/drm/xe/xe_gt_types.h
+++ b/drivers/gpu/drm/xe/xe_gt_types.h
@@ -358,6 +358,12 @@ struct xe_gt {
 		/** @oob: bitmap with active OOB workaroudns */
 		unsigned long *oob;
 	} wa_active;
+
+	/** @reset_done : completion for GT reset */
+	struct completion reset_done;
+
+	/** @gt_reset_timeout_ms : gt reset timeout in ms */
+	u32 reset_timeout_ms;
 };
 
 #endif
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread
* [PATCH] drm/xe/debugfs: Make sysfs gt force reset synchronous
@ 2023-12-27 11:58 Karthik Poosa
  0 siblings, 0 replies; 15+ messages in thread
From: Karthik Poosa @ 2023-12-27 11:58 UTC (permalink / raw)
  To: intel-xe; +Cc: Karthik Poosa, rodrigo.vivi

Wait for gt reset to complete before returning from force_reset
sysfs call. Without this igt test freq_reset_multiple fails
sporadically in case xe_guc_pc is not started.

v2:
- Changed wait for completion to interruptible (Anshuman).
- Moved timeout to xe_gt.h (Anshuman).
- Created a debugfs for updating timeout (Rodrigo).
- Moved completion and timeout under gt->reset struct (Badal).

Testcase: igt@xe_guc_pc@freq_reset_multiple
Signed-off-by: Karthik Poosa <karthik.poosa@intel.com>
---
 drivers/gpu/drm/xe/xe_gt.c         |  2 ++
 drivers/gpu/drm/xe/xe_gt_debugfs.c | 12 ++++++++++++
 drivers/gpu/drm/xe/xe_gt_types.h   |  5 +++++
 3 files changed, 19 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
index 3af2adec1295..c8d2c18b0c62 100644
--- a/drivers/gpu/drm/xe/xe_gt.c
+++ b/drivers/gpu/drm/xe/xe_gt.c
@@ -65,6 +65,7 @@ struct xe_gt *xe_gt_alloc(struct xe_tile *tile)
 
 	gt->tile = tile;
 	gt->ordered_wq = alloc_ordered_workqueue("gt-ordered-wq", 0);
+	init_completion(&gt->reset.done);
 
 	return gt;
 }
@@ -633,6 +634,7 @@ static int gt_reset(struct xe_gt *gt)
 	xe_device_mem_access_put(gt_to_xe(gt));
 	XE_WARN_ON(err);
 
+	complete(&gt->reset.done);
 	xe_gt_info(gt, "reset done\n");
 
 	return 0;
diff --git a/drivers/gpu/drm/xe/xe_gt_debugfs.c b/drivers/gpu/drm/xe/xe_gt_debugfs.c
index c4b67cf09f8f..223dedf5c2ab 100644
--- a/drivers/gpu/drm/xe/xe_gt_debugfs.c
+++ b/drivers/gpu/drm/xe/xe_gt_debugfs.c
@@ -58,8 +58,16 @@ static int hw_engines(struct seq_file *m, void *data)
 static int force_reset(struct seq_file *m, void *data)
 {
 	struct xe_gt *gt = node_to_gt(m->private);
+	struct xe_device *xe = gt_to_xe(gt);
+	long ret;
 
 	xe_gt_reset_async(gt);
+	ret = wait_for_completion_interruptible_timeout(&gt->reset.done,
+						msecs_to_jiffies(gt->reset.timeout_ms));
+	if (ret <= 0) {
+		drm_err(&xe->drm, "gt reset timed out/interrputed, ret %ld\n", ret);
+		return -ETIMEDOUT;
+	}
 
 	return 0;
 }
@@ -245,5 +253,9 @@ void xe_gt_debugfs_register(struct xe_gt *gt)
 				 ARRAY_SIZE(debugfs_list),
 				 root, minor);
 
+	/* set a default gt reset timeout value */
+	gt->reset.timeout_ms = 1000;
+	debugfs_create_u32("gt_reset_timeout_ms", 0600, root,
+					&gt->reset.timeout_ms);
 	xe_uc_debugfs_register(&gt->uc, root);
 }
diff --git a/drivers/gpu/drm/xe/xe_gt_types.h b/drivers/gpu/drm/xe/xe_gt_types.h
index f74684660475..210a376c0e46 100644
--- a/drivers/gpu/drm/xe/xe_gt_types.h
+++ b/drivers/gpu/drm/xe/xe_gt_types.h
@@ -148,6 +148,10 @@ struct xe_gt {
 		 * code to safely flush all code paths
 		 */
 		struct work_struct worker;
+		/** @done : completion for GT reset */
+		struct completion done;
+		/** @timeout_ms : gt reset timeout in ms */
+		u32 timeout_ms;
 	} reset;
 
 	/** @tlb_invalidation: TLB invalidation state */
@@ -358,6 +362,7 @@ struct xe_gt {
 		/** @oob: bitmap with active OOB workaroudns */
 		unsigned long *oob;
 	} wa_active;
+
 };
 
 #endif
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-01-04  9:30 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-27  8:32 [PATCH] drm/xe/debugfs: Make sysfs gt force reset synchronous Karthik Poosa
2023-12-27 10:17 ` Nilawar, Badal
2023-12-27 10:36 ` Gupta, Anshuman
2023-12-27 12:59   ` Poosa, Karthik
2023-12-27 13:52     ` Gupta, Anshuman
2023-12-27 15:23   ` Nilawar, Badal
2023-12-28 19:01     ` Matthew Brost
2024-01-04  8:45 ` ✓ CI.Patch_applied: success for " Patchwork
2024-01-04  8:46 ` ✗ CI.checkpatch: warning " Patchwork
2024-01-04  8:47 ` ✓ CI.KUnit: success " Patchwork
2024-01-04  8:54 ` ✓ CI.Build: " Patchwork
2024-01-04  8:55 ` ✗ CI.Hooks: failure " Patchwork
2024-01-04  8:56 ` ✓ CI.checksparse: success " Patchwork
2024-01-04  9:30 ` ✓ CI.BAT: " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2023-12-27 11:58 [PATCH] " Karthik Poosa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox