1 /* 2 * SPDX-License-Identifier: MIT 3 * 4 * Copyright © 2018 Intel Corporation 5 */ 6 7 #include "igt_reset.h" 8 9 #include "gt/intel_engine.h" 10 11 #include "../i915_drv.h" 12 13 void igt_global_reset_lock(struct drm_i915_private *i915) 14 { 15 struct intel_engine_cs *engine; 16 enum intel_engine_id id; 17 18 pr_debug("%s: current gpu_error=%08lx\n", 19 __func__, i915->gpu_error.flags); 20 21 while (test_and_set_bit(I915_RESET_BACKOFF, &i915->gpu_error.flags)) 22 wait_event(i915->gpu_error.reset_queue, 23 !test_bit(I915_RESET_BACKOFF, 24 &i915->gpu_error.flags)); 25 26 for_each_engine(engine, i915, id) { 27 while (test_and_set_bit(I915_RESET_ENGINE + id, 28 &i915->gpu_error.flags)) 29 wait_on_bit(&i915->gpu_error.flags, 30 I915_RESET_ENGINE + id, 31 TASK_UNINTERRUPTIBLE); 32 } 33 } 34 35 void igt_global_reset_unlock(struct drm_i915_private *i915) 36 { 37 struct intel_engine_cs *engine; 38 enum intel_engine_id id; 39 40 for_each_engine(engine, i915, id) 41 clear_bit(I915_RESET_ENGINE + id, &i915->gpu_error.flags); 42 43 clear_bit(I915_RESET_BACKOFF, &i915->gpu_error.flags); 44 wake_up_all(&i915->gpu_error.reset_queue); 45 } 46 47 bool igt_force_reset(struct drm_i915_private *i915) 48 { 49 i915_gem_set_wedged(i915); 50 i915_reset(i915, 0, NULL); 51 52 return !i915_reset_failed(i915); 53 } 54