[Intel-gfx] [PATCH] drm/i915: Fix for reserved space WARN_ON when ring begin fails

John.C.Harrison at Intel.com John.C.Harrison at Intel.com
Wed Jan 13 04:52:40 PST 2016


From: John Harrison <John.C.Harrison at Intel.com>

The reserved space code was not cleaning up properly in the case where
the intel_ring_begin() call failed. This led to WARN_ONs firing about
a double reserve call when running the gem_reset_stats IGT test.

Signed-off-by: John Harrison <John.C.Harrison at Intel.com>
---
 drivers/gpu/drm/i915/intel_lrc.c        | 8 +++++++-
 drivers/gpu/drm/i915/intel_ringbuffer.c | 8 +++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 06180dc..7dcc299 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -835,6 +835,8 @@ int intel_logical_ring_begin(struct drm_i915_gem_request *req, int num_dwords)
 
 int intel_logical_ring_reserve_space(struct drm_i915_gem_request *request)
 {
+	int ret;
+
 	/*
 	 * The first call merely notes the reserve request and is common for
 	 * all back ends. The subsequent localised _begin() call actually
@@ -845,7 +847,11 @@ int intel_logical_ring_reserve_space(struct drm_i915_gem_request *request)
 	 */
 	intel_ring_reserved_space_reserve(request->ringbuf, MIN_SPACE_FOR_ADD_REQUEST);
 
-	return intel_logical_ring_begin(request, 0);
+	ret = intel_logical_ring_begin(request, 0);
+	if (ret)
+		intel_ring_reserved_space_cancel(request->ringbuf);
+
+	return ret;
 }
 
 /**
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index c9b081f..f1d3a4a 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -2296,6 +2296,8 @@ int intel_ring_alloc_request_extras(struct drm_i915_gem_request *request)
 
 int intel_ring_reserve_space(struct drm_i915_gem_request *request)
 {
+	int ret;
+
 	/*
 	 * The first call merely notes the reserve request and is common for
 	 * all back ends. The subsequent localised _begin() call actually
@@ -2306,7 +2308,11 @@ int intel_ring_reserve_space(struct drm_i915_gem_request *request)
 	 */
 	intel_ring_reserved_space_reserve(request->ringbuf, MIN_SPACE_FOR_ADD_REQUEST);
 
-	return intel_ring_begin(request, 0);
+	ret = intel_ring_begin(request, 0);
+	if (ret)
+		intel_ring_reserved_space_cancel(request->ringbuf);
+
+	return ret;
 }
 
 void intel_ring_reserved_space_reserve(struct intel_ringbuffer *ringbuf, int size)
-- 
1.9.1



More information about the Intel-gfx mailing list