From: Ben Widawsky Subject: [RFC] [PATCH 4/8] drm/i915/context: logical context free Date: Sat, 26 Feb 2011 10:30:14 -0800 Message-ID: <1298745018-5937-5-git-send-email-bwidawsk@gmail.com> References: <1298745018-5937-1-git-send-email-bwidawsk@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-iy0-f177.google.com (mail-iy0-f177.google.com [209.85.210.177]) by gabe.freedesktop.org (Postfix) with ESMTP id 5FDA09E7BE for ; Sat, 26 Feb 2011 10:30:38 -0800 (PST) Received: by mail-iy0-f177.google.com with SMTP id 40so1907628iyf.36 for ; Sat, 26 Feb 2011 10:30:38 -0800 (PST) In-Reply-To: <1298745018-5937-1-git-send-email-bwidawsk@gmail.com> 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 List-Id: intel-gfx@lists.freedesktop.org Another review only commit. The opposite of context alloc is context free. Context free needs to employ context_fini (the opposite of context init) which will switch back to the default context if needed. This function is not currently implemented. --- drivers/gpu/drm/i915/i915_context.c | 37 +++++++++++++++++++++++++++++++++++ 1 files changed, 37 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_context.c b/drivers/gpu/drm/i915/i915_context.c index 490aa5a..babceca 100644 --- a/drivers/gpu/drm/i915/i915_context.c +++ b/drivers/gpu/drm/i915/i915_context.c @@ -180,6 +180,43 @@ id_out: return ret; } +static void logical_context_fini(struct drm_i915_gem_context *ctx) +{ + +} + +static int logical_context_free(struct drm_file *file, uint32_t id) +{ + struct drm_i915_gem_context *ctx; + + if (WARN_ON(id == DEFAULT_CONTEXT_ID)) + return 0; + + /* ref and pin the object */ + ctx = i915_get_context(file, id); + if (!ctx) { + DRM_ERROR("Couldn't find context %d", id); + return -EINVAL; + } + + i915_release_context(ctx); + + mutex_lock(&ctx->dev->struct_mutex); + + logical_context_fini(ctx); + drm_gem_object_unreference(&ctx->obj->base); + + mutex_unlock(&ctx->dev->struct_mutex); + + context_destroy_id(ctx); + + ctx->file = NULL; + ctx->dev = NULL; + kfree(ctx); + + return 0; +} + /** * i915_context_create_ioctl() - not yet supported */ -- 1.7.3.4