]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
drm/i915: make semaphore signaller detection more robust
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 18 Mar 2014 09:26:04 +0000 (10:26 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 1 Apr 2014 20:58:06 +0000 (22:58 +0200)
Extract all this logic into a new helper function
semaphore_wait_to_signaller_ring because:

- The current code has way too much magic.

- The current code doesn't look at bi16, which encodes VECS signallers
  on HSW. Those are just added after the fact, so can't be encoded in
  a neat formula.

- The current logic can't blow up since it limits its value range
  sufficiently, but that's a bit too tricky to rely on in my opinion.
  Especially when we start to add bdw support.

- I'm not a big fan of the explicit ring->semaphore_register list, but
  I think it's more robust to use the same mapping both when
  constructing the semaphore commands and when decoding them.

- Finally add a FIXME comment about lack of broadwell support here,
  like in the earlier ipehr semaphore cmd detection function.

Cc: Mika Kuoppala <mika.kuoppala@intel.com>
Cc: Ben Widawsky <ben@bwidawsk.net>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Mika Kuoppala <mika.kuoppala@intel.com>
[danvet: Actually drop the untrue claim in the commit message Chris
pointed out.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_irq.c

index 4be756f422ecd598d44e537f847a5cf923025b6d..c8d2445b259c722670b8991d5ae70091d50bc9e6 100644 (file)
@@ -2518,6 +2518,39 @@ ipehr_is_semaphore_wait(struct drm_device *dev, u32 ipehr)
        }
 }
 
+static struct intel_ring_buffer *
+semaphore_wait_to_signaller_ring(struct intel_ring_buffer *ring, u32 ipehr)
+{
+       struct drm_i915_private *dev_priv = ring->dev->dev_private;
+       struct intel_ring_buffer *signaller;
+       int i;
+
+       if (INTEL_INFO(dev_priv->dev)->gen >= 8) {
+               /*
+                * FIXME: gen8 semaphore support - currently we don't emit
+                * semaphores on bdw anyway, but this needs to be addressed when
+                * we merge that code.
+                */
+               return NULL;
+       } else {
+               u32 sync_bits = ipehr & MI_SEMAPHORE_SYNC_MASK;
+
+               for_each_ring(signaller, dev_priv, i) {
+                       if(ring == signaller)
+                               continue;
+
+                       if (sync_bits ==
+                           signaller->semaphore_register[ring->id])
+                               return signaller;
+               }
+       }
+
+       DRM_ERROR("No signaller ring found for ring %i, ipehr 0x%08x\n",
+                 ring->id, ipehr);
+
+       return NULL;
+}
+
 static struct intel_ring_buffer *
 semaphore_waits_for(struct intel_ring_buffer *ring, u32 *seqno)
 {
@@ -2558,7 +2591,7 @@ semaphore_waits_for(struct intel_ring_buffer *ring, u32 *seqno)
                return NULL;
 
        *seqno = ioread32(ring->virtual_start + head + 4) + 1;
-       return &dev_priv->ring[(ring->id + (((ipehr >> 17) & 1) + 1)) % 3];
+       return semaphore_wait_to_signaller_ring(ring, ipehr);
 }
 
 static int semaphore_passed(struct intel_ring_buffer *ring)