diff mbox

drm/i915: Set sync_seqno properly after seqno wrap

Message ID 1354115925-32630-1-git-send-email-mika.kuoppala@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mika Kuoppala Nov. 28, 2012, 3:18 p.m. UTC
i915_gem_handle_seqno_wrap() will zero all sync_seqnos but as the
wrap can happen inside ring->sync_to(), pre wrap seqno was
carried over and overwrote the zeroed sync_seqno.

When wrap is handled, all outstanding requests will be retired and
objects moved to inactive queue, causing their last_read_seqno to be zero.
Use this to update the sync_seqno correctly.

RING_SYNC registers after wrap will contain pre wrap values which
are >= seqno. So injecting the semaphore wait into ring completes
immediately.

Original idea for using last_read_seqno from Chris Wilson.

Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Daniel Vetter Nov. 29, 2012, 10:03 a.m. UTC | #1
On Wed, Nov 28, 2012 at 05:18:45PM +0200, Mika Kuoppala wrote:
> i915_gem_handle_seqno_wrap() will zero all sync_seqnos but as the
> wrap can happen inside ring->sync_to(), pre wrap seqno was
> carried over and overwrote the zeroed sync_seqno.
> 
> When wrap is handled, all outstanding requests will be retired and
> objects moved to inactive queue, causing their last_read_seqno to be zero.
> Use this to update the sync_seqno correctly.
> 
> RING_SYNC registers after wrap will contain pre wrap values which
> are >= seqno. So injecting the semaphore wait into ring completes
> immediately.
> 
> Original idea for using last_read_seqno from Chris Wilson.
> 
> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Queued for -next, thanks for the patch.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 85a0948..4ef8b57 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2397,7 +2397,11 @@  i915_gem_object_sync(struct drm_i915_gem_object *obj,
 
 	ret = to->sync_to(to, from, seqno);
 	if (!ret)
-		from->sync_seqno[idx] = seqno;
+		/* We use last_read_seqno because sync_to()
+		 * might have just caused seqno wrap under
+		 * the radar.
+		 */
+		from->sync_seqno[idx] = obj->last_read_seqno;
 
 	return ret;
 }