From patchwork Sun Feb 3 01:20:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 2085421 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 35A7E3FD2B for ; Sun, 3 Feb 2013 01:25:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2E62CE5F7F for ; Sat, 2 Feb 2013 17:25:52 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pb0-f41.google.com (mail-pb0-f41.google.com [209.85.160.41]) by gabe.freedesktop.org (Postfix) with ESMTP id CAC0CE607A for ; Sat, 2 Feb 2013 17:21:56 -0800 (PST) Received: by mail-pb0-f41.google.com with SMTP id ro12so2677995pbb.0 for ; Sat, 02 Feb 2013 17:21:56 -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=ipTHPqKfifTXUpImSKl1/FeDvGiUu6PBwC1ylfQmEFc=; b=q2WsnnLN5VQh64yGKxhBzlM0se1XwCzzJKWBx9/UzsmhfDKncqnyBYWLQ2dCPfThAi 3RsArrLMdcEMNgCdj6HTmmHj00NB9hPmNq3ECOhWzFufnTgdnVaL9aP6LrEizcW2H3IZ zu1L53/grFrVeF2I6w+14CIdlm+k9EsZnhZmZGjQ5C1lfrrcQMSp8vv39iGUntwO2hTC ogyzvwpjILN4LCx0xUljqp7TNYXu/Jehh7S4Aovw88/Lol4ouMT98mWa9s9JJSmmzmli XyXMDeFEuijyEiuDXiu+Xo1Kikt+SiniWEB0ogvfyy8OhtxmcHO7N6np2H8dL8NFzKJo cmwg== X-Received: by 10.66.81.166 with SMTP id b6mr41214978pay.7.1359854516655; Sat, 02 Feb 2013 17:21:56 -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.54 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 02 Feb 2013 17:21:56 -0800 (PST) From: Tejun Heo To: akpm@linux-foundation.org Subject: [PATCH 20/62] drm/vmwgfx: convert to idr_alloc() Date: Sat, 2 Feb 2013 17:20:21 -0800 Message-Id: <1359854463-2538-21-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, 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: dri-devel@lists.freedesktop.org --- 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/vmwgfx/vmwgfx_resource.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c index e01a17b..c9d0676 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c @@ -177,17 +177,16 @@ int vmw_resource_alloc_id(struct vmw_resource *res) BUG_ON(res->id != -1); - do { - if (unlikely(idr_pre_get(idr, GFP_KERNEL) == 0)) - return -ENOMEM; - - write_lock(&dev_priv->resource_lock); - ret = idr_get_new_above(idr, res, 1, &res->id); - write_unlock(&dev_priv->resource_lock); + idr_preload(GFP_KERNEL); + write_lock(&dev_priv->resource_lock); - } while (ret == -EAGAIN); + ret = idr_alloc(idr, res, 1, 0, GFP_NOWAIT); + if (ret >= 0) + res->id = ret; - return ret; + write_unlock(&dev_priv->resource_lock); + idr_preload_end(); + return ret < 0 ? ret : 0; } /**