Skip to content

Commit

Permalink
drm/i915: Hold onto an explicit ref to i915_vma_work.pinned
Browse files Browse the repository at this point in the history
[ Upstream commit 537457a ]

Since __vma_release is run by a kworker after the fence has been
signaled, it is no longer protected by the active reference on the vma,
and so the alias of vw->pinned to vma->obj is also not protected by a
reference on the object. Add an explicit reference for vw->pinned so it
will always be safe.

Found by inspection.

Fixes: 54d7195 ("drm/i915: Unpin vma->obj on early error")
Reported-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: <stable@vger.kernel.org> # v5.6+
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201102161931.30031-1-chris@chris-wilson.co.uk
(cherry picked from commit bc73e5d)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
ickle authored and gregkh committed Nov 18, 2020
1 parent 951cbbc commit 81a01ed
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/gpu/drm/i915/i915_vma.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,10 @@ static void __vma_release(struct dma_fence_work *work)
{
struct i915_vma_work *vw = container_of(work, typeof(*vw), base);

if (vw->pinned)
if (vw->pinned) {
__i915_gem_object_unpin_pages(vw->pinned);
i915_gem_object_put(vw->pinned);
}
}

static const struct dma_fence_work_ops bind_ops = {
Expand Down Expand Up @@ -430,7 +432,7 @@ int i915_vma_bind(struct i915_vma *vma,

if (vma->obj) {
__i915_gem_object_pin_pages(vma->obj);
work->pinned = vma->obj;
work->pinned = i915_gem_object_get(vma->obj);
}
} else {
ret = vma->ops->bind_vma(vma->vm, vma, cache_level, bind_flags);
Expand Down

0 comments on commit 81a01ed

Please sign in to comment.