1 /*
2  * SPDX-License-Identifier: MIT
3  *
4  * Copyright © 2018 Intel Corporation
5  */
6 
7 #include "gt/intel_gt.h"
8 #include "gt/intel_gt_requests.h"
9 
10 #include "i915_drv.h"
11 #include "i915_selftest.h"
12 
13 #include "igt_flush_test.h"
14 
igt_flush_test(struct drm_i915_private * i915)15 int igt_flush_test(struct drm_i915_private *i915)
16 {
17 	struct intel_gt *gt;
18 	unsigned int i;
19 	int ret = 0;
20 
21 	for_each_gt(gt, i915, i) {
22 		if (intel_gt_is_wedged(gt))
23 			ret = -EIO;
24 
25 		cond_resched();
26 
27 		if (intel_gt_wait_for_idle(gt, HZ * 3) == -ETIME) {
28 			pr_err("%pS timed out, cancelling all further testing.\n",
29 			       __builtin_return_address(0));
30 
31 			GEM_TRACE("%pS timed out.\n",
32 				  __builtin_return_address(0));
33 			GEM_TRACE_DUMP();
34 
35 			intel_gt_set_wedged(gt);
36 			ret = -EIO;
37 		}
38 	}
39 
40 	return ret;
41 }
42