89 #include <drm/i915_drm.h>
96 #define CONTEXT_ALIGN (64<<10)
135 BUG_ON(ctx != dev_priv->
ring[RCS].default_context);
137 drm_gem_object_unreference(&ctx->
obj->base);
156 DRM_DEBUG_DRIVER(
"Context object allocated failed\n");
167 if (file_priv ==
NULL)
175 DRM_DEBUG_DRIVER(
"idr allocation failed\n");
198 return (ctx == ctx->
ring->default_context);
211 BUG_ON(!mutex_is_locked(&dev_priv->
dev->struct_mutex));
213 ctx = create_hw_context(dev_priv->
dev,
NULL);
223 dev_priv->
ring[RCS].default_context =
ctx;
228 ret = do_switch(ctx);
232 DRM_DEBUG_DRIVER(
"Default HW context loaded\n");
254 dev_priv->
ring[RCS].default_context)
257 ctx_size = get_context_size(dev);
261 if (ctx_size <= 0 || ctx_size > (1<<20)) {
266 if (create_default_context(dev_priv)) {
271 DRM_DEBUG_DRIVER(
"HW context support initialized\n");
288 do_destroy(dev_priv->
ring[RCS].default_context);
291 static int context_idr_cleanup(
int id,
void *
p,
void *
data)
343 intel_ring_emit(ring,
MI_NOOP);
345 intel_ring_emit(ring,
MI_NOOP);
347 intel_ring_emit(ring, new_context->
obj->gtt_offset |
353 intel_ring_emit(ring,
MI_NOOP);
358 intel_ring_emit(ring,
MI_NOOP);
374 if (from_obj == to->
obj)
392 if (!to->
obj->has_global_gtt_mapping)
400 ret = mi_set_context(ring, to, hw_flags);
412 if (from_obj !=
NULL) {
427 drm_gem_object_unreference(&from_obj->
base);
430 drm_gem_object_reference(&to->
obj->base);
451 struct drm_file *
file,
460 if (ring != &dev_priv->
ring[RCS])
469 to = i915_gem_context_get(file->driver_priv, to_id);
474 return do_switch(to);
478 struct drm_file *
file)
486 if (!(dev->driver->driver_features & DRIVER_GEM))
496 ctx = create_hw_context(dev, file_priv);
502 DRM_DEBUG_DRIVER(
"HW context %d created\n", args->
ctx_id);
508 struct drm_file *
file)
515 if (!(dev->driver->driver_features & DRIVER_GEM))
522 ctx = i915_gem_context_get(file_priv, args->
ctx_id);
532 DRM_DEBUG_DRIVER(
"HW context %d destroyed\n", args->
ctx_id);