Skip to contentSkip to conversation

FAILED: patch "[PATCH] drm/i915: Hold onto an explicit ref to i915_vma_work.pinned" failed to apply to 5.9-stable tree

PATCH [email protected] 1 participant 1 message Nov 9, 2020

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.9-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 537457a979a02a410b555fab289dcb28b588f33b Mon Sep 17 00:00:00 2001
From: Chris Wilson <[email protected]>
Date: Mon, 2 Nov 2020 16:19:31 +0000
Subject: [PATCH] drm/i915: Hold onto an explicit ref to i915_vma_work.pinned

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 54d7195f8c64 ("drm/i915: Unpin vma->obj on early error")
Cc Tvrtko Ursulin <[email protected]>
Cc <[email protected]> # v5.6+
(cherry picked from commit bc73e5d33048b7ab5f12b11b5d923700467a8e1d)
drivers/gpu/drm/i915/i915_vma.c +4 -2
index ffb5287e055a..caa9b041616b 100644
@@ -314,8 +314,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);
+	}
 
 	i915_vm_free_pt_stash(vw->vm, &vw->stash);
 	i915_vm_put(vw->vm);
@@ -431,7 +433,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 {
 		vma->ops->bind_vma(vma->vm, NULL, vma, cache_level, bind_flags);