[Intel-gfx] [PATCH] drm/i915: extract common ce->pin_count check

Daniele Ceraolo Spurio daniele.ceraolospurio at intel.com
Mon Oct 1 21:34:38 UTC 2018



On 01/10/18 14:09, Chris Wilson wrote:
> Quoting Daniele Ceraolo Spurio (2018-10-01 21:46:56)
>> We already have it coded 3 times and a 4th one is coming for the GuC
>> path in an upcoming patch, so let's move it to a common place.
> 
> Nope. It is separate as virtual engine does not follow the same pattern.
> -Chris
> 

Would it be worth adding virtual engine knowledge to to_intel_context()?

e.g.:

static inline struct intel_context *
to_intel_context(struct i915_gem_context *ctx,
		 const struct intel_engine_cs *engine)
{
	if (intel_engine_is_virtual(engine)) {
		struct virtual_engine *ve = to_virtual_engine(engine);
		return &ve->context;
	} else {
		return &ctx->__engine[engine->id];
	}
}

Maybe a bit overkill, but having the same check repeated in 5 versions 
of *_context_pin() really bugs me :P

Daniele


More information about the Intel-gfx mailing list