drm/i915: Drop vm.ref for duplicate vma on construction
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 2 Jul 2020 08:32:03 +0000 (09:32 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 Jul 2020 06:13:32 +0000 (08:13 +0200)
commit98762e5b00567622d57295d2d3389aea2c37be03
tree7111b3c4dd33e7d0109bd2c81ef6c297267958b3
parent22ff658396b44606163ad0231e8215309a26d613
drm/i915: Drop vm.ref for duplicate vma on construction

commit 42723673a193d5f8e30dba6ea9826d42262a502b upstream.

As we allow for parallel threads to create the same vma instance
concurrently, and we only filter out the duplicates upon reacquiring the
spinlock for the rbtree, we have to free the loser of the constructors'
race. When freeing, we should also drop any resource references acquired
for the redundant vma.

Fixes: 2850748ef876 ("drm/i915: Pull i915_vma_pin under the vm->mutex")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: <stable@vger.kernel.org> # v5.5+
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200702083225.20044-1-chris@chris-wilson.co.uk
(cherry picked from commit 2377427cdd2b7514eb4c40241cf5c4dec63c1bec)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/i915/i915_vma.c