]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/i915/selftests: Move some reset testcases to separate file
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Wed, 22 May 2019 19:31:55 +0000 (19:31 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Thu, 23 May 2019 20:52:26 +0000 (21:52 +0100)
igt_global_reset and igt_wedged_reset testcases are first candidates.

Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20190522193203.23932-2-michal.wajdeczko@intel.com
drivers/gpu/drm/i915/gt/intel_reset.c
drivers/gpu/drm/i915/gt/selftest_hangcheck.c
drivers/gpu/drm/i915/gt/selftest_reset.c [new file with mode: 0644]
drivers/gpu/drm/i915/selftests/i915_live_selftests.h

index 464369bc55ad664e5b7f3af07989e074a78eb56f..8c60f7550f9cb480b966f4b316c4d2c2970039cc 100644 (file)
@@ -1394,3 +1394,7 @@ void __i915_fini_wedge(struct i915_wedge_me *w)
        destroy_delayed_work_on_stack(&w->work);
        w->i915 = NULL;
 }
+
+#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
+#include "selftest_reset.c"
+#endif
index dab3d30c9c735cab01dfd1187e6fc61ac8e7b5d0..a6e7f84bbbe9c23efd653b56432921c506f69462 100644 (file)
@@ -365,54 +365,6 @@ static int igt_hang_sanitycheck(void *arg)
        return err;
 }
 
-static int igt_global_reset(void *arg)
-{
-       struct drm_i915_private *i915 = arg;
-       unsigned int reset_count;
-       int err = 0;
-
-       /* Check that we can issue a global GPU reset */
-
-       igt_global_reset_lock(i915);
-
-       reset_count = i915_reset_count(&i915->gpu_error);
-
-       i915_reset(i915, ALL_ENGINES, NULL);
-
-       if (i915_reset_count(&i915->gpu_error) == reset_count) {
-               pr_err("No GPU reset recorded!\n");
-               err = -EINVAL;
-       }
-
-       igt_global_reset_unlock(i915);
-
-       if (i915_reset_failed(i915))
-               err = -EIO;
-
-       return err;
-}
-
-static int igt_wedged_reset(void *arg)
-{
-       struct drm_i915_private *i915 = arg;
-       intel_wakeref_t wakeref;
-
-       /* Check that we can recover a wedged device with a GPU reset */
-
-       igt_global_reset_lock(i915);
-       wakeref = intel_runtime_pm_get(i915);
-
-       i915_gem_set_wedged(i915);
-
-       GEM_BUG_ON(!i915_reset_failed(i915));
-       i915_reset(i915, ALL_ENGINES, NULL);
-
-       intel_runtime_pm_put(i915, wakeref);
-       igt_global_reset_unlock(i915);
-
-       return i915_reset_failed(i915) ? -EIO : 0;
-}
-
 static bool wait_for_idle(struct intel_engine_cs *engine)
 {
        return wait_for(intel_engine_is_idle(engine), IGT_IDLE_TIMEOUT) == 0;
@@ -1846,8 +1798,6 @@ static int igt_atomic_reset(void *arg)
 int intel_hangcheck_live_selftests(struct drm_i915_private *i915)
 {
        static const struct i915_subtest tests[] = {
-               SUBTEST(igt_global_reset), /* attempt to recover GPU first */
-               SUBTEST(igt_wedged_reset),
                SUBTEST(igt_hang_sanitycheck),
                SUBTEST(igt_reset_nop),
                SUBTEST(igt_reset_nop_engine),
diff --git a/drivers/gpu/drm/i915/gt/selftest_reset.c b/drivers/gpu/drm/i915/gt/selftest_reset.c
new file mode 100644 (file)
index 0000000..ef90101
--- /dev/null
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2018 Intel Corporation
+ */
+
+#include "i915_selftest.h"
+#include "selftests/igt_reset.h"
+
+static int igt_global_reset(void *arg)
+{
+       struct drm_i915_private *i915 = arg;
+       unsigned int reset_count;
+       int err = 0;
+
+       /* Check that we can issue a global GPU reset */
+
+       igt_global_reset_lock(i915);
+
+       reset_count = i915_reset_count(&i915->gpu_error);
+
+       i915_reset(i915, ALL_ENGINES, NULL);
+
+       if (i915_reset_count(&i915->gpu_error) == reset_count) {
+               pr_err("No GPU reset recorded!\n");
+               err = -EINVAL;
+       }
+
+       igt_global_reset_unlock(i915);
+
+       if (i915_reset_failed(i915))
+               err = -EIO;
+
+       return err;
+}
+
+static int igt_wedged_reset(void *arg)
+{
+       struct drm_i915_private *i915 = arg;
+       intel_wakeref_t wakeref;
+
+       /* Check that we can recover a wedged device with a GPU reset */
+
+       igt_global_reset_lock(i915);
+       wakeref = intel_runtime_pm_get(i915);
+
+       i915_gem_set_wedged(i915);
+
+       GEM_BUG_ON(!i915_reset_failed(i915));
+       i915_reset(i915, ALL_ENGINES, NULL);
+
+       intel_runtime_pm_put(i915, wakeref);
+       igt_global_reset_unlock(i915);
+
+       return i915_reset_failed(i915) ? -EIO : 0;
+}
+
+int intel_reset_live_selftests(struct drm_i915_private *i915)
+{
+       static const struct i915_subtest tests[] = {
+               SUBTEST(igt_global_reset), /* attempt to recover GPU first */
+               SUBTEST(igt_wedged_reset),
+       };
+       intel_wakeref_t wakeref;
+       int err = 0;
+
+       if (!intel_has_gpu_reset(i915))
+               return 0;
+
+       if (i915_terminally_wedged(i915))
+               return -EIO; /* we're long past hope of a successful reset */
+
+       with_intel_runtime_pm(i915, wakeref)
+               err = i915_subtests(tests, i915);
+
+       return err;
+}
index a54f590788a406e8baf6c5745f6b36ef9e724bb8..a953125b14c443d2f377ebc7cb940893bbb3f457 100644 (file)
@@ -24,6 +24,7 @@ selftest(gem, i915_gem_live_selftests)
 selftest(evict, i915_gem_evict_live_selftests)
 selftest(hugepages, i915_gem_huge_page_live_selftests)
 selftest(contexts, i915_gem_context_live_selftests)
+selftest(reset, intel_reset_live_selftests)
 selftest(hangcheck, intel_hangcheck_live_selftests)
 selftest(execlists, intel_execlists_live_selftests)
 selftest(guc, intel_guc_live_selftest)