Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915: Refactor out intel_context_init()

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

+12 -10
+2 -5
drivers/gpu/drm/i915/i915_gem_context.c
··· 338 338 ctx->i915 = dev_priv; 339 339 ctx->sched.priority = I915_USER_PRIORITY(I915_PRIORITY_NORMAL); 340 340 341 - for (n = 0; n < ARRAY_SIZE(ctx->__engine); n++) { 342 - struct intel_context *ce = &ctx->__engine[n]; 343 - 344 - ce->gem_context = ctx; 345 - } 341 + for (n = 0; n < ARRAY_SIZE(ctx->__engine); n++) 342 + intel_context_init(&ctx->__engine[n], ctx, dev_priv->engine[n]); 346 343 347 344 INIT_RADIX_TREE(&ctx->handles_vma, GFP_KERNEL); 348 345 INIT_LIST_HEAD(&ctx->handles_list);
+8
drivers/gpu/drm/i915/i915_gem_context.h
··· 364 364 kref_put(&ctx->ref, i915_gem_context_release); 365 365 } 366 366 367 + static inline void 368 + intel_context_init(struct intel_context *ce, 369 + struct i915_gem_context *ctx, 370 + struct intel_engine_cs *engine) 371 + { 372 + ce->gem_context = ctx; 373 + } 374 + 367 375 #endif /* !__I915_GEM_CONTEXT_H__ */
+2 -5
drivers/gpu/drm/i915/selftests/mock_context.c
··· 45 45 INIT_LIST_HEAD(&ctx->handles_list); 46 46 INIT_LIST_HEAD(&ctx->hw_id_link); 47 47 48 - for (n = 0; n < ARRAY_SIZE(ctx->__engine); n++) { 49 - struct intel_context *ce = &ctx->__engine[n]; 50 - 51 - ce->gem_context = ctx; 52 - } 48 + for (n = 0; n < ARRAY_SIZE(ctx->__engine); n++) 49 + intel_context_init(&ctx->__engine[n], ctx, i915->engine[n]); 53 50 54 51 ret = i915_gem_context_pin_hw_id(ctx); 55 52 if (ret < 0)