drm/i915: Add intel_ring_handle_seqno wrap
authorMika Kuoppala <mika.kuoppala@linux.intel.com>
Tue, 4 Dec 2012 13:12:04 +0000 (15:12 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 6 Dec 2012 12:14:34 +0000 (13:14 +0100)
If there are pre-wrap values in semaphore-mbox registers after wrap,
syncing against some after-wrap request will complete immediately.
Fix this by emitting ring commands to set mbox registers to zero
when the wrap happens.

v2: Use __intel_ring_begin to emit ring commands, from
Chris Wilson.

Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
[danvet: Add a small comment to handle_seqno_wrap.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/intel_ringbuffer.c
drivers/gpu/drm/i915/intel_ringbuffer.h

index cb941448c2bc3de4b72f6950d33c0edf6ecceb4c..02d315164aa94e5a462f5416be94d7bc1c54c93e 100644 (file)
@@ -1952,6 +1952,10 @@ i915_gem_handle_seqno_wrap(struct drm_device *dev)
 
        i915_gem_retire_requests(dev);
        for_each_ring(ring, dev_priv, i) {
+               ret = intel_ring_handle_seqno_wrap(ring);
+               if (ret)
+                       return ret;
+
                for (j = 0; j < ARRAY_SIZE(ring->sync_seqno); j++)
                        ring->sync_seqno[j] = 0;
        }
index 01a660a7c16701034ab4bb6355d8f9c8ff90610a..0d03dc649c5ef4e8dcc7ac9f04959882635deb36 100644 (file)
@@ -1402,6 +1402,28 @@ int intel_ring_begin(struct intel_ring_buffer *ring,
        return __intel_ring_begin(ring, num_dwords * sizeof(uint32_t));
 }
 
+int intel_ring_handle_seqno_wrap(struct intel_ring_buffer *ring)
+{
+       int ret;
+
+       BUG_ON(ring->outstanding_lazy_request);
+
+       if (INTEL_INFO(ring->dev)->gen < 6)
+               return 0;
+
+       ret = __intel_ring_begin(ring, 6 * sizeof(uint32_t));
+       if (ret)
+               return ret;
+
+       /* Leaving a stale, pre-wrap seqno behind in the mboxes will result in
+        * post-wrap semaphore waits completing immediately. Clear them. */
+       update_mboxes(ring, ring->signal_mbox[0]);
+       update_mboxes(ring, ring->signal_mbox[1]);
+       intel_ring_advance(ring);
+
+       return 0;
+}
+
 void intel_ring_advance(struct intel_ring_buffer *ring)
 {
        struct drm_i915_private *dev_priv = ring->dev->dev_private;
index d4b7416fa1b014b722e479e8d63d0f381448dba7..b4a533e53fd1f718d50785adfcceefca6d0518f9 100644 (file)
@@ -196,7 +196,7 @@ static inline void intel_ring_emit(struct intel_ring_buffer *ring,
 }
 void intel_ring_advance(struct intel_ring_buffer *ring);
 int __must_check intel_ring_idle(struct intel_ring_buffer *ring);
-
+int __must_check intel_ring_handle_seqno_wrap(struct intel_ring_buffer *ring);
 int intel_ring_flush_all_caches(struct intel_ring_buffer *ring);
 int intel_ring_invalidate_all_caches(struct intel_ring_buffer *ring);