[PATCH] drm/xe: Add xe mocs suspend resume kunit
Janga Rahul Kumar
janga.rahul.kumar at intel.com
Thu Jan 25 11:16:37 UTC 2024
This kunit verifies the mocs register content with
the KMD programmed values before and after suspend resume.
Add helper function to check mocs values and use it.
Cc: Matt Roper <matthew.d.roper at intel.com>
Cc: Badal Nilawar <badal.nilawar at intel.com>
Signed-off-by: Janga Rahul Kumar <janga.rahul.kumar at intel.com>
---
drivers/gpu/drm/xe/tests/xe_mocs.c | 53 +++++++++++++++++++------
drivers/gpu/drm/xe/tests/xe_mocs_test.c | 1 +
drivers/gpu/drm/xe/tests/xe_mocs_test.h | 1 +
3 files changed, 43 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/xe/tests/xe_mocs.c b/drivers/gpu/drm/xe/tests/xe_mocs.c
index df5c36b70ab4..a36f804e5ce0 100644
--- a/drivers/gpu/drm/xe/tests/xe_mocs.c
+++ b/drivers/gpu/drm/xe/tests/xe_mocs.c
@@ -103,6 +103,14 @@ static void read_mocs_table(struct xe_gt *gt,
xe_device_mem_access_put(gt_to_xe(gt));
}
+static void check_mocs_table(struct xe_gt *gt, struct live_mocs *mocs, unsigned int flags)
+{
+ if (flags & HAS_GLOBAL_MOCS)
+ read_mocs_table(gt, &(mocs->table));
+ if (flags & HAS_LNCF_MOCS)
+ read_l3cc_table(gt, &(mocs->table));
+}
+
static int mocs_kernel_test_run_device(struct xe_device *xe)
{
/* Basic check the system is configured with the expected mocs table */
@@ -115,10 +123,7 @@ static int mocs_kernel_test_run_device(struct xe_device *xe)
for_each_gt(gt, xe, id) {
flags = live_mocs_init(&mocs, gt);
- if (flags & HAS_GLOBAL_MOCS)
- read_mocs_table(gt, &mocs.table);
- if (flags & HAS_LNCF_MOCS)
- read_l3cc_table(gt, &mocs.table);
+ check_mocs_table(gt, &mocs, flags);
}
return 0;
}
@@ -142,19 +147,13 @@ static int mocs_reset_test_run_device(struct xe_device *xe)
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);
+ check_mocs_table(gt, &mocs, flags);
xe_gt_reset_async(gt);
flush_work(>->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);
+ check_mocs_table(gt, &mocs, flags);
}
return 0;
}
@@ -164,3 +163,33 @@ 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);
+
+static int mocs_suspend_resume_test_run_device(struct xe_device *xe)
+{
+ /* Check the mocs setup is retained over suspend resume */
+
+ 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_suspend_resume_test before suspend resume\n");
+ check_mocs_table(gt, &mocs, flags);
+
+ xe_gt_suspend(gt);
+ xe_gt_resume(gt);
+
+ kunit_info(test, "mocs_suspend_resume_test after suspend resume\n");
+ check_mocs_table(gt, &mocs, flags);
+ }
+ return 0;
+}
+
+void xe_live_mocs_suspend_resume_kunit(struct kunit *test)
+{
+ xe_call_for_each_device(mocs_suspend_resume_test_run_device);
+}
+EXPORT_SYMBOL_IF_KUNIT(xe_live_mocs_suspend_resume_kunit);
diff --git a/drivers/gpu/drm/xe/tests/xe_mocs_test.c b/drivers/gpu/drm/xe/tests/xe_mocs_test.c
index 4f62e7a4270b..0d813472cdd3 100644
--- a/drivers/gpu/drm/xe/tests/xe_mocs_test.c
+++ b/drivers/gpu/drm/xe/tests/xe_mocs_test.c
@@ -10,6 +10,7 @@
static struct kunit_case xe_mocs_tests[] = {
KUNIT_CASE(xe_live_mocs_kernel_kunit),
KUNIT_CASE(xe_live_mocs_reset_kunit),
+ KUNIT_CASE(xe_live_mocs_suspend_resume_kunit),
{}
};
diff --git a/drivers/gpu/drm/xe/tests/xe_mocs_test.h b/drivers/gpu/drm/xe/tests/xe_mocs_test.h
index e7699d495411..117164cc0df7 100644
--- a/drivers/gpu/drm/xe/tests/xe_mocs_test.h
+++ b/drivers/gpu/drm/xe/tests/xe_mocs_test.h
@@ -10,5 +10,6 @@ struct kunit;
void xe_live_mocs_kernel_kunit(struct kunit *test);
void xe_live_mocs_reset_kunit(struct kunit *test);
+void xe_live_mocs_suspend_resume_kunit(struct kunit *test);
#endif
--
2.25.1
More information about the Intel-xe
mailing list