Skip to content

Commit

Permalink
drm/i915: Move fd_install after last use of fence
Browse files Browse the repository at this point in the history
Because eb_composite_fence_create() drops the fence_array reference
after creation of the sync_file, only the sync_file holds a ref to the
fence.  But fd_install() makes that reference visable to userspace, so
it must be the last thing we do with the fence.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Fixes: 00dae4d ("drm/i915: Implement SINGLE_TIMELINE with a syncobj (v4)")
Cc: <stable@vger.kernel.org> # v5.15+
[tursulin: Added stable tag.]
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230203164937.4035503-1-robdclark@gmail.com
  • Loading branch information
Rob Clark authored and Tvrtko Ursulin committed Feb 6, 2023
1 parent 01f0411 commit 960dafa
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3486,6 +3486,13 @@ i915_gem_do_execbuffer(struct drm_device *dev,
eb.composite_fence :
&eb.requests[0]->fence);

if (unlikely(eb.gem_context->syncobj)) {
drm_syncobj_replace_fence(eb.gem_context->syncobj,
eb.composite_fence ?
eb.composite_fence :
&eb.requests[0]->fence);
}

if (out_fence) {
if (err == 0) {
fd_install(out_fence_fd, out_fence->file);
Expand All @@ -3497,13 +3504,6 @@ i915_gem_do_execbuffer(struct drm_device *dev,
}
}

if (unlikely(eb.gem_context->syncobj)) {
drm_syncobj_replace_fence(eb.gem_context->syncobj,
eb.composite_fence ?
eb.composite_fence :
&eb.requests[0]->fence);
}

if (!out_fence && eb.composite_fence)
dma_fence_put(eb.composite_fence);

Expand Down

0 comments on commit 960dafa

Please sign in to comment.