drm/i915: Refactor out intel_context_init()
authorChris Wilson <chris@chris-wilson.co.uk>
Mon, 21 Jan 2019 22:20:50 +0000 (22:20 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Tue, 22 Jan 2019 13:13:53 +0000 (13:13 +0000)
Prior to adding a third instance of intel_context_init() and extending
the information stored therewithin, refactor out the common assignments.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190121222117.23305-8-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_gem_context.c
drivers/gpu/drm/i915/i915_gem_context.h
drivers/gpu/drm/i915/selftests/mock_context.c

index b68b4345d7be0d4ed50cdf0783b0c39a78ef1470..71d5ca059ee69de81086c875fc3ef5e8057a64b6 100644 (file)
@@ -338,11 +338,8 @@ __create_hw_context(struct drm_i915_private *dev_priv,
        ctx->i915 = dev_priv;
        ctx->sched.priority = I915_USER_PRIORITY(I915_PRIORITY_NORMAL);
 
-       for (n = 0; n < ARRAY_SIZE(ctx->__engine); n++) {
-               struct intel_context *ce = &ctx->__engine[n];
-
-               ce->gem_context = ctx;
-       }
+       for (n = 0; n < ARRAY_SIZE(ctx->__engine); n++)
+               intel_context_init(&ctx->__engine[n], ctx, dev_priv->engine[n]);
 
        INIT_RADIX_TREE(&ctx->handles_vma, GFP_KERNEL);
        INIT_LIST_HEAD(&ctx->handles_list);
index f6d870b1f73e397971e4f55714d8524f68220395..47d82ce7ba6a6cb9e10081bc6b5344123ff3e3b0 100644 (file)
@@ -364,4 +364,12 @@ static inline void i915_gem_context_put(struct i915_gem_context *ctx)
        kref_put(&ctx->ref, i915_gem_context_release);
 }
 
+static inline void
+intel_context_init(struct intel_context *ce,
+                  struct i915_gem_context *ctx,
+                  struct intel_engine_cs *engine)
+{
+       ce->gem_context = ctx;
+}
+
 #endif /* !__I915_GEM_CONTEXT_H__ */
index d937bdff26f99cec944a4550f02fddd3ad482772..b646cdcdd6029a95bace9ed5f537abcf28464abb 100644 (file)
@@ -45,11 +45,8 @@ mock_context(struct drm_i915_private *i915,
        INIT_LIST_HEAD(&ctx->handles_list);
        INIT_LIST_HEAD(&ctx->hw_id_link);
 
-       for (n = 0; n < ARRAY_SIZE(ctx->__engine); n++) {
-               struct intel_context *ce = &ctx->__engine[n];
-
-               ce->gem_context = ctx;
-       }
+       for (n = 0; n < ARRAY_SIZE(ctx->__engine); n++)
+               intel_context_init(&ctx->__engine[n], ctx, i915->engine[n]);
 
        ret = i915_gem_context_pin_hw_id(ctx);
        if (ret < 0)