xref: /openbmc/linux/drivers/gpu/drm/i915/gt/intel_reset.h (revision cbdf59ad)
1 /*
2  * SPDX-License-Identifier: MIT
3  *
4  * Copyright © 2008-2018 Intel Corporation
5  */
6 
7 #ifndef I915_RESET_H
8 #define I915_RESET_H
9 
10 #include <linux/compiler.h>
11 #include <linux/types.h>
12 #include <linux/srcu.h>
13 
14 #include "gt/intel_engine_types.h"
15 
16 struct drm_i915_private;
17 struct i915_request;
18 struct intel_engine_cs;
19 struct intel_guc;
20 
21 __printf(4, 5)
22 void i915_handle_error(struct drm_i915_private *i915,
23 		       intel_engine_mask_t engine_mask,
24 		       unsigned long flags,
25 		       const char *fmt, ...);
26 #define I915_ERROR_CAPTURE BIT(0)
27 
28 void i915_check_and_clear_faults(struct drm_i915_private *i915);
29 
30 void i915_reset(struct drm_i915_private *i915,
31 		intel_engine_mask_t stalled_mask,
32 		const char *reason);
33 int i915_reset_engine(struct intel_engine_cs *engine,
34 		      const char *reason);
35 
36 void i915_reset_request(struct i915_request *rq, bool guilty);
37 
38 int __must_check i915_reset_trylock(struct drm_i915_private *i915);
39 void i915_reset_unlock(struct drm_i915_private *i915, int tag);
40 
41 int i915_terminally_wedged(struct drm_i915_private *i915);
42 
43 bool intel_has_gpu_reset(struct drm_i915_private *i915);
44 bool intel_has_reset_engine(struct drm_i915_private *i915);
45 
46 int intel_gpu_reset(struct drm_i915_private *i915,
47 		    intel_engine_mask_t engine_mask);
48 
49 int intel_reset_guc(struct drm_i915_private *i915);
50 
51 struct i915_wedge_me {
52 	struct delayed_work work;
53 	struct drm_i915_private *i915;
54 	const char *name;
55 };
56 
57 void __i915_init_wedge(struct i915_wedge_me *w,
58 		       struct drm_i915_private *i915,
59 		       long timeout,
60 		       const char *name);
61 void __i915_fini_wedge(struct i915_wedge_me *w);
62 
63 #define i915_wedge_on_timeout(W, DEV, TIMEOUT)				\
64 	for (__i915_init_wedge((W), (DEV), (TIMEOUT), __func__);	\
65 	     (W)->i915;							\
66 	     __i915_fini_wedge((W)))
67 
68 #endif /* I915_RESET_H */
69