diff mbox

[1/2] drm/i915: Don't allow ring tail to reach the same cacheline as head

Message ID 1353934099-18685-2-git-send-email-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ville Syrjälä Nov. 26, 2012, 12:48 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

According to BSpec the ring head and tail pointers must not be
on the same cacheline when head > tail. The easiest way to enforce
this is to reduce the reported ring space.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_dma.c         |    2 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c |    4 ++--
 drivers/gpu/drm/i915/intel_ringbuffer.h |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

Comments

Chris Wilson Nov. 26, 2012, 4:28 p.m. UTC | #1
On Mon, 26 Nov 2012 14:48:18 +0200, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> According to BSpec the ring head and tail pointers must not be
> on the same cacheline when head > tail. The easiest way to enforce
> this is to reduce the reported ring space.

I'm going to admit blindness because I don't see that warning in the
gen2-gen7 bspecs. Can you please give chapter and verse, and check to
see if there is a rationale?
-Chris
Ville Syrjälä Nov. 26, 2012, 6:02 p.m. UTC | #2
On Mon, Nov 26, 2012 at 04:28:33PM +0000, Chris Wilson wrote:
> On Mon, 26 Nov 2012 14:48:18 +0200, ville.syrjala@linux.intel.com wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > According to BSpec the ring head and tail pointers must not be
> > on the same cacheline when head > tail. The easiest way to enforce
> > this is to reduce the reported ring space.
> 
> I'm going to admit blindness because I don't see that warning in the
> gen2-gen7 bspecs. Can you please give chapter and verse, and check to
> see if there is a rationale?

It's always the last thing in the section titled 'Ring Buffer Use'. I
believe it's present in all the pre-snb internal bspecs, and it's also
in all the public docs. I can't find it in the internal snb+ bspec but
then again those don't seem to include the relevant chapter at all.

Of course I can't be sure if it's a valid issue, or just something that
got faithfully copypasted from one document to the next.
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 2cba7b4..d184727 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -168,7 +168,7 @@  void i915_kernel_lost_context(struct drm_device * dev)
 
 	ring->head = I915_READ_HEAD(ring) & HEAD_ADDR;
 	ring->tail = I915_READ_TAIL(ring) & TAIL_ADDR;
-	ring->space = ring->head - (ring->tail + 8);
+	ring->space = ring->head - (ring->tail + 64);
 	if (ring->space < 0)
 		ring->space += ring->size;
 
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index c828169..70a184e 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 & HEAD_ADDR) - (ring->tail + 64);
 	if (space < 0)
 		space += ring->size;
 	return space;
@@ -1163,7 +1163,7 @@  static int intel_ring_wait_request(struct intel_ring_buffer *ring, int n)
 		if (request->tail == -1)
 			continue;
 
-		space = request->tail - (ring->tail + 8);
+		space = request->tail - (ring->tail + 64);
 		if (space < 0)
 			space += ring->size;
 		if (space >= n) {
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 2ea7a31..b15f896 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -187,7 +187,7 @@  void intel_cleanup_ring_buffer(struct intel_ring_buffer *ring);
 int __must_check intel_wait_ring_buffer(struct intel_ring_buffer *ring, int n);
 static inline int intel_wait_ring_idle(struct intel_ring_buffer *ring)
 {
-	return intel_wait_ring_buffer(ring, ring->size - 8);
+	return intel_wait_ring_buffer(ring, ring->size - 64);
 }
 
 int __must_check intel_ring_begin(struct intel_ring_buffer *ring, int n);