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.

Fixes: f4457ae71fd6 ("drm/i915: Prevent leaking of -EIO from 
i915_wait_request()")
Testcase: igt/gem_reset_stats
Signed-off-by: Chris Wilson <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: Mika Kuoppala <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 474c027..b1a33fe9 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -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
-- 
2.8.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to