diff mbox series

[2/2] drm/i915/selftests: Fix live_workarounds to actually do resets

Message ID 20181130080254.15383-2-tvrtko.ursulin@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [1/2] drm/i915/selftests: Extract spinner code | expand

Commit Message

Tvrtko Ursulin Nov. 30, 2018, 8:02 a.m. UTC
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

The test was missing some magic ingredients to actually trigger the
resets.

In case of the full reset we need the I915_RESET_HANDOFF flag set, and in
case of engine reset we need a busy request.

Thanks to Chris for helping with reset magic.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 .../drm/i915/selftests/intel_workarounds.c    | 58 +++++++++++++++----
 1 file changed, 48 insertions(+), 10 deletions(-)

Comments

Chris Wilson Nov. 30, 2018, 9:53 a.m. UTC | #1
Quoting Tvrtko Ursulin (2018-11-30 08:02:54)
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> The test was missing some magic ingredients to actually trigger the
> resets.
> 
> In case of the full reset we need the I915_RESET_HANDOFF flag set, and in
> case of engine reset we need a busy request.
> 
> Thanks to Chris for helping with reset magic.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>

Thanks for fixing up my fail,
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
Tvrtko Ursulin Nov. 30, 2018, 12:17 p.m. UTC | #2
On 30/11/2018 09:53, Chris Wilson wrote:
> Quoting Tvrtko Ursulin (2018-11-30 08:02:54)
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> The test was missing some magic ingredients to actually trigger the
>> resets.
>>
>> In case of the full reset we need the I915_RESET_HANDOFF flag set, and in
>> case of engine reset we need a busy request.
>>
>> Thanks to Chris for helping with reset magic.
>>
>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> 
> Thanks for fixing up my fail,
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Thanks, happy with v2 as well? (adds rpm over reset)

Regards,

Tvrtko
Chris Wilson Nov. 30, 2018, 12:55 p.m. UTC | #3
Quoting Tvrtko Ursulin (2018-11-30 12:17:13)
> 
> On 30/11/2018 09:53, Chris Wilson wrote:
> > Quoting Tvrtko Ursulin (2018-11-30 08:02:54)
> >> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> >>
> >> The test was missing some magic ingredients to actually trigger the
> >> resets.
> >>
> >> In case of the full reset we need the I915_RESET_HANDOFF flag set, and in
> >> case of engine reset we need a busy request.
> >>
> >> Thanks to Chris for helping with reset magic.
> >>
> >> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> >> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > 
> > Thanks for fixing up my fail,
> > Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
> 
> Thanks, happy with v2 as well? (adds rpm over reset)

Yup, was trying to save electrons :)
-Chris
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/selftests/intel_workarounds.c b/drivers/gpu/drm/i915/selftests/intel_workarounds.c
index d1a0923d2f38..8e49c005d4db 100644
--- a/drivers/gpu/drm/i915/selftests/intel_workarounds.c
+++ b/drivers/gpu/drm/i915/selftests/intel_workarounds.c
@@ -6,6 +6,7 @@ 
 
 #include "../i915_selftest.h"
 
+#include "igt_spinner.h"
 #include "igt_wedge_me.h"
 #include "mock_context.h"
 
@@ -159,35 +160,57 @@  static int check_whitelist(const struct whitelist *w,
 
 static int do_device_reset(struct intel_engine_cs *engine)
 {
-	i915_reset(engine->i915, ENGINE_MASK(engine->id), NULL);
+	set_bit(I915_RESET_HANDOFF, &engine->i915->gpu_error.flags);
+	i915_reset(engine->i915, ENGINE_MASK(engine->id), "live_workarounds");
 	return 0;
 }
 
 static int do_engine_reset(struct intel_engine_cs *engine)
 {
-	return i915_reset_engine(engine, NULL);
+	return i915_reset_engine(engine, "live_workarounds");
 }
 
-static int switch_to_scratch_context(struct intel_engine_cs *engine)
+static int
+switch_to_scratch_context(struct intel_engine_cs *engine,
+			  struct igt_spinner *spin)
 {
 	struct i915_gem_context *ctx;
 	struct i915_request *rq;
+	int err = 0;
 
 	ctx = kernel_context(engine->i915);
 	if (IS_ERR(ctx))
 		return PTR_ERR(ctx);
 
 	intel_runtime_pm_get(engine->i915);
-	rq = i915_request_alloc(engine, ctx);
+
+	if (spin)
+		rq = igt_spinner_create_request(spin, ctx, engine, MI_NOOP);
+	else
+		rq = i915_request_alloc(engine, ctx);
+
 	intel_runtime_pm_put(engine->i915);
 
 	kernel_context_close(ctx);
-	if (IS_ERR(rq))
-		return PTR_ERR(rq);
+
+	if (IS_ERR(rq)) {
+		spin = NULL;
+		err = PTR_ERR(rq);
+		goto err;
+	}
 
 	i915_request_add(rq);
 
-	return 0;
+	if (spin && !igt_wait_for_spinner(spin, rq)) {
+		pr_err("Spinner failed to start\n");
+		err = -ETIMEDOUT;
+	}
+
+err:
+	if (err && spin)
+		igt_spinner_end(spin);
+
+	return err;
 }
 
 static int check_whitelist_across_reset(struct intel_engine_cs *engine,
@@ -195,9 +218,20 @@  static int check_whitelist_across_reset(struct intel_engine_cs *engine,
 					const struct whitelist *w,
 					const char *name)
 {
+	bool want_spin = reset == do_engine_reset;
 	struct i915_gem_context *ctx;
+	struct igt_spinner spin;
 	int err;
 
+	pr_info("Checking %d whitelisted registers (RING_NONPRIV) [%s]\n",
+		w->count, name);
+
+	if (want_spin) {
+		err = igt_spinner_init(&spin, engine->i915);
+		if (err)
+			return err;
+	}
+
 	ctx = kernel_context(engine->i915);
 	if (IS_ERR(ctx))
 		return PTR_ERR(ctx);
@@ -208,11 +242,17 @@  static int check_whitelist_across_reset(struct intel_engine_cs *engine,
 		goto out;
 	}
 
-	err = switch_to_scratch_context(engine);
+	err = switch_to_scratch_context(engine, want_spin ? &spin : NULL);
 	if (err)
 		goto out;
 
 	err = reset(engine);
+
+	if (want_spin) {
+		igt_spinner_end(&spin);
+		igt_spinner_fini(&spin);
+	}
+
 	if (err) {
 		pr_err("%s reset failed\n", name);
 		goto out;
@@ -259,8 +299,6 @@  static int live_reset_whitelist(void *arg)
 	if (!whitelist_build(engine, &w))
 		return 0;
 
-	pr_info("Checking %d whitelisted registers (RING_NONPRIV)\n", w.count);
-
 	set_bit(I915_RESET_BACKOFF, &error->flags);
 	set_bit(I915_RESET_ENGINE + engine->id, &error->flags);