@@ -1379,9 +1379,33 @@ static int execlists_context_pin(struct intel_context *ce)
13791379 return __execlists_context_pin (ce , ce -> engine );
13801380}
13811381
1382+ static void execlists_context_reset (struct intel_context * ce )
1383+ {
1384+ /*
1385+ * Because we emit WA_TAIL_DWORDS there may be a disparity
1386+ * between our bookkeeping in ce->ring->head and ce->ring->tail and
1387+ * that stored in context. As we only write new commands from
1388+ * ce->ring->tail onwards, everything before that is junk. If the GPU
1389+ * starts reading from its RING_HEAD from the context, it may try to
1390+ * execute that junk and die.
1391+ *
1392+ * The contexts that are stilled pinned on resume belong to the
1393+ * kernel, and are local to each engine. All other contexts will
1394+ * have their head/tail sanitized upon pinning before use, so they
1395+ * will never see garbage,
1396+ *
1397+ * So to avoid that we reset the context images upon resume. For
1398+ * simplicity, we just zero everything out.
1399+ */
1400+ intel_ring_reset (ce -> ring , 0 );
1401+ __execlists_update_reg_state (ce , ce -> engine );
1402+ }
1403+
13821404static const struct intel_context_ops execlists_context_ops = {
13831405 .pin = execlists_context_pin ,
13841406 .unpin = execlists_context_unpin ,
1407+
1408+ .reset = execlists_context_reset ,
13851409 .destroy = execlists_context_destroy ,
13861410};
13871411
@@ -2895,31 +2919,6 @@ static int execlists_context_deferred_alloc(struct intel_context *ce,
28952919 return ret ;
28962920}
28972921
2898- void intel_lr_context_resume (struct drm_i915_private * i915 )
2899- {
2900- struct i915_gem_context * ctx ;
2901- struct intel_context * ce ;
2902-
2903- /*
2904- * Because we emit WA_TAIL_DWORDS there may be a disparity
2905- * between our bookkeeping in ce->ring->head and ce->ring->tail and
2906- * that stored in context. As we only write new commands from
2907- * ce->ring->tail onwards, everything before that is junk. If the GPU
2908- * starts reading from its RING_HEAD from the context, it may try to
2909- * execute that junk and die.
2910- *
2911- * So to avoid that we reset the context images upon resume. For
2912- * simplicity, we just zero everything out.
2913- */
2914- list_for_each_entry (ctx , & i915 -> contexts .list , link ) {
2915- list_for_each_entry (ce , & ctx -> active_engines , active_link ) {
2916- GEM_BUG_ON (!ce -> ring );
2917- intel_ring_reset (ce -> ring , 0 );
2918- __execlists_update_reg_state (ce , ce -> engine );
2919- }
2920- }
2921- }
2922-
29232922void intel_execlists_show_requests (struct intel_engine_cs * engine ,
29242923 struct drm_printer * m ,
29252924 void (* show_request )(struct drm_printer * m ,
0 commit comments