From: Ben Widawsky Subject: [PATCH 10/11] drm/i915/context: track contexts per device Date: Tue, 14 Feb 2012 22:09:17 +0100 Message-ID: <1329253758-24943-11-git-send-email-ben@bwidawsk.net> References: <1329253758-24943-1-git-send-email-ben@bwidawsk.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from cloud01.chad-versace.us (184-106-247-128.static.cloud-ips.com [184.106.247.128]) by gabe.freedesktop.org (Postfix) with ESMTP id AB3DD9E709 for ; Tue, 14 Feb 2012 13:10:59 -0800 (PST) In-Reply-To: <1329253758-24943-1-git-send-email-ben@bwidawsk.net> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: intel-gfx@lists.freedesktop.org Cc: Ben Widawsky List-Id: intel-gfx@lists.freedesktop.org Nice to have a list of contexts handy for debug and perhaps other things in the future. Signed-off-by: Ben Widawsky --- 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