From patchwork Thu Apr 4 23:41:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 2395611 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 70B66DF25A for ; Thu, 4 Apr 2013 23:41:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 315A7E61AC for ; Thu, 4 Apr 2013 16:41:53 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from shiva.localdomain (209-20-75-48.static.cloud-ips.com [209.20.75.48]) by gabe.freedesktop.org (Postfix) with ESMTP id 04BA0E6203 for ; Thu, 4 Apr 2013 16:40:05 -0700 (PDT) Received: by shiva.localdomain (Postfix, from userid 1005) id B3C608862A; Thu, 4 Apr 2013 23:40:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on shiva.chad-versace.us X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=unavailable version=3.3.2 Received: from lundgren.nims.intel.com (jfdmzpr05-ext.jf.intel.com [134.134.139.74]) by shiva.localdomain (Postfix) with ESMTPSA id 0801088625; Thu, 4 Apr 2013 23:40:00 +0000 (UTC) From: Ben Widawsky To: intel-gfx@lists.freedesktop.org Date: Thu, 4 Apr 2013 16:41:50 -0700 Message-Id: <1365118914-15753-5-git-send-email-ben@bwidawsk.net> X-Mailer: git-send-email 1.8.2 In-Reply-To: <1365118914-15753-1-git-send-email-ben@bwidawsk.net> References: <1365118914-15753-1-git-send-email-ben@bwidawsk.net> Cc: Ben Widawsky Subject: [Intel-gfx] [PATCH 4/7] drm/i915: A bit better messaging for contexts X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Signed-off-by: Ben Widawsky --- drivers/gpu/drm/i915/i915_gem_context.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 8e218ad..5ac93f4 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -97,6 +97,11 @@ static int do_switch(struct i915_hw_context *to); +static inline bool is_default_context(struct i915_hw_context *ctx) +{ + return (ctx == ctx->ring->default_context); +} + static int get_context_size(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; @@ -124,8 +129,10 @@ static int get_context_size(struct drm_device *dev) static void do_destroy(struct i915_hw_context *ctx) { - if (ctx->file_priv) + if (ctx->file_priv) { + WARN_ON(!is_default_context(ctx)); idr_remove(&ctx->file_priv->context_idr, ctx->id); + } drm_gem_object_unreference(&ctx->obj->base); kfree(ctx); @@ -177,11 +184,6 @@ err_out: return ERR_PTR(ret); } -static inline bool is_default_context(struct i915_hw_context *ctx) -{ - return (ctx == ctx->ring->default_context); -} - /** * The default context needs to exist per ring that uses contexts. It stores the * context state of the GPU for applications that don't utilize HW contexts, as @@ -213,7 +215,7 @@ static int create_default_context(struct drm_i915_private *dev_priv) if (ret) goto err_unpin; - DRM_DEBUG_DRIVER("Default HW context loaded\n"); + DRM_DEBUG_DRIVER("Default HW context loaded (%p)\n", ctx); return 0; err_unpin: @@ -275,6 +277,7 @@ static int context_idr_cleanup(int id, void *p, void *data) BUG_ON(id == DEFAULT_CONTEXT_ID); + DRM_DEBUG_DRIVER("Context %d closed before destroy.\n", ctx->id); do_destroy(ctx); return 0; @@ -453,8 +456,11 @@ int i915_switch_context(struct intel_ring_buffer *ring, return -EINVAL; to = i915_gem_context_get(ring, file->driver_priv, to_id); - if (to == NULL) + if (unlikely(!to)) { + BUG_ON(to_id == DEFAULT_CONTEXT_ID); + DRM_DEBUG_DRIVER("Couldn't find context %d\n", to_id); return -ENOENT; + } return do_switch(to); } @@ -517,6 +523,6 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data, mutex_unlock(&dev->struct_mutex); - DRM_DEBUG_DRIVER("HW context %d destroyed\n", args->ctx_id); + DRM_DEBUG_DRIVER("User destroyed context %d\n", args->ctx_id); return 0; }