From: Ben Widawsky <benjamin.widaw...@intel.com>

This is just a cosmetic change to try to put do_switch_rcs on a diet. As
it stands, the function was quite complex, and error prone.

Signed-off-by: Ben Widawsky <b...@bwidawsk.net>
---
 drivers/gpu/drm/i915/i915_gem_context.c | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_context.c 
b/drivers/gpu/drm/i915/i915_gem_context.c
index a1dc885..9ab3dad 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -643,6 +643,24 @@ static int do_switch_xcs(struct intel_engine_cs *ring,
        return 0;
 }
 
+static void remap_l3(struct intel_engine_cs *ring,
+                    struct intel_context *ctx)
+{
+       int ret, i;
+
+       for (i = 0; i < MAX_L3_SLICES; i++) {
+               if (!(ctx->remap_slice & (1<<i)))
+                       continue;
+
+               ret = i915_gem_l3_remap(ring, i);
+               /* If it failed, try again next round */
+               if (ret)
+                       DRM_DEBUG_DRIVER("L3 remapping failed\n");
+               else
+                       ctx->remap_slice &= ~(1<<i);
+       }
+}
+
 static int do_switch_rcs(struct intel_engine_cs *ring,
                         struct intel_context *from,
                         struct intel_context *to)
@@ -651,7 +669,7 @@ static int do_switch_rcs(struct intel_engine_cs *ring,
        struct i915_hw_ppgtt *ppgtt = ctx_to_ppgtt(to);
        u32 hw_flags = 0;
        bool uninitialized = false;
-       int ret, i;
+       int ret;
 
        if (from != NULL) {
                BUG_ON(from->legacy_hw_ctx.rcs_state == NULL);
@@ -702,17 +720,7 @@ static int do_switch_rcs(struct intel_engine_cs *ring,
        if (ret)
                goto unpin_out;
 
-       for (i = 0; i < MAX_L3_SLICES; i++) {
-               if (!(to->remap_slice & (1<<i)))
-                       continue;
-
-               ret = i915_gem_l3_remap(ring, i);
-               /* If it failed, try again next round */
-               if (ret)
-                       DRM_DEBUG_DRIVER("L3 remapping failed\n");
-               else
-                       to->remap_slice &= ~(1<<i);
-       }
+       remap_l3(ring, to);
 
        /* The backing object for the context is done after switching to the
         * *next* context. Therefore we cannot retire the previous context until
-- 
1.9.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to