]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe: introduce xe_gt_reset and xe_gt_wait_for_reset
authorMaciej Patelczyk <maciej.patelczyk@intel.com>
Wed, 11 Dec 2024 11:17:26 +0000 (12:17 +0100)
committerThomas Hellström <thomas.hellstrom@linux.intel.com>
Wed, 15 Jan 2025 10:32:50 +0000 (11:32 +0100)
Add synchronous version gt reset as there are few places where it
is expected.
Also add a wait helper to wait until gt reset is done.

Signed-off-by: Maciej Patelczyk <maciej.patelczyk@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Fixes: f3bc5bb4d53d ("drm/xe: Allow userspace to configure CCS mode")
Reviewed-by: Nirmoy Das <nirmoy.das@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241211111727.1481476-2-maciej.patelczyk@intel.com
Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
(cherry picked from commit 155c77f45f63dd58a37eeb0896b0b140ab785836)
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
drivers/gpu/drm/xe/tests/xe_bo.c
drivers/gpu/drm/xe/tests/xe_mocs.c
drivers/gpu/drm/xe/xe_gt.h
drivers/gpu/drm/xe/xe_gt_debugfs.c

index 3e0ae40ebbd283a9bf60fa0bdd4a7e3d95cc00c5..812046f5d7415bf829adaf2c5bc6f899ad0fcf5b 100644 (file)
@@ -257,10 +257,9 @@ static int evict_test_run_tile(struct xe_device *xe, struct xe_tile *tile, struc
                 * however seems quite fragile not to also restart the GT. Try
                 * 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);
-               }
+               for_each_gt(__gt, xe, id)
+                       xe_gt_reset(__gt);
+
                if (err) {
                        KUNIT_FAIL(test, "restore kernel err=%pe\n",
                                   ERR_PTR(err));
index 6f9b7a266b41955cd205d09b731b3f7a741df46e..2698e433c6fa15178fc850dc9222e85b1ed1bd1c 100644 (file)
@@ -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(gt);
 
                kunit_info(test, "mocs_reset_test after reset\n");
                if (flags & HAS_GLOBAL_MOCS)
index 82b9b7f82fcab17ff1440ee2e99a369c26b2f272..eb294696342048071e0d6547b2abad3496db88a2 100644 (file)
@@ -56,6 +56,31 @@ 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);
 
+/**
+ * xe_gt_wait_for_reset - wait for gt's async reset to finalize.
+ * @gt: GT structure
+ * Return:
+ * %true if it waited for the work to finish execution,
+ * %false if there was no scheduled reset or it was done.
+ */
+static inline bool xe_gt_wait_for_reset(struct xe_gt *gt)
+{
+       return flush_work(&gt->reset.worker);
+}
+
+/**
+ * xe_gt_reset - perform synchronous reset
+ * @gt: GT structure
+ * Return:
+ * %true if it waited for the reset to finish,
+ * %false if there was no scheduled reset.
+ */
+static inline bool xe_gt_reset(struct xe_gt *gt)
+{
+       xe_gt_reset_async(gt);
+       return xe_gt_wait_for_reset(gt);
+}
+
 /**
  * xe_gt_any_hw_engine_by_reset_domain - scan the list of engines and return the
  * first that matches the same reset domain as @class
index 3e8c351a0eab08d7ce93e1fcf1adc82dbdbda919..e7792858b1e46626bd35630414bc62a446be9210 100644 (file)
@@ -132,11 +132,9 @@ static int force_reset(struct xe_gt *gt, struct drm_printer *p)
 static int force_reset_sync(struct xe_gt *gt, struct drm_printer *p)
 {
        xe_pm_runtime_get(gt_to_xe(gt));
-       xe_gt_reset_async(gt);
+       xe_gt_reset(gt);
        xe_pm_runtime_put(gt_to_xe(gt));
 
-       flush_work(&gt->reset.worker);
-
        return 0;
 }