drm/i915: Wrap around the tail offset before setting ring->tail
authorChris Wilson <chris@chris-wilson.co.uk>
Mon, 11 Jun 2018 11:08:45 +0000 (12:08 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Mon, 11 Jun 2018 13:03:49 +0000 (14:03 +0100)
commit41d37680ca0b157ad1ed29409bcdc2b0bc21d11f
tree755292c6753cfc09aa1707871eba43a20e041ffd
parentb3ee09a4de33259a89d30aca6b2ebb0bc26640af
drm/i915: Wrap around the tail offset before setting ring->tail

The HW only accepts offsets within ring->size, and fails peculiarly if
the RING_HEAD or RING_TAIL is set to ring->size. Therefore whenever we
set ring->head/ring->tail we want to make sure it is within value (using
intel_ring_wrap()).

v2: Double check execlists as well
v3: Remove redundancy with assert_ring_tail_valid()
v4: Just assert in intel_ring_reset() rather than be over-defensive.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Matthew Auld <matthew.william.auld@gmail.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> #v2
Link: https://patchwork.freedesktop.org/patch/msgid/20180611110845.31890-2-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/intel_lrc.c
drivers/gpu/drm/i915/intel_ringbuffer.c
drivers/gpu/drm/i915/intel_ringbuffer.h