Message ID | 20180717141259.20841-1-chris@chris-wilson.co.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
diff --git a/drivers/gpu/drm/i915/selftests/mock_context.c b/drivers/gpu/drm/i915/selftests/mock_context.c index 8904f1ce64e3..23b8b254ef89 100644 --- a/drivers/gpu/drm/i915/selftests/mock_context.c +++ b/drivers/gpu/drm/i915/selftests/mock_context.c @@ -103,7 +103,14 @@ live_context(struct drm_i915_private *i915, struct drm_file *file) struct i915_gem_context * kernel_context(struct drm_i915_private *i915) { - return i915_gem_context_create_kernel(i915, I915_PRIORITY_NORMAL); + struct i915_gem_context *ctx; + + ctx = i915_gem_context_create_kernel(i915, I915_PRIORITY_NORMAL); + if (IS_ERR(ctx)) + return ctx; + + ctx->file_priv = ERR_PTR(-EPERM); /* !i915_is_ggtt() */ + return ctx; } void kernel_context_close(struct i915_gem_context *ctx)
i915_is_ggtt() uses the ctx->file_priv == NULL to determine if the context was allocation on behalf of the user, or by the kernel. Ordinarily, we only ever allocate one context by the kernel and this is used as the Global GTT, but for self testing we may want to create lots of internal contexts unconnected to struct files. These we ordinarily do not want to mistake for the GGTT, even when mocked there will only be a single mock GGTT. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> --- drivers/gpu/drm/i915/selftests/mock_context.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)