drm/xe: Add mocs reset kunit
authorRuthuvikas Ravikumar <ruthuvikas.ravikumar@intel.com>
Fri, 22 Dec 2023 19:23:52 +0000 (00:53 +0530)
committerMatt Roper <matthew.d.roper@intel.com>
Fri, 5 Jan 2024 16:46:09 +0000 (08:46 -0800)
This kunit verifies the mocs registers content
with the KMD programmed values before and after
GT reset.

v2: Remove extra blank lines between the local variables
definitions (Matt Roper)

Cc: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Ruthuvikas Ravikumar <ruthuvikas.ravikumar@intel.com>
Signed-off-by: Janga Rahul Kumar <janga.rahul.kumar@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://lore.kernel.org/r/20231222192352.927101-1-janga.rahul.kumar@intel.com
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
drivers/gpu/drm/xe/tests/xe_mocs.c
drivers/gpu/drm/xe/tests/xe_mocs_test.c
drivers/gpu/drm/xe/tests/xe_mocs_test.h

index 7dd34f94e8094c65c71b32cac3edd706824438ff..df5c36b70ab45be1b01b6179e4786b00bec258f4 100644 (file)
@@ -128,3 +128,39 @@ void xe_live_mocs_kernel_kunit(struct kunit *test)
        xe_call_for_each_device(mocs_kernel_test_run_device);
 }
 EXPORT_SYMBOL_IF_KUNIT(xe_live_mocs_kernel_kunit);
+
+static int mocs_reset_test_run_device(struct xe_device *xe)
+{
+       /* Check the mocs setup is retained over GT reset */
+
+       struct live_mocs mocs;
+       struct xe_gt *gt;
+       unsigned int flags;
+       int id;
+       struct kunit *test = xe_cur_kunit();
+
+       for_each_gt(gt, xe, id) {
+               flags = live_mocs_init(&mocs, gt);
+               kunit_info(test, "mocs_reset_test before reset\n");
+               if (flags & HAS_GLOBAL_MOCS)
+                       read_mocs_table(gt, &mocs.table);
+               if (flags & HAS_LNCF_MOCS)
+                       read_l3cc_table(gt, &mocs.table);
+
+               xe_gt_reset_async(gt);
+               flush_work(&gt->reset.worker);
+
+               kunit_info(test, "mocs_reset_test after reset\n");
+               if (flags & HAS_GLOBAL_MOCS)
+                       read_mocs_table(gt, &mocs.table);
+               if (flags & HAS_LNCF_MOCS)
+                       read_l3cc_table(gt, &mocs.table);
+       }
+       return 0;
+}
+
+void xe_live_mocs_reset_kunit(struct kunit *test)
+{
+       xe_call_for_each_device(mocs_reset_test_run_device);
+}
+EXPORT_SYMBOL_IF_KUNIT(xe_live_mocs_reset_kunit);
index ef56bd517b28c2604b1ed8c5f494a839217d25da..4f62e7a4270bdbf68866a9c632498c5c2c176b19 100644 (file)
@@ -9,6 +9,7 @@
 
 static struct kunit_case xe_mocs_tests[] = {
        KUNIT_CASE(xe_live_mocs_kernel_kunit),
+       KUNIT_CASE(xe_live_mocs_reset_kunit),
        {}
 };
 
index 7faa3575e6c3a91f45d6755fb8545a919f3c580d..e7699d4954115a3675d04ede3894adc6017e7f09 100644 (file)
@@ -9,5 +9,6 @@
 struct kunit;
 
 void xe_live_mocs_kernel_kunit(struct kunit *test);
+void xe_live_mocs_reset_kunit(struct kunit *test);
 
 #endif