FAILED: patch "[PATCH] drm/i915: Fix race in __i915_vma_remove_closed" failed to apply to 5.10-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.10-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 3220c3b2115102bb35f8f07d90d2989a3f5eb452 Mon Sep 17 00:00:00 2001
From: Karol Herbst <[email protected]>
Date: Wed, 20 Apr 2022 11:57:20 +0200
Subject: [PATCH] drm/i915: Fix race in __i915_vma_remove_closed
i915_vma_reopen checked if the vma is closed before without taking the lock. So multiple threads could attempt removing the vma.
Instead the lock needs to be taken before actually checking.
v2: move struct declaration
Cc Chris Wilson <[email protected]>
Cc <[email protected]> # v5.3+
Signed-off-by Karol Herbst <[email protected]>
Fixes 155ab8836caa ("drm/i915: Move object close under its own lock")
Reviewed-by Tvrtko Ursulin <[email protected]>
Signed-off-by Tvrtko Ursulin <[email protected]>
(cherry picked from commit 1df1c79cbb7ac9bf148930be3418973c76ba8dde)
Signed-off-by Joonas Lahtinen <[email protected]>
drivers/gpu/drm/i915/i915_vma.c +7 -4
@@ -1605,17 +1605,17 @@ void i915_vma_close(struct i915_vma *vma)static void __i915_vma_remove_closed (struct i915_vma *vma) { -struct intel_gt *gt = vma->vm->gt; - -spin_lock_irq (>->closed_lock);list_del_init (&vma->closed_link); -spin_unlock_irq (>->closed_lock); }void i915_vma_reopen (struct i915_vma *vma) { +struct intel_gt *gt = vma->vm->gt; + +spin_lock_irq (>->closed_lock);if (i915_vma_is_closed (vma))__i915_vma_remove_closed (vma); +spin_unlock_irq (>->closed_lock); }void i915_vma_release (struct kref *ref)
@@ -1641,6 +1641,7 @@ static void force_unbind(struct i915_vma *vma)static void release_references (struct i915_vma *vma) {struct drm_i915_gem_object *obj = vma->obj; +struct intel_gt *gt = vma->vm->gt;GEM_BUG_ON (i915_vma_is_active (vma));
@@ -1650,7 +1651,9 @@ static void release_references(struct i915_vma *vma)rb_erase (&vma->obj_node, &obj->vma.tree);spin_unlock (&obj->vma.lock); +spin_lock_irq (>->closed_lock);__i915_vma_remove_closed (vma); +spin_unlock_irq (>->closed_lock);__i915_vma_put (vma); }