From: Andi Shyti <andi.sh...@intel.com>

live_rc6_basic simply checks if rc6 works when it's enabled
or stops when it's disabled.

The test is added as subtest of the bigger live_late_gt_pm
selftest.

Signed-off-by: Andi Shyti <andi.sh...@intel.com>
Cc: Chris Wilson <ch...@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gt/selftest_gt_pm.c |  1 +
 drivers/gpu/drm/i915/gt/selftest_rc6.c   | 37 ++++++++++++++++++++++++
 drivers/gpu/drm/i915/gt/selftest_rc6.h   |  1 +
 3 files changed, 39 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/selftest_gt_pm.c 
b/drivers/gpu/drm/i915/gt/selftest_gt_pm.c
index d39a21a047de..2bbdc9235b45 100644
--- a/drivers/gpu/drm/i915/gt/selftest_gt_pm.c
+++ b/drivers/gpu/drm/i915/gt/selftest_gt_pm.c
@@ -51,6 +51,7 @@ static int live_gt_resume(void *arg)
 int intel_gt_pm_live_selftests(struct drm_i915_private *i915)
 {
        static const struct i915_subtest tests[] = {
+               SUBTEST(live_rc6_basic),
                SUBTEST(live_rc6_busy),
                SUBTEST(live_rc6_manual),
                SUBTEST(live_rc6_threshold),
diff --git a/drivers/gpu/drm/i915/gt/selftest_rc6.c 
b/drivers/gpu/drm/i915/gt/selftest_rc6.c
index 7b5d476a8ad1..9e84b860b70a 100644
--- a/drivers/gpu/drm/i915/gt/selftest_rc6.c
+++ b/drivers/gpu/drm/i915/gt/selftest_rc6.c
@@ -250,6 +250,43 @@ static bool is_rc6_active(struct intel_rc6 *rc6)
        return !!measure_rc6(uncore, 2 * interval);
 }
 
+int live_rc6_basic(void *arg)
+{
+       struct intel_gt *gt = arg;
+       struct intel_rc6 *rc6 = &gt->rc6;
+       intel_wakeref_t wakeref;
+       int i, err = 0;
+
+       if (!rc6->supported)
+               return 0;
+
+       wakeref = intel_runtime_pm_get(gt->uncore->rpm);
+
+       /*
+        * the two loops test rc6 both in case it's enabled
+        * and in the case it's disabled. It restores the prvious
+        * status
+        */
+       for (i = 0; i < 2; i++) {
+               if (rc6->enabled ^ is_rc6_active(rc6)) {
+                       err = -EINVAL;
+
+                       /* restore before leaving */
+                       if (!i)
+                               goto exit;
+               }
+
+               if (rc6->enabled)
+                       intel_rc6_disable(&gt->rc6);
+               else
+                       intel_rc6_enable(&gt->rc6);
+       }
+
+exit:
+       intel_runtime_pm_put(gt->uncore->rpm, wakeref);
+       return err;
+}
+
 int live_rc6_threshold(void *arg)
 {
        struct intel_gt *gt = arg;
diff --git a/drivers/gpu/drm/i915/gt/selftest_rc6.h 
b/drivers/gpu/drm/i915/gt/selftest_rc6.h
index 312894423dc2..38183f3558f3 100644
--- a/drivers/gpu/drm/i915/gt/selftest_rc6.h
+++ b/drivers/gpu/drm/i915/gt/selftest_rc6.h
@@ -7,6 +7,7 @@
 #ifndef SELFTEST_RC6_H
 #define SELFTEST_RC6_H
 
+int live_rc6_basic(void *arg);
 int live_rc6_busy(void *arg);
 int live_rc6_ctx_wa(void *arg);
 int live_rc6_manual(void *arg);
-- 
2.25.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to