From patchwork Sat Feb 26 18:30:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 592711 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1QIbUYv010240 for ; Sat, 26 Feb 2011 18:37:51 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 604EC9E970 for ; Sat, 26 Feb 2011 10:37:30 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=KH85uN4nZU8pXvbF5BztqW1JVuODmwx+n1oKGY2gwcQ=; b=VP23eGYUnn5YyBKXivHJJGjh2tNtYsxvJXlhgaQEb/k0PqZRlOxjZvinnT7CXw4ih3 3m1T229YKMrkxx/sW2kqX12fg08y3vEBkMNVbzfmmgx0ccQ6W83NDh7iwk5uZFUymx3w F81UBvyv2yEh/w/VacusF/z3oQxW9JbpF6unI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=WkkDnwbXnh8/nimTZSHbAL32Boq0MqucuPd9FaUWf5/H3oouH4rF+/fHO0vy/WiSMR DSVwjtgy/X9rFqE2t3bp7kcs0ntfiRnXsL/fsJndhKZoTcdgeOFeuJvN7+PntxxEZa+b M6vZ03x3pGZUwicOpmGClMWuEQmGrG68+iafg= Received: by 10.42.223.65 with SMTP id ij1mr2503461icb.349.1298745038175; Sat, 26 Feb 2011 10:30:38 -0800 (PST) Received: from localhost.localdomain ([67.208.96.87]) by mx.google.com with ESMTPS id wd12sm1519339icb.17.2011.02.26.10.30.36 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 26 Feb 2011 10:30:37 -0800 (PST) From: Ben Widawsky To: intel-gfx@lists.freedesktop.org Date: Sat, 26 Feb 2011 10:30:14 -0800 Message-Id: <1298745018-5937-5-git-send-email-bwidawsk@gmail.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1298745018-5937-1-git-send-email-bwidawsk@gmail.com> References: <1298745018-5937-1-git-send-email-bwidawsk@gmail.com> Subject: [Intel-gfx] [RFC] [PATCH 4/8] drm/i915/context: logical context free X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.11 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 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sat, 26 Feb 2011 18:37:51 +0000 (UTC) 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 */