1 /* $NetBSD: intel_reset.h,v 1.2 2021/12/18 23:45:30 riastradh Exp $ */
2
3 /*
4 * SPDX-License-Identifier: MIT
5 *
6 * Copyright © 2008-2018 Intel Corporation
7 */
8
9 #ifndef I915_RESET_H
10 #define I915_RESET_H
11
12 #include <linux/compiler.h>
13 #include <linux/types.h>
14 #include <linux/srcu.h>
15
16 #include "intel_engine_types.h"
17 #include "intel_reset_types.h"
18
19 struct i915_request;
20 struct intel_engine_cs;
21 struct intel_gt;
22 struct intel_guc;
23
24 void intel_gt_init_reset(struct intel_gt *gt);
25 void intel_gt_fini_reset(struct intel_gt *gt);
26
27 __printf(4, 5)
28 void intel_gt_handle_error(struct intel_gt *gt,
29 intel_engine_mask_t engine_mask,
30 unsigned long flags,
31 const char *fmt, ...);
32 #define I915_ERROR_CAPTURE BIT(0)
33
34 void intel_gt_reset(struct intel_gt *gt,
35 intel_engine_mask_t stalled_mask,
36 const char *reason);
37 int intel_engine_reset(struct intel_engine_cs *engine,
38 const char *reason);
39
40 void __i915_request_reset(struct i915_request *rq, bool guilty);
41
42 int __must_check intel_gt_reset_trylock(struct intel_gt *gt, int *srcu);
43 void intel_gt_reset_unlock(struct intel_gt *gt, int tag);
44
45 void intel_gt_set_wedged(struct intel_gt *gt);
46 bool intel_gt_unset_wedged(struct intel_gt *gt);
47 int intel_gt_terminally_wedged(struct intel_gt *gt);
48
49 /*
50 * There's no unset_wedged_on_init paired with this one.
51 * Once we're wedged on init, there's no going back.
52 */
53 void intel_gt_set_wedged_on_init(struct intel_gt *gt);
54
55 int __intel_gt_reset(struct intel_gt *gt, intel_engine_mask_t engine_mask);
56
57 int intel_reset_guc(struct intel_gt *gt);
58
59 struct intel_wedge_me {
60 struct delayed_work work;
61 struct intel_gt *gt;
62 const char *name;
63 };
64
65 void __intel_init_wedge(struct intel_wedge_me *w,
66 struct intel_gt *gt,
67 long timeout,
68 const char *name);
69 void __intel_fini_wedge(struct intel_wedge_me *w);
70
71 #define intel_wedge_on_timeout(W, GT, TIMEOUT) \
72 for (__intel_init_wedge((W), (GT), (TIMEOUT), __func__); \
73 (W)->gt; \
74 __intel_fini_wedge((W)))
75
__intel_reset_failed(const struct intel_reset * reset)76 static inline bool __intel_reset_failed(const struct intel_reset *reset)
77 {
78 GEM_BUG_ON(test_bit(I915_WEDGED_ON_INIT, &reset->flags) ?
79 !test_bit(I915_WEDGED, &reset->flags) : false);
80
81 return unlikely(test_bit(I915_WEDGED, &reset->flags));
82 }
83
84 bool intel_has_gpu_reset(const struct intel_gt *gt);
85 bool intel_has_reset_engine(const struct intel_gt *gt);
86
87 #endif /* I915_RESET_H */
88