From patchwork Sun Feb 3 01:20:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 2085101 Return-Path: X-Original-To: patchwork-dri-devel@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 677E5DFB79 for ; Sun, 3 Feb 2013 01:23:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D4D3E61BD for ; Sat, 2 Feb 2013 17:23:37 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-da0-f53.google.com (mail-da0-f53.google.com [209.85.210.53]) by gabe.freedesktop.org (Postfix) with ESMTP id C53DCE611A for ; Sat, 2 Feb 2013 17:21:51 -0800 (PST) Received: by mail-da0-f53.google.com with SMTP id x6so2184837dac.40 for ; Sat, 02 Feb 2013 17:21:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=aHCCNqiGQWqifgPo3o+9uh6UgwJNXYq1V9J9YKPQgow=; b=xTcs3xushMFWnk62FAYriJMmpt9uAUtdRwDwi6caf6LwqwLy9TDoG2HwkB7HlM/kyR YS351XoCRtwyh8xCrtzyXUqZmm1zDmAQ6BlhdAPAAmWmns2Z2hOjUON4na+kaYOPlV3C i1xPcVLVxI9berivMEPOfvQswet4APS+FVpBUuFJgWAxN12EddlZCBklVvzVbkVdUvV2 i/vxGBktr6tPIkfbQvh0PlRQQ8n+WWrAR1cbUStBj1f03iaKRTL2MLCxPdzyvnlgRigj acST8kADFwQ6boOj3sX3x7v7bmmKoBwaXmehtRdmEVCSHKpy1h89Fgm/PCgMYFTCtc2a 6UXw== X-Received: by 10.68.231.137 with SMTP id tg9mr44080502pbc.45.1359854511323; Sat, 02 Feb 2013 17:21:51 -0800 (PST) Received: from htj.dyndns.org (c-69-181-251-227.hsd1.ca.comcast.net. [69.181.251.227]) by mx.google.com with ESMTPS id hs2sm13149467pbc.22.2013.02.02.17.21.49 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 02 Feb 2013 17:21:50 -0800 (PST) From: Tejun Heo To: akpm@linux-foundation.org Subject: [PATCH 17/62] drm/i915: convert to idr_alloc() Date: Sat, 2 Feb 2013 17:20:18 -0800 Message-Id: <1359854463-2538-18-git-send-email-tj@kernel.org> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1359854463-2538-1-git-send-email-tj@kernel.org> References: <1359854463-2538-1-git-send-email-tj@kernel.org> Cc: axboe@kernel.dk, skinsbursky@parallels.com, Daniel Vetter , rusty@rustcorp.com.au, jmorris@namei.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, bfields@fieldses.org, ebiederm@xmission.com, Tejun Heo X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Convert to the much saner new idr interface. Only compile tested. Signed-off-by: Tejun Heo Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel@lists.freedesktop.org Acked-by: Daniel Vetter --- This patch depends on an earlier idr changes and I think it would be best to route these together through -mm. Please holler if there's any objection. Thanks. drivers/gpu/drm/i915/i915_gem_context.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index a3f06bc..27e586a 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -144,7 +144,7 @@ create_hw_context(struct drm_device *dev, { struct drm_i915_private *dev_priv = dev->dev_private; struct i915_hw_context *ctx; - int ret, id; + int ret; ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); if (ctx == NULL) @@ -169,22 +169,11 @@ create_hw_context(struct drm_device *dev, ctx->file_priv = file_priv; -again: - if (idr_pre_get(&file_priv->context_idr, GFP_KERNEL) == 0) { - ret = -ENOMEM; - DRM_DEBUG_DRIVER("idr allocation failed\n"); - goto err_out; - } - - ret = idr_get_new_above(&file_priv->context_idr, ctx, - DEFAULT_CONTEXT_ID + 1, &id); - if (ret == 0) - ctx->id = id; - - if (ret == -EAGAIN) - goto again; - else if (ret) + ret = idr_alloc(&file_priv->context_idr, ctx, DEFAULT_CONTEXT_ID + 1, 0, + GFP_KERNEL); + if (ret < 0) goto err_out; + ctx->id = ret; return ctx;