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