[Intel-gfx] [PATCH 5/7] drm/i915: Track context status

Ben Widawsky ben at bwidawsk.net
Fri Apr 5 01:41:52 CEST 2013


Instead of using just an is_initialized flag, it will be helpful to have
a bit more information about the context's actual status primarily for
the case when the file is closed before the context has actually be
destroyed.

Could also be useful for debugging.

Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
 drivers/gpu/drm/i915/i915_drv.h         | 4 +++-
 drivers/gpu/drm/i915/i915_gem_context.c | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index da071a0..25cdade 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -439,7 +439,9 @@ struct i915_hw_ppgtt {
 #define DEFAULT_CONTEXT_ID 0
 struct i915_hw_context {
 	int id;
-	bool is_initialized;
+	enum {
+		I915_CTX_INITIALIZED=1,
+	} status;
 	struct drm_i915_file_private *file_priv;
 	struct intel_ring_buffer *ring;
 	struct drm_i915_gem_object *obj;
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 8b2e73a..41be2a5 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -383,7 +383,7 @@ static int do_switch(struct i915_hw_context *to)
 	if (!to->obj->has_global_gtt_mapping)
 		i915_gem_gtt_bind_object(to->obj, to->obj->cache_level);
 
-	if (!to->is_initialized || is_default_context(to))
+	if (!to->status || is_default_context(to))
 		hw_flags |= MI_RESTORE_INHIBIT;
 	else if (WARN_ON_ONCE(from_obj == to->obj)) /* not yet expected */
 		hw_flags |= MI_FORCE_RESTORE;
@@ -419,7 +419,7 @@ static int do_switch(struct i915_hw_context *to)
 
 	drm_gem_object_reference(&to->obj->base);
 	ring->last_context_obj = to->obj;
-	to->is_initialized = true;
+	to->status = I915_CTX_INITIALIZED;
 
 	return 0;
 }
-- 
1.8.2




More information about the Intel-gfx mailing list