Blob Blame History Raw
From 56184a20a80037c39fccc78b683cf593a2db4c5f Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris@chris-wilson.co.uk>
Date: Tue, 15 Oct 2019 10:39:15 +0100
Subject: drm/i915: Drop obj.page_pin_count after a failed vma->set_pages()
Git-commit: 56184a20a80037c39fccc78b683cf593a2db4c5f
Patch-mainline: v5.5-rc1
References: bsc#1152489

Before we attempt to set_pages on the vma, we claim a
obj.pages_pin_count for it. If we subsequently fail to set the pages on
the vma, we need to drop our pinning before returning the error.

Reported-by: Matthew Auld <matthew.auld@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191015093915.3995-1-chris@chris-wilson.co.uk
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/i915/i915_vma.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
index 9fdcd4e2c799..7d936254bde7 100644
--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -802,8 +802,11 @@ static int vma_get_pages(struct i915_vma *vma)
 		}
 
 		err = vma->ops->set_pages(vma);
-		if (err)
+		if (err) {
+			if (vma->obj)
+				i915_gem_object_unpin_pages(vma->obj);
 			goto unlock;
+		}
 	}
 	atomic_inc(&vma->pages_count);
 
-- 
2.28.0