[Intel-gfx] [PATCH 1/2] drm/i915/selftests: Mark mock contexts as being !GGTT

Chris Wilson chris at chris-wilson.co.uk
Tue Jul 17 14:12:58 UTC 2018


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 at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/selftests/mock_context.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

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)
-- 
2.18.0



More information about the Intel-gfx mailing list