Commit d97ed339 authored by Chris Wilson's avatar Chris Wilson Committed by Eric Anholt

drm/i915: Move ringbuffer accounting to begin/advance.

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: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarEric Anholt <eric@anholt.net>
parent 1741dd4a
...@@ -731,6 +731,8 @@ void intel_ring_begin(struct drm_device *dev, ...@@ -731,6 +731,8 @@ void intel_ring_begin(struct drm_device *dev,
intel_wrap_ring_buffer(dev, ring); intel_wrap_ring_buffer(dev, ring);
if (unlikely(ring->space < n)) if (unlikely(ring->space < n))
intel_wait_ring_buffer(dev, ring, n); intel_wait_ring_buffer(dev, ring, n);
ring->space -= n;
} }
void intel_ring_emit(struct drm_device *dev, void intel_ring_emit(struct drm_device *dev,
...@@ -739,13 +741,12 @@ void intel_ring_emit(struct drm_device *dev, ...@@ -739,13 +741,12 @@ void intel_ring_emit(struct drm_device *dev,
unsigned int *virt = ring->virtual_start + ring->tail; unsigned int *virt = ring->virtual_start + ring->tail;
*virt = data; *virt = data;
ring->tail += 4; ring->tail += 4;
ring->tail &= ring->size - 1;
ring->space -= 4;
} }
void intel_ring_advance(struct drm_device *dev, void intel_ring_advance(struct drm_device *dev,
struct intel_ring_buffer *ring) struct intel_ring_buffer *ring)
{ {
ring->tail &= ring->size - 1;
ring->advance_ring(dev, ring); ring->advance_ring(dev, ring);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment