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