2 * SPDX-License-Identifier: MIT
4 * Copyright © 2018 Intel Corporation
9 #include "gt/intel_engine.h"
10 #include "gt/intel_gt.h"
12 #include "../i915_drv.h"
14 void igt_global_reset_lock(struct intel_gt
*gt
)
16 struct intel_engine_cs
*engine
;
17 enum intel_engine_id id
;
19 pr_debug("%s: current gpu_error=%08lx\n", __func__
, gt
->reset
.flags
);
21 while (test_and_set_bit(I915_RESET_BACKOFF
, >
->reset
.flags
))
22 wait_event(gt
->reset
.queue
,
23 !test_bit(I915_RESET_BACKOFF
, >
->reset
.flags
));
25 for_each_engine(engine
, gt
, id
) {
26 while (test_and_set_bit(I915_RESET_ENGINE
+ id
,
28 wait_on_bit(>
->reset
.flags
, I915_RESET_ENGINE
+ id
,
29 TASK_UNINTERRUPTIBLE
);
33 void igt_global_reset_unlock(struct intel_gt
*gt
)
35 struct intel_engine_cs
*engine
;
36 enum intel_engine_id id
;
38 for_each_engine(engine
, gt
, id
)
39 clear_bit(I915_RESET_ENGINE
+ id
, >
->reset
.flags
);
41 clear_bit(I915_RESET_BACKOFF
, >
->reset
.flags
);
42 wake_up_all(>
->reset
.queue
);
45 bool igt_force_reset(struct intel_gt
*gt
)
47 intel_gt_set_wedged(gt
);
48 intel_gt_reset(gt
, 0, NULL
);
50 return !intel_gt_is_wedged(gt
);