@@ -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;
@@ -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;
}
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@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(-)