GNU Linux-libre 4.19.245-gnu1
[releases.git] / drivers / gpu / drm / i915 / selftests / igt_flush_test.c
1 /*
2  * SPDX-License-Identifier: MIT
3  *
4  * Copyright © 2018 Intel Corporation
5  */
6
7 #include "../i915_drv.h"
8
9 #include "../i915_selftest.h"
10 #include "igt_flush_test.h"
11
12 int igt_flush_test(struct drm_i915_private *i915, unsigned int flags)
13 {
14         cond_resched();
15
16         if (flags & I915_WAIT_LOCKED &&
17             i915_gem_switch_to_kernel_context(i915)) {
18                 pr_err("Failed to switch back to kernel context; declaring wedged\n");
19                 i915_gem_set_wedged(i915);
20         }
21
22         if (i915_gem_wait_for_idle(i915, flags, HZ / 5) == -ETIME) {
23                 pr_err("%pS timed out, cancelling all further testing.\n",
24                        __builtin_return_address(0));
25
26                 GEM_TRACE("%pS timed out.\n", __builtin_return_address(0));
27                 GEM_TRACE_DUMP();
28
29                 i915_gem_set_wedged(i915);
30         }
31
32         return i915_terminally_wedged(&i915->gpu_error) ? -EIO : 0;
33 }