aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_ringbuffer.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-01-02 09:32:35 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-02-13 16:48:03 -0500
commit98e0694d0e679e7018b6617f48fa04b7b888cef3 (patch)
tree5ee8cd553ee592db352f4f78201f71d5d85759a8 /drivers/gpu/drm/i915/intel_ringbuffer.c
parentc3c43400a29dba30a581c97a6eb6952d187c3e07 (diff)
drm/i915: Flush outstanding requests before allocating new seqno
commit 304d695c3dc8eb65206b9eaf16f8d1a41510d1cf upstream. In very rare cases (such as a memory failure stress test) it is possible to fill the entire ring without emitting a request. Under this circumstance, the outstanding request is flushed and waited upon. After space on the ring is cleared, we return to emitting the new command - except that we just cleared the seqno allocated for this operation and trigger the sanity check that a request is only ever emitted with a valid seqno. The fix is to rearrange the code to make sure the allocation of the seqno for this operation is after any required flushes of outstanding operations. The bug exists since the preallocation was introduced in commit 9d7730914f4cd496e356acfab95b41075aa8eae8 Author: Chris Wilson <chris@chris-wilson.co.uk> Date: Tue Nov 27 16:22:52 2012 +0000 drm/i915: Preallocate next seqno before touching the ring Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Mika Kuoppala <mika.kuoppala@intel.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_ringbuffer.c')
-rw-r--r--drivers/gpu/drm/i915/intel_ringbuffer.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 48fe23e8d180..629527d205de 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -1459,8 +1459,8 @@ intel_ring_alloc_seqno(struct intel_ring_buffer *ring)
1459 return i915_gem_get_seqno(ring->dev, &ring->outstanding_lazy_request); 1459 return i915_gem_get_seqno(ring->dev, &ring->outstanding_lazy_request);
1460} 1460}
1461 1461
1462static int __intel_ring_begin(struct intel_ring_buffer *ring, 1462static int __intel_ring_prepare(struct intel_ring_buffer *ring,
1463 int bytes) 1463 int bytes)
1464{ 1464{
1465 int ret; 1465 int ret;
1466 1466
@@ -1476,7 +1476,6 @@ static int __intel_ring_begin(struct intel_ring_buffer *ring,
1476 return ret; 1476 return ret;
1477 } 1477 }
1478 1478
1479 ring->space -= bytes;
1480 return 0; 1479 return 0;
1481} 1480}
1482 1481
@@ -1491,12 +1490,17 @@ int intel_ring_begin(struct intel_ring_buffer *ring,
1491 if (ret) 1490 if (ret)
1492 return ret; 1491 return ret;
1493 1492
1493 ret = __intel_ring_prepare(ring, num_dwords * sizeof(uint32_t));
1494 if (ret)
1495 return ret;
1496
1494 /* Preallocate the olr before touching the ring */ 1497 /* Preallocate the olr before touching the ring */
1495 ret = intel_ring_alloc_seqno(ring); 1498 ret = intel_ring_alloc_seqno(ring);
1496 if (ret) 1499 if (ret)
1497 return ret; 1500 return ret;
1498 1501
1499 return __intel_ring_begin(ring, num_dwords * sizeof(uint32_t)); 1502 ring->space -= num_dwords * sizeof(uint32_t);
1503 return 0;
1500} 1504}
1501 1505
1502void intel_ring_init_seqno(struct intel_ring_buffer *ring, u32 seqno) 1506void intel_ring_init_seqno(struct intel_ring_buffer *ring, u32 seqno)