drm/i915/gem: Keep request alive while attaching fences

Since commit e5dadff4b0 ("drm/i915: Protect request retirement with
timeline->mutex"), the request retirement can happen outside of the
struct_mutex serialised only by the timeline->mutex. We drop the
timeline->mutex on submitting the request (i915_request_add) so after
that point, it is liable to be freed. Make sure our local reference is
kept alive until we have finished attaching it to the signalers. (Note
that this erodes the argument that i915_request_add should consume the
reference, but that is a slightly larger patch!)

Fixes: e5dadff4b0 ("drm/i915: Protect request retirement with timeline->mutex")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191217134729.3297818-1-chris@chris-wilson.co.uk
(cherry picked from commit e14177f197)
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
This commit is contained in:
Chris Wilson 2019-12-17 13:47:29 +00:00 committed by Joonas Lahtinen
parent d55157f6aa
commit a76cf56920
1 changed files with 2 additions and 0 deletions

View File

@ -2694,6 +2694,7 @@ i915_gem_do_execbuffer(struct drm_device *dev,
err = eb_submit(&eb); err = eb_submit(&eb);
err_request: err_request:
add_to_client(eb.request, file); add_to_client(eb.request, file);
i915_request_get(eb.request);
i915_request_add(eb.request); i915_request_add(eb.request);
if (fences) if (fences)
@ -2709,6 +2710,7 @@ err_request:
fput(out_fence->file); fput(out_fence->file);
} }
} }
i915_request_put(eb.request);
err_batch_unpin: err_batch_unpin:
if (eb.batch_flags & I915_DISPATCH_SECURE) if (eb.batch_flags & I915_DISPATCH_SECURE)