[Intel-gfx] [PATCH 1/2] drm/i915: use effective_size for ringbuffer calculations

Dave Gordon david.s.gordon at intel.com
Fri Jun 12 10:09:07 PDT 2015


When calculating the available space in a ringbuffer, we should
use the effective_size rather than the true size of the ring.

v2: rebase to latest drm-intel-nightly
v3: rebase to latest drm-intel-nightly

Signed-off-by: Dave Gordon <david.s.gordon at intel.com>
---
 drivers/gpu/drm/i915/intel_lrc.c        |    5 +++--
 drivers/gpu/drm/i915/intel_ringbuffer.c |    9 ++++++---
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 9b74ffa..454e836 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -699,7 +699,7 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf,
 
 		/* Would completion of this request free enough space? */
 		space = __intel_ring_space(request->postfix, ringbuf->tail,
-					   ringbuf->size);
+					   ringbuf->effective_size);
 		if (space >= bytes)
 			break;
 	}
@@ -711,7 +711,8 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf,
 	if (ret)
 		return ret;
 
-	ringbuf->space = space;
+	/* Update ring space after wait+retire */
+	intel_ring_update_space(ringbuf);
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index b70d25b..a3406b2 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -66,7 +66,8 @@ void intel_ring_update_space(struct intel_ringbuffer *ringbuf)
 	}
 
 	ringbuf->space = __intel_ring_space(ringbuf->head & HEAD_ADDR,
-					    ringbuf->tail, ringbuf->size);
+					    ringbuf->tail,
+					    ringbuf->effective_size);
 }
 
 int intel_ring_space(struct intel_ringbuffer *ringbuf)
@@ -2117,8 +2118,9 @@ static int ring_wait_for_space(struct intel_engine_cs *ring, int n)
 		return 0;
 
 	list_for_each_entry(request, &ring->request_list, list) {
+		/* Would completion of this request free enough space? */
 		space = __intel_ring_space(request->postfix, ringbuf->tail,
-					   ringbuf->size);
+					   ringbuf->effective_size);
 		if (space >= n)
 			break;
 	}
@@ -2130,7 +2132,8 @@ static int ring_wait_for_space(struct intel_engine_cs *ring, int n)
 	if (ret)
 		return ret;
 
-	ringbuf->space = space;
+	/* Update ring space after wait+retire */
+	intel_ring_update_space(ringbuf);
 	return 0;
 }
 
-- 
1.7.9.5



More information about the Intel-gfx mailing list