When we retire the last request on the ring, before we ever access that
ring again we know it will be completely idle and so we can advance the
ring->head fully to the end (i.e. ring->tail) and not just to the start
of the breadcrumb. This allows us to skip re-emitting the breadcrumb
after resetting the GPU if the ring was entirely idle. This prevents us
from overwriting a seqno wraparound by re-executing a stale breadcrumb,
i.e.
        submit_request(1)
        intel_engine_init_global_seqno(0)
        i915_reset()
would then leave 1 in the HWS, but the next request to execute would
also be with seqno 1. The sanity checks upon submission detect this as a
timewarp and explode. By setting the ring as empty, upon reset the HWS
is left as 0, leaving it consistent with the timeline.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100144
Testcase: igt/gem_exec_whisper/hang-*
Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem_request.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_request.c 
b/drivers/gpu/drm/i915/i915_gem_request.c
index 2f8c5132b54e..2cc090ee1440 100644
--- a/drivers/gpu/drm/i915/i915_gem_request.c
+++ b/drivers/gpu/drm/i915/i915_gem_request.c
@@ -295,8 +295,11 @@ static void i915_gem_request_retire(struct 
drm_i915_gem_request *request)
         * Note this requires that we are always called in request
         * completion order.
         */
+       if (request->ring_link.prev == &request->ring->request_list)
+               request->ring->head = request->ring->tail;
+       else
+               request->ring->head = request->postfix;
        list_del(&request->ring_link);
-       request->ring->head = request->postfix;
        if (!--request->i915->gt.active_requests) {
                GEM_BUG_ON(!request->i915->gt.awake);
                mod_delayed_work(request->i915->wq,
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to