On Thu, May 06, 2021 at 12:14:22PM -0700, Matthew Brost wrote: > GuC will issue a reset on detecting an engine hang and will notify > the driver via a G2H message. The driver will service the notification > by resetting the guilty context to a simple state or banning it > completely. > > Cc: Matthew Brost <matthew.br...@intel.com> > Cc: John Harrison <john.c.harri...@intel.com> > Signed-off-by: Matthew Brost <matthew.br...@intel.com>
Entirely aside, but I wonder whether we shouldn't just make non-recoverable contexts the only thing we support. But probably a too big can of worms. -Daniel > --- > drivers/gpu/drm/i915/gt/uc/intel_guc.h | 2 ++ > drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c | 6 ++++ > .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 35 +++++++++++++++++++ > drivers/gpu/drm/i915/i915_trace.h | 10 ++++++ > 4 files changed, 53 insertions(+) > > diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc.h > b/drivers/gpu/drm/i915/gt/uc/intel_guc.h > index 277b4496a20e..a2abe1c422e3 100644 > --- a/drivers/gpu/drm/i915/gt/uc/intel_guc.h > +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc.h > @@ -263,6 +263,8 @@ int intel_guc_deregister_done_process_msg(struct > intel_guc *guc, > const u32 *msg, u32 len); > int intel_guc_sched_done_process_msg(struct intel_guc *guc, > const u32 *msg, u32 len); > +int intel_guc_context_reset_process_msg(struct intel_guc *guc, > + const u32 *msg, u32 len); > > void intel_guc_submission_reset_prepare(struct intel_guc *guc); > void intel_guc_submission_reset(struct intel_guc *guc, bool stalled); > diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c > b/drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c > index b3194d753b13..9c84b2ba63a8 100644 > --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c > +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c > @@ -941,6 +941,12 @@ static int ct_process_request(struct intel_guc_ct *ct, > struct ct_incoming_msg *r > CT_ERROR(ct, "schedule context failed %x %*ph\n", > action, 4 * len, payload); > break; > + case INTEL_GUC_ACTION_CONTEXT_RESET_NOTIFICATION: > + ret = intel_guc_context_reset_process_msg(guc, payload, len); > + if (unlikely(ret)) > + CT_ERROR(ct, "context reset notification failed %x > %*ph\n", > + action, 4 * len, payload); > + break; > default: > ret = -EOPNOTSUPP; > break; > diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c > b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c > index 2c3791fc24b7..940017495731 100644 > --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c > +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c > @@ -2192,6 +2192,41 @@ int intel_guc_sched_done_process_msg(struct intel_guc > *guc, > return 0; > } > > +static void guc_context_replay(struct intel_context *ce) > +{ > + struct i915_sched_engine *sched_engine = ce->engine->sched_engine; > + > + __guc_reset_context(ce, true); > + i915_sched_engine_hi_kick(sched_engine); > +} > + > +static void guc_handle_context_reset(struct intel_guc *guc, > + struct intel_context *ce) > +{ > + trace_intel_context_reset(ce); > + guc_context_replay(ce); > +} > + > +int intel_guc_context_reset_process_msg(struct intel_guc *guc, > + const u32 *msg, u32 len) > +{ > + struct intel_context *ce; > + int desc_idx = msg[0]; > + > + if (unlikely(len != 1)) { > + drm_dbg(&guc_to_gt(guc)->i915->drm, "Invalid length %u", len); > + return -EPROTO; > + } > + > + ce = g2h_context_lookup(guc, desc_idx); > + if (unlikely(!ce)) > + return -EPROTO; > + > + guc_handle_context_reset(guc, ce); > + > + return 0; > +} > + > void intel_guc_log_submission_info(struct intel_guc *guc, > struct drm_printer *p) > { > diff --git a/drivers/gpu/drm/i915/i915_trace.h > b/drivers/gpu/drm/i915/i915_trace.h > index 97c2e83984ed..c095c4d39456 100644 > --- a/drivers/gpu/drm/i915/i915_trace.h > +++ b/drivers/gpu/drm/i915/i915_trace.h > @@ -929,6 +929,11 @@ DECLARE_EVENT_CLASS(intel_context, > __entry->guc_sched_state_no_lock) > ); > > +DEFINE_EVENT(intel_context, intel_context_reset, > + TP_PROTO(struct intel_context *ce), > + TP_ARGS(ce) > +); > + > DEFINE_EVENT(intel_context, intel_context_register, > TP_PROTO(struct intel_context *ce), > TP_ARGS(ce) > @@ -1026,6 +1031,11 @@ trace_i915_request_out(struct i915_request *rq) > { > } > > +static inline void > +trace_intel_context_reset(struct intel_context *ce) > +{ > +} > + > static inline void > trace_intel_context_register(struct intel_context *ce) > { > -- > 2.28.0 > > _______________________________________________ > Intel-gfx mailing list > intel-...@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch