drm/i915: Stop automatically retiring requests after a GPU hang
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 13 May 2016 10:57:22 +0000 (11:57 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 13 May 2016 11:39:20 +0000 (12:39 +0100)
Following a GPU hang, we break out of the request loop in order to
unlock the struct_mutex for use by the GPU reset. However, if we retire
all the requests at that moment, we cannot identify the guilty request
after performing the reset.

v2: Not automatically retiring requests forces us to recheck for
available ringspace.

Fixes: f4457ae71fd6 ("drm/i915: Prevent leaking of -EIO from i915_wait_request()")
Testcase: igt/gem_reset_stats/ban-*
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Mika Kuoppala <mika.kuoppala@intel.com>
Tested-by: Mika Kuoppala <mika.kuoppala@intel.com>
Reviewed-by: Mika Kuoppala <mika.kuoppala@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1463137042-9669-4-git-send-email-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/intel_ringbuffer.c

index 474c0272e73d29c1fdc777edb2d088087f92bd85..b1a33fe95ab3a84a6618ed7ba95eb52d140debed 100644 (file)
@@ -1462,7 +1462,10 @@ i915_wait_request(struct drm_i915_gem_request *req)
        if (ret)
                return ret;
 
-       __i915_gem_request_retire__upto(req);
+       /* If the GPU hung, we want to keep the requests to find the guilty. */
+       if (req->reset_counter == i915_reset_counter(&dev_priv->gpu_error))
+               __i915_gem_request_retire__upto(req);
+
        return 0;
 }
 
@@ -1519,7 +1522,8 @@ i915_gem_object_retire_request(struct drm_i915_gem_object *obj,
        else if (obj->last_write_req == req)
                i915_gem_object_retire__write(obj);
 
-       __i915_gem_request_retire__upto(req);
+       if (req->reset_counter == i915_reset_counter(&req->i915->gpu_error))
+               __i915_gem_request_retire__upto(req);
 }
 
 /* A nonblocking variant of the above wait. This is a highly dangerous routine
index 0618dd34c3ec32c9ea2bf07dfc07575752c8345a..8d35a3978f9bf978dd1543c0f2e587e139b74796 100644 (file)
@@ -2450,6 +2450,8 @@ int intel_ring_begin(struct drm_i915_gem_request *req, int num_dwords)
                        return ret;
 
                intel_ring_update_space(ringbuf);
+               if (unlikely(ringbuf->space < wait_bytes))
+                       return -EAGAIN;
        }
 
        if (unlikely(need_wrap)) {