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