[Intel-gfx] [PATCH] drm/i915: Mask the ring->head offset using the ring->size

Chris Wilson chris at chris-wilson.co.uk
Wed Nov 9 00:13:12 CET 2011


Rather than relying on the hardware to do this correctly, we can
trivially do it ourselves.

This fixes a very reliable crash on d-i-n with all bits enabled during a
cairo-trace replay. The symptoms of the crash is that we continue to
write commands into the render ring buffer past the active head
position, leading to undefined operations.

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

diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 3c30dba..90aa9f7 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -46,7 +46,7 @@ struct pipe_control {
 
 static inline int ring_space(struct intel_ring_buffer *ring)
 {
-	int space = (ring->head & HEAD_ADDR) - (ring->tail + 8);
+	int space = (ring->head & (ring->size-1)) - (ring->tail + 8);
 	if (space < 0)
 		space += ring->size;
 	return space;
-- 
1.7.7.2




More information about the Intel-gfx mailing list