[Intel-gfx] [PATCH 10/11] drm/i915/context: track contexts per device
Ben Widawsky
ben at bwidawsk.net
Tue Feb 14 22:09:17 CET 2012
Nice to have a list of contexts handy for debug and perhaps other things
in the future.
Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
---
drivers/gpu/drm/i915/i915_context.c | 8 ++++++--
drivers/gpu/drm/i915/i915_drv.h | 3 +++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_context.c b/drivers/gpu/drm/i915/i915_context.c
index 0547411..93a3822 100644
--- a/drivers/gpu/drm/i915/i915_context.c
+++ b/drivers/gpu/drm/i915/i915_context.c
@@ -193,11 +193,13 @@ static int logical_context_alloc(struct drm_device *dev, struct drm_file *file,
if (!ret)
ctx->ring_enable |= (1 << RCS);
- if (ctx->ring_enable)
+ if (ctx->ring_enable) {
DRM_DEBUG_DRIVER("Context %d allocated, rings %x\n", ctx->id,
ctx->ring_enable);
- else
+ list_add(&ctx->context_link, &dev_priv->context_list);
+ } else {
ctx = NULL;
+ }
*ctx_out = ctx;
return 0;
@@ -298,6 +300,7 @@ static int logical_context_free(struct drm_file *file, uint32_t id)
BUG_ON(ctx->obj->pin_count > 1);
drm_gem_object_unreference(&ctx->obj->base);
+ list_del(&ctx->context_link);
context_destroy_id(ctx);
@@ -404,6 +407,7 @@ void i915_context_load(struct drm_device *dev)
size = roundup(size, 4096);
dev_priv->context_size = size;
DRM_DEBUG_DRIVER("Logical context size = %d\n", size);
+ INIT_LIST_HEAD(&dev_priv->context_list);
ret = logical_context_alloc(dev, NULL, &dev_priv->default_context);
if (ret)
dev_priv->contexts_disabled = true;
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 13e088f..165a5a5 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -765,6 +765,7 @@ typedef struct drm_i915_private {
uint32_t context_size;
struct drm_i915_gem_context *default_context;
bool contexts_disabled;
+ struct list_head context_list;
} drm_i915_private_t;
enum i915_cache_level {
@@ -968,6 +969,8 @@ struct drm_i915_gem_context {
struct drm_i915_gem_object *obj;
bool is_default;
bool is_initialized;
+
+ struct list_head context_link;
};
#define I915_CONTEXT_NORMAL_SWITCH (1 << 0)
--
1.7.9
More information about the Intel-gfx
mailing list