Commit 304d695c authored by Chris Wilson's avatar Chris Wilson Committed by Daniel Vetter

drm/i915: Flush outstanding requests before allocating new seqno

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 9d773091
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: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent b38538cc
...@@ -1607,8 +1607,8 @@ intel_ring_alloc_seqno(struct intel_ring_buffer *ring) ...@@ -1607,8 +1607,8 @@ intel_ring_alloc_seqno(struct intel_ring_buffer *ring)
return i915_gem_get_seqno(ring->dev, &ring->outstanding_lazy_seqno); return i915_gem_get_seqno(ring->dev, &ring->outstanding_lazy_seqno);
} }
static int __intel_ring_begin(struct intel_ring_buffer *ring, static int __intel_ring_prepare(struct intel_ring_buffer *ring,
int bytes) int bytes)
{ {
int ret; int ret;
...@@ -1624,7 +1624,6 @@ static int __intel_ring_begin(struct intel_ring_buffer *ring, ...@@ -1624,7 +1624,6 @@ static int __intel_ring_begin(struct intel_ring_buffer *ring,
return ret; return ret;
} }
ring->space -= bytes;
return 0; return 0;
} }
...@@ -1639,12 +1638,17 @@ int intel_ring_begin(struct intel_ring_buffer *ring, ...@@ -1639,12 +1638,17 @@ int intel_ring_begin(struct intel_ring_buffer *ring,
if (ret) if (ret)
return ret; return ret;
ret = __intel_ring_prepare(ring, num_dwords * sizeof(uint32_t));
if (ret)
return ret;
/* Preallocate the olr before touching the ring */ /* Preallocate the olr before touching the ring */
ret = intel_ring_alloc_seqno(ring); ret = intel_ring_alloc_seqno(ring);
if (ret) if (ret)
return ret; return ret;
return __intel_ring_begin(ring, num_dwords * sizeof(uint32_t)); ring->space -= num_dwords * sizeof(uint32_t);
return 0;
} }
void intel_ring_init_seqno(struct intel_ring_buffer *ring, u32 seqno) void intel_ring_init_seqno(struct intel_ring_buffer *ring, u32 seqno)
......
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