drm/i915: Moved the for_each_ring loop outside of i915_gem_context_enable()
authorJohn Harrison <John.C.Harrison@Intel.com>
Fri, 29 May 2015 16:43:37 +0000 (17:43 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 23 Jun 2015 12:02:06 +0000 (14:02 +0200)
The start of day context initialisation code in i915_gem_context_enable() loops
over each ring and calls the legacy switch context or the execlist init context
code as appropriate.

This patch moves the ring looping out of that function in to the top level
caller i915_gem_init_hw(). This means the a single pass can be made over all
rings doing the PPGTT, L3 remap and context initialisation of each ring
altogether.

For: VIZ-5115
Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
Reviewed-by: Tomas Elf <tomas.elf@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_gem_context.c

index 104893bea2f1f95e4e6368878d310b3f52436131..198e681639b71fea09beb9a55225bd08bd7fcc0a 100644 (file)
@@ -3039,7 +3039,7 @@ int __must_check i915_gem_context_init(struct drm_device *dev);
 void i915_gem_context_fini(struct drm_device *dev);
 void i915_gem_context_reset(struct drm_device *dev);
 int i915_gem_context_open(struct drm_device *dev, struct drm_file *file);
-int i915_gem_context_enable(struct drm_i915_private *dev_priv);
+int i915_gem_context_enable(struct intel_engine_cs *ring);
 void i915_gem_context_close(struct drm_device *dev, struct drm_file *file);
 int i915_switch_context(struct intel_engine_cs *ring,
                        struct intel_context *to);
index 9522e861a733d697531a8c460a451ef699cf26c0..a580593f586e60016842b6609b856bbbc85e6d2b 100644 (file)
@@ -5052,6 +5052,8 @@ i915_gem_init_hw(struct drm_device *dev)
         */
        init_unused_rings(dev);
 
+       BUG_ON(!dev_priv->ring[RCS].default_context);
+
        ret = i915_ppgtt_init_hw(dev);
        if (ret) {
                DRM_ERROR("PPGTT enable HW failed %d\n", ret);
@@ -5067,6 +5069,8 @@ i915_gem_init_hw(struct drm_device *dev)
 
        /* Now it is safe to go back round and do everything else: */
        for_each_ring(ring, dev_priv, i) {
+               WARN_ON(!ring->default_context);
+
                if (ring->id == RCS) {
                        for (j = 0; j < NUM_L3_SLICES(dev); j++)
                                i915_gem_l3_remap(ring, j);
@@ -5078,14 +5082,13 @@ i915_gem_init_hw(struct drm_device *dev)
                        i915_gem_cleanup_ringbuffer(dev);
                        goto out;
                }
-       }
 
-       ret = i915_gem_context_enable(dev_priv);
-       if (ret && ret != -EIO) {
-               DRM_ERROR("Context enable failed %d\n", ret);
-               i915_gem_cleanup_ringbuffer(dev);
-
-               goto out;
+               ret = i915_gem_context_enable(ring);
+               if (ret && ret != -EIO) {
+                       DRM_ERROR("Context enable ring #%d failed %d\n", i, ret);
+                       i915_gem_cleanup_ringbuffer(dev);
+                       goto out;
+               }
        }
 
 out:
index 133afcf4d79e4d64777b8e694af5b42a861ac757..9687d00c4b920d64773e00a0c43fda9bd7003765 100644 (file)
@@ -409,32 +409,22 @@ void i915_gem_context_fini(struct drm_device *dev)
        i915_gem_context_unreference(dctx);
 }
 
-int i915_gem_context_enable(struct drm_i915_private *dev_priv)
+int i915_gem_context_enable(struct intel_engine_cs *ring)
 {
-       struct intel_engine_cs *ring;
-       int ret, i;
-
-       BUG_ON(!dev_priv->ring[RCS].default_context);
+       int ret;
 
        if (i915.enable_execlists) {
-               for_each_ring(ring, dev_priv, i) {
-                       if (ring->init_context) {
-                               ret = ring->init_context(ring,
-                                               ring->default_context);
-                               if (ret) {
-                                       DRM_ERROR("ring init context: %d\n",
-                                                       ret);
-                                       return ret;
-                               }
-                       }
-               }
+               if (ring->init_context == NULL)
+                       return 0;
 
+               ret = ring->init_context(ring, ring->default_context);
        } else
-               for_each_ring(ring, dev_priv, i) {
-                       ret = i915_switch_context(ring, ring->default_context);
-                       if (ret)
-                               return ret;
-               }
+               ret = i915_switch_context(ring, ring->default_context);
+
+       if (ret) {
+               DRM_ERROR("ring init context: %d\n", ret);
+               return ret;
+       }
 
        return 0;
 }