Merge tag 'io_uring-5.11-2021-01-16' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / gpu / drm / i915 / selftests / igt_live_test.c
blobc130010a7033db06a2edd0d68801044fe6ba9870
1 /*
2 * SPDX-License-Identifier: MIT
4 * Copyright © 2018 Intel Corporation
5 */
7 #include "i915_drv.h"
8 #include "gt/intel_gt_requests.h"
10 #include "../i915_selftest.h"
11 #include "igt_flush_test.h"
12 #include "igt_live_test.h"
14 int igt_live_test_begin(struct igt_live_test *t,
15 struct drm_i915_private *i915,
16 const char *func,
17 const char *name)
19 struct intel_gt *gt = &i915->gt;
20 struct intel_engine_cs *engine;
21 enum intel_engine_id id;
22 int err;
24 t->i915 = i915;
25 t->func = func;
26 t->name = name;
28 err = intel_gt_wait_for_idle(gt, MAX_SCHEDULE_TIMEOUT);
29 if (err) {
30 pr_err("%s(%s): failed to idle before, with err=%d!",
31 func, name, err);
32 return err;
35 t->reset_global = i915_reset_count(&i915->gpu_error);
37 for_each_engine(engine, gt, id)
38 t->reset_engine[id] =
39 i915_reset_engine_count(&i915->gpu_error, engine);
41 return 0;
44 int igt_live_test_end(struct igt_live_test *t)
46 struct drm_i915_private *i915 = t->i915;
47 struct intel_engine_cs *engine;
48 enum intel_engine_id id;
50 if (igt_flush_test(i915))
51 return -EIO;
53 if (t->reset_global != i915_reset_count(&i915->gpu_error)) {
54 pr_err("%s(%s): GPU was reset %d times!\n",
55 t->func, t->name,
56 i915_reset_count(&i915->gpu_error) - t->reset_global);
57 return -EIO;
60 for_each_engine(engine, &i915->gt, id) {
61 if (t->reset_engine[id] ==
62 i915_reset_engine_count(&i915->gpu_error, engine))
63 continue;
65 pr_err("%s(%s): engine '%s' was reset %d times!\n",
66 t->func, t->name, engine->name,
67 i915_reset_engine_count(&i915->gpu_error, engine) -
68 t->reset_engine[id]);
69 return -EIO;
72 return 0;