124f90d66SChris Wilson /* SPDX-License-Identifier: MIT */ 2112ed2d3SChris Wilson /* 3112ed2d3SChris Wilson * Copyright © 2008-2018 Intel Corporation 4112ed2d3SChris Wilson */ 5112ed2d3SChris Wilson 6112ed2d3SChris Wilson #ifndef I915_RESET_H 7112ed2d3SChris Wilson #define I915_RESET_H 8112ed2d3SChris Wilson 9112ed2d3SChris Wilson #include <linux/compiler.h> 10112ed2d3SChris Wilson #include <linux/types.h> 11112ed2d3SChris Wilson #include <linux/srcu.h> 12112ed2d3SChris Wilson 13cb823ed9SChris Wilson #include "intel_engine_types.h" 14cb823ed9SChris Wilson #include "intel_reset_types.h" 15112ed2d3SChris Wilson 16112ed2d3SChris Wilson struct i915_request; 17112ed2d3SChris Wilson struct intel_engine_cs; 18cb823ed9SChris Wilson struct intel_gt; 19112ed2d3SChris Wilson struct intel_guc; 20112ed2d3SChris Wilson 21cb823ed9SChris Wilson void intel_gt_init_reset(struct intel_gt *gt); 22cb823ed9SChris Wilson void intel_gt_fini_reset(struct intel_gt *gt); 23cb823ed9SChris Wilson 24112ed2d3SChris Wilson __printf(4, 5) 25cb823ed9SChris Wilson void intel_gt_handle_error(struct intel_gt *gt, 26112ed2d3SChris Wilson intel_engine_mask_t engine_mask, 27112ed2d3SChris Wilson unsigned long flags, 28112ed2d3SChris Wilson const char *fmt, ...); 29112ed2d3SChris Wilson #define I915_ERROR_CAPTURE BIT(0) 30112ed2d3SChris Wilson 31cb823ed9SChris Wilson void intel_gt_reset(struct intel_gt *gt, 32112ed2d3SChris Wilson intel_engine_mask_t stalled_mask, 33112ed2d3SChris Wilson const char *reason); 34cb823ed9SChris Wilson int intel_engine_reset(struct intel_engine_cs *engine, 35112ed2d3SChris Wilson const char *reason); 3616f2941aSChris Wilson int __intel_engine_reset_bh(struct intel_engine_cs *engine, 3716f2941aSChris Wilson const char *reason); 38112ed2d3SChris Wilson 39cb823ed9SChris Wilson void __i915_request_reset(struct i915_request *rq, bool guilty); 40112ed2d3SChris Wilson 41eebab60fSChris Wilson int __must_check intel_gt_reset_trylock(struct intel_gt *gt, int *srcu); 42178b8a36SJohn Harrison int __must_check intel_gt_reset_lock_interruptible(struct intel_gt *gt, int *srcu); 43cb823ed9SChris Wilson void intel_gt_reset_unlock(struct intel_gt *gt, int tag); 44112ed2d3SChris Wilson 45cb823ed9SChris Wilson void intel_gt_set_wedged(struct intel_gt *gt); 46cb823ed9SChris Wilson bool intel_gt_unset_wedged(struct intel_gt *gt); 47cb823ed9SChris Wilson int intel_gt_terminally_wedged(struct intel_gt *gt); 48112ed2d3SChris Wilson 495311f517SMichał Winiarski /* 505311f517SMichał Winiarski * There's no unset_wedged_on_init paired with this one. 515311f517SMichał Winiarski * Once we're wedged on init, there's no going back. 523f04bdceSMichał Winiarski * Same thing for unset_wedged_on_fini. 535311f517SMichał Winiarski */ 545311f517SMichał Winiarski void intel_gt_set_wedged_on_init(struct intel_gt *gt); 553f04bdceSMichał Winiarski void intel_gt_set_wedged_on_fini(struct intel_gt *gt); 565311f517SMichał Winiarski 57cb823ed9SChris Wilson int __intel_gt_reset(struct intel_gt *gt, intel_engine_mask_t engine_mask); 58112ed2d3SChris Wilson 59cb823ed9SChris Wilson int intel_reset_guc(struct intel_gt *gt); 60112ed2d3SChris Wilson 61cb823ed9SChris Wilson struct intel_wedge_me { 62112ed2d3SChris Wilson struct delayed_work work; 63cb823ed9SChris Wilson struct intel_gt *gt; 64112ed2d3SChris Wilson const char *name; 65112ed2d3SChris Wilson }; 66112ed2d3SChris Wilson 67cb823ed9SChris Wilson void __intel_init_wedge(struct intel_wedge_me *w, 68cb823ed9SChris Wilson struct intel_gt *gt, 69112ed2d3SChris Wilson long timeout, 70112ed2d3SChris Wilson const char *name); 71cb823ed9SChris Wilson void __intel_fini_wedge(struct intel_wedge_me *w); 72112ed2d3SChris Wilson 73cb823ed9SChris Wilson #define intel_wedge_on_timeout(W, GT, TIMEOUT) \ 74cb823ed9SChris Wilson for (__intel_init_wedge((W), (GT), (TIMEOUT), __func__); \ 75cb823ed9SChris Wilson (W)->gt; \ 76cb823ed9SChris Wilson __intel_fini_wedge((W))) 77cb823ed9SChris Wilson 78260e6b71SChris Wilson bool intel_has_gpu_reset(const struct intel_gt *gt); 79260e6b71SChris Wilson bool intel_has_reset_engine(const struct intel_gt *gt); 80112ed2d3SChris Wilson 81*67f7fba8SMatt Roper bool intel_engine_reset_needs_wa_22011802037(struct intel_gt *gt); 82*67f7fba8SMatt Roper 83112ed2d3SChris Wilson #endif /* I915_RESET_H */ 84