From patchwork Sun Feb 3 01:20:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 2085751 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 12C2F3FD2B for ; Sun, 3 Feb 2013 01:31:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753762Ab3BCBby (ORCPT ); Sat, 2 Feb 2013 20:31:54 -0500 Received: from mail-da0-f43.google.com ([209.85.210.43]:49055 "EHLO mail-da0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753646Ab3BCBWG (ORCPT ); Sat, 2 Feb 2013 20:22:06 -0500 Received: by mail-da0-f43.google.com with SMTP id u36so2188585dak.2 for ; Sat, 02 Feb 2013 17:22:06 -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=MtC1heOL8Xp7xQXVXhjxZa0zo+g08MOJjMfw91aERFY=; b=Haw7bSAqBkDY1LUp64tQDcB2Mwrif1UpnSFKYaiUX4hirNMK1SY9MyX7Fz7wT1nZYw eNKHA9pk5c6k9lwKaXqacz6HV5AauxlcPAdDDLvh12e5aybOun+LOgur1lMs4FpPwzUq 0cIXbVzg4yqqZ0F7YJlp5Gf7/UVNOUltHcGW7wUGEoN/2HPMKRJzqcBJiuD9tdZpooLN nBCtVxSDNYCch9wzQaRf/Rj1QKNfvJ8znHmbaFQEs8uYEbGIR9k8mINckOCtev4UBpIq 64MntEmxHcozMfzT+jjpURXZQRJJisYezrDyxBAl3Czm2suy6wlYnutkjna8IVoh8r8T tt8g== X-Received: by 10.68.220.197 with SMTP id py5mr43777138pbc.13.1359854526260; Sat, 02 Feb 2013 17:22:06 -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.22.04 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 02 Feb 2013 17:22:05 -0800 (PST) From: Tejun Heo To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, rusty@rustcorp.com.au, bfields@fieldses.org, skinsbursky@parallels.com, ebiederm@xmission.com, jmorris@namei.org, axboe@kernel.dk, Tejun Heo , Steve Wise , linux-rdma@vger.kernel.org Subject: [PATCH 25/62] infiniband/cxgb4: convert to idr_alloc() Date: Sat, 2 Feb 2013 17:20:26 -0800 Message-Id: <1359854463-2538-26-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> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Convert to the much saner new idr interface. Only compile tested. Signed-off-by: Tejun Heo Cc: Steve Wise Cc: linux-rdma@vger.kernel.org Reviewed-by: Steve Wise --- 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/infiniband/hw/cxgb4/iw_cxgb4.h | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h index 9c1644f..7f862da 100644 --- a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h +++ b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h @@ -260,20 +260,21 @@ static inline int _insert_handle(struct c4iw_dev *rhp, struct idr *idr, void *handle, u32 id, int lock) { int ret; - int newid; - do { - if (!idr_pre_get(idr, lock ? GFP_KERNEL : GFP_ATOMIC)) - return -ENOMEM; - if (lock) - spin_lock_irq(&rhp->lock); - ret = idr_get_new_above(idr, handle, id, &newid); - BUG_ON(!ret && newid != id); - if (lock) - spin_unlock_irq(&rhp->lock); - } while (ret == -EAGAIN); - - return ret; + if (lock) { + idr_preload(GFP_KERNEL); + spin_lock_irq(&rhp->lock); + } + + ret = idr_alloc(idr, handle, id, id + 1, GFP_ATOMIC); + + if (lock) { + spin_unlock_irq(&rhp->lock); + idr_preload_end(); + } + + BUG_ON(ret == -ENOSPC); + return ret < 0 ? ret : 0; } static inline int insert_handle(struct c4iw_dev *rhp, struct idr *idr,