[Intel-gfx] [PATCH 2/4] drm/i915: Move ringbuffer accounting to begin/advance.

Chris Wilson chris at chris-wilson.co.uk
Wed Aug 4 16:18:13 CEST 2010


As we check that the ringbuffer will not wrap upon emission, we do not
need to check that incrementing the tail wrapped every time. However, we
do upon advancing just in case the tail is now pointing at the very end
of the ring.

Likewise we can account for the space used during emission in begin()
and avoid decrementing it for every emit.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_ringbuffer.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index b5ccee5..c153d4e 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -751,6 +751,8 @@ void intel_ring_begin(struct drm_device *dev,
 		intel_wrap_ring_buffer(dev, ring);
 	if (unlikely(ring->space < n))
 		intel_wait_ring_buffer(dev, ring, n);
+
+	ring->space -= n;
 }
 
 void intel_ring_emit(struct drm_device *dev,
@@ -759,13 +761,12 @@ void intel_ring_emit(struct drm_device *dev,
 	unsigned int *virt = ring->virtual_start + ring->tail;
 	*virt = data;
 	ring->tail += 4;
-	ring->tail &= ring->size - 1;
-	ring->space -= 4;
 }
 
 void intel_ring_advance(struct drm_device *dev,
 		struct intel_ring_buffer *ring)
 {
+	ring->tail &= ring->size - 1;
 	ring->advance_ring(dev, ring);
 }
 
-- 
1.7.1




More information about the Intel-gfx mailing list