[Intel-gfx] [PATCH 1/3] drm/i915: Rework ring wrap detection

ville.syrjala at linux.intel.com ville.syrjala at linux.intel.com
Tue Feb 11 14:55:48 CET 2014


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

Move the ring wrap detection out from __intel_ring_prepare() all the way
up to intel_ring_begin(). Also convert intel_ring_begin() into a thin
wrapper that just does the wrap detection, and calls
__intel_ring_begin() which contains the code from the original
intel_ring_begin().

This will be useful when we introduce the cacheline safe ring begin
function where the wrap detection won't be quite so simple.

Cc: Bjoern C <lkml at call-home.ch>
Cc: Alexandru DAMIAN <alexandru.damian at intel.com>
Cc: Enrico Tagliavini <enrico.tagliavini at gmail.com>
Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 drivers/gpu/drm/i915/intel_ringbuffer.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index ba686d7..a2bd533 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -1595,11 +1595,11 @@ intel_ring_alloc_seqno(struct intel_ring_buffer *ring)
 }
 
 static int __intel_ring_prepare(struct intel_ring_buffer *ring,
-				int bytes)
+				int bytes, bool wrap)
 {
 	int ret;
 
-	if (unlikely(ring->tail + bytes > ring->effective_size)) {
+	if (unlikely(wrap)) {
 		ret = intel_wrap_ring_buffer(ring);
 		if (unlikely(ret))
 			return ret;
@@ -1614,8 +1614,8 @@ static int __intel_ring_prepare(struct intel_ring_buffer *ring,
 	return 0;
 }
 
-int intel_ring_begin(struct intel_ring_buffer *ring,
-		     int num_dwords)
+static int __intel_ring_begin(struct intel_ring_buffer *ring,
+			      int bytes, bool wrap)
 {
 	drm_i915_private_t *dev_priv = ring->dev->dev_private;
 	int ret;
@@ -1625,7 +1625,7 @@ int intel_ring_begin(struct intel_ring_buffer *ring,
 	if (ret)
 		return ret;
 
-	ret = __intel_ring_prepare(ring, num_dwords * sizeof(uint32_t));
+	ret = __intel_ring_prepare(ring, bytes, wrap);
 	if (ret)
 		return ret;
 
@@ -1634,10 +1634,19 @@ int intel_ring_begin(struct intel_ring_buffer *ring,
 	if (ret)
 		return ret;
 
-	ring->space -= num_dwords * sizeof(uint32_t);
+	ring->space -= bytes;
 	return 0;
 }
 
+int intel_ring_begin(struct intel_ring_buffer *ring,
+		     int num_dwords)
+{
+	int bytes = num_dwords * sizeof(uint32_t);
+
+	return __intel_ring_begin(ring, bytes,
+				  ring->tail + bytes > ring->effective_size);
+}
+
 void intel_ring_init_seqno(struct intel_ring_buffer *ring, u32 seqno)
 {
 	struct drm_i915_private *dev_priv = ring->dev->dev_private;
-- 
1.8.3.2




More information about the Intel-gfx mailing list