Skip to content

Commit 3220c3b

Browse files
karolherbstjlahtine-intel
authored andcommitted
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] Cc: [email protected] Cc: <[email protected]> # v5.3+ Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5732 Signed-off-by: Karol Herbst <[email protected]> Fixes: 155ab88 ("drm/i915: Move object close under its own lock") Reviewed-by: Tvrtko Ursulin <[email protected]> Signed-off-by: Tvrtko Ursulin <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 1df1c79) Signed-off-by: Joonas Lahtinen <[email protected]>
1 parent c5eb0a6 commit 3220c3b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

drivers/gpu/drm/i915/i915_vma.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,17 +1605,17 @@ void i915_vma_close(struct i915_vma *vma)
16051605

16061606
static void __i915_vma_remove_closed(struct i915_vma *vma)
16071607
{
1608-
struct intel_gt *gt = vma->vm->gt;
1609-
1610-
spin_lock_irq(&gt->closed_lock);
16111608
list_del_init(&vma->closed_link);
1612-
spin_unlock_irq(&gt->closed_lock);
16131609
}
16141610

16151611
void i915_vma_reopen(struct i915_vma *vma)
16161612
{
1613+
struct intel_gt *gt = vma->vm->gt;
1614+
1615+
spin_lock_irq(&gt->closed_lock);
16171616
if (i915_vma_is_closed(vma))
16181617
__i915_vma_remove_closed(vma);
1618+
spin_unlock_irq(&gt->closed_lock);
16191619
}
16201620

16211621
void i915_vma_release(struct kref *ref)
@@ -1641,6 +1641,7 @@ static void force_unbind(struct i915_vma *vma)
16411641
static void release_references(struct i915_vma *vma)
16421642
{
16431643
struct drm_i915_gem_object *obj = vma->obj;
1644+
struct intel_gt *gt = vma->vm->gt;
16441645

16451646
GEM_BUG_ON(i915_vma_is_active(vma));
16461647

@@ -1650,7 +1651,9 @@ static void release_references(struct i915_vma *vma)
16501651
rb_erase(&vma->obj_node, &obj->vma.tree);
16511652
spin_unlock(&obj->vma.lock);
16521653

1654+
spin_lock_irq(&gt->closed_lock);
16531655
__i915_vma_remove_closed(vma);
1656+
spin_unlock_irq(&gt->closed_lock);
16541657

16551658
__i915_vma_put(vma);
16561659
}

0 commit comments

Comments
 (0)