diff mbox series

[2/2] drm/i915: Cleanup properly if the implicit fence wait fails

Message ID 20180912185252.27191-2-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [1/2] drm/i915: Balance prepare_fb/cleanup_fb | expand

Commit Message

Ville Syrjälä Sept. 12, 2018, 6:52 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

We've already pinned the vma and fence by the time we try to
deal with implicit fencing. Properly unpin the vma and fence
if the fence wait fails instead of just bailing straight out
from .prepare_fb(). As can be expected
drm_atomic_helper_prepare_planes() will not call .cleanup_fb()
for the plane whose .prepare_fb() failed so we must do the
cleanup ourself.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 1333493c0618..947301312ea3 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -13188,7 +13188,7 @@  intel_prepare_plane_fb(struct drm_plane *plane,
 						      false, I915_FENCE_TIMEOUT,
 						      GFP_KERNEL);
 		if (ret < 0)
-			return ret;
+			goto unpin_fb;
 
 		fence = reservation_object_get_excl_rcu(obj->resv);
 		if (fence) {
@@ -13213,6 +13213,13 @@  intel_prepare_plane_fb(struct drm_plane *plane,
 	}
 
 	return 0;
+
+unpin_fb:
+	mutex_lock(&dev_priv->drm.struct_mutex);
+	intel_plane_unpin_fb(to_intel_plane_state(new_state));
+	mutex_unlock(&dev_priv->drm.struct_mutex);
+
+	return ret;
 }
 
 /**