[PATCH 1/2] drm/xe/gt: Add a synchronous GT reset function

Balasubramani Vivekanandan balasubramani.vivekanandan at intel.com
Thu Nov 14 13:37:37 UTC 2024


There are multiples places in the driver where a GT reset is initiated
and then the driver waits for the GT reset to complete by waiting for
the GT reset worker to complete. Wrap these two steps into a single
function which the driver can use whenever it needs the reset the GT
synchronously.

Signed-off-by: Balasubramani Vivekanandan <balasubramani.vivekanandan at intel.com>
---
 drivers/gpu/drm/xe/tests/xe_bo.c   | 3 +--
 drivers/gpu/drm/xe/tests/xe_mocs.c | 3 +--
 drivers/gpu/drm/xe/xe_gt.c         | 6 ++++++
 drivers/gpu/drm/xe/xe_gt.h         | 1 +
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/tests/xe_bo.c b/drivers/gpu/drm/xe/tests/xe_bo.c
index cd811aa2b227..396a11260d57 100644
--- a/drivers/gpu/drm/xe/tests/xe_bo.c
+++ b/drivers/gpu/drm/xe/tests/xe_bo.c
@@ -258,8 +258,7 @@ static int evict_test_run_tile(struct xe_device *xe, struct xe_tile *tile, struc
 		 * to do that here by triggering a GT reset.
 		 */
 		for_each_gt(__gt, xe, id) {
-			xe_gt_reset_async(__gt);
-			flush_work(&__gt->reset.worker);
+			xe_gt_reset_sync(__gt);
 		}
 		if (err) {
 			KUNIT_FAIL(test, "restore kernel err=%pe\n",
diff --git a/drivers/gpu/drm/xe/tests/xe_mocs.c b/drivers/gpu/drm/xe/tests/xe_mocs.c
index 6f9b7a266b41..9de0e27b5a32 100644
--- a/drivers/gpu/drm/xe/tests/xe_mocs.c
+++ b/drivers/gpu/drm/xe/tests/xe_mocs.c
@@ -162,8 +162,7 @@ static int mocs_reset_test_run_device(struct xe_device *xe)
 		if (flags & HAS_LNCF_MOCS)
 			read_l3cc_table(gt, &mocs.table);
 
-		xe_gt_reset_async(gt);
-		flush_work(&gt->reset.worker);
+		xe_gt_reset_sync(gt);
 
 		kunit_info(test, "mocs_reset_test after reset\n");
 		if (flags & HAS_GLOBAL_MOCS)
diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
index d6744be01a68..72030cc9f030 100644
--- a/drivers/gpu/drm/xe/xe_gt.c
+++ b/drivers/gpu/drm/xe/xe_gt.c
@@ -848,6 +848,12 @@ void xe_gt_reset_async(struct xe_gt *gt)
 	queue_work(gt->ordered_wq, &gt->reset.worker);
 }
 
+void xe_gt_reset_sync(struct xe_gt *gt)
+{
+	xe_gt_reset_async(gt);
+	flush_work(&gt->reset.worker);
+}
+
 void xe_gt_suspend_prepare(struct xe_gt *gt)
 {
 	unsigned int fw_ref;
diff --git a/drivers/gpu/drm/xe/xe_gt.h b/drivers/gpu/drm/xe/xe_gt.h
index 82b9b7f82fca..aafc1b0057d9 100644
--- a/drivers/gpu/drm/xe/xe_gt.h
+++ b/drivers/gpu/drm/xe/xe_gt.h
@@ -52,6 +52,7 @@ int xe_gt_suspend(struct xe_gt *gt);
 void xe_gt_shutdown(struct xe_gt *gt);
 int xe_gt_resume(struct xe_gt *gt);
 void xe_gt_reset_async(struct xe_gt *gt);
+void xe_gt_reset_sync(struct xe_gt *gt);
 void xe_gt_sanitize(struct xe_gt *gt);
 int xe_gt_sanitize_freq(struct xe_gt *gt);
 void xe_gt_remove(struct xe_gt *gt);
-- 
2.34.1



More information about the Intel-xe mailing list