From patchwork Sun Feb 3 01:20:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 2085741 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 5DFF13FD2B for ; Sun, 3 Feb 2013 01:31:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753641Ab3BCBWG (ORCPT ); Sat, 2 Feb 2013 20:22:06 -0500 Received: from mail-pa0-f48.google.com ([209.85.220.48]:36193 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753613Ab3BCBWD (ORCPT ); Sat, 2 Feb 2013 20:22:03 -0500 Received: by mail-pa0-f48.google.com with SMTP id fa1so2781459pad.21 for ; Sat, 02 Feb 2013 17:22:03 -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=XLDmiVHi7RPotpKef7mbTzsQ9VxKqTJOYDDuGV5Uiog=; b=ca1vBhg93UrfYHpr50oJfo5eHB65sZ4VTnldNt5DYiaZXffIWSYX2ubyaGNrphOG8B oSCQXD5Mttdg+b2KM9w8Frld8V275BoiUskd2O49b+gzUlSTLBmkdDxHU8owwgcI1lBn hZBxvZWeLor/eFdfFqgtt0ZmYNsmo+bMiF1hfEOZNYaYTe+KXrjRv8Gaw9Z9n7VH2g3h ZYiv1Np3LY5uty0WLKUAwrO4PDbkgN2vPpkFEK/IyB26H9HZClPw7PdRGP+/aoSfZZEe c1P871Q//GN5p09xBrEbTDvCFvdzidFzbLmt5DLNiXIvPlFY+wPTfF7QVJqigSer1zkZ UxnA== X-Received: by 10.68.203.198 with SMTP id ks6mr44085388pbc.35.1359854523042; Sat, 02 Feb 2013 17:22:03 -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.01 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 02 Feb 2013 17:22:02 -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 , Tom Tucker , Steve Wise , linux-rdma@vger.kernel.org Subject: [PATCH 23/62] infiniband/amso1100: convert to idr_alloc() Date: Sat, 2 Feb 2013 17:20:24 -0800 Message-Id: <1359854463-2538-24-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: Tom Tucker 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/amso1100/c2_qp.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/infiniband/hw/amso1100/c2_qp.c b/drivers/infiniband/hw/amso1100/c2_qp.c index 28cd5cb..0ab826b 100644 --- a/drivers/infiniband/hw/amso1100/c2_qp.c +++ b/drivers/infiniband/hw/amso1100/c2_qp.c @@ -382,14 +382,17 @@ static int c2_alloc_qpn(struct c2_dev *c2dev, struct c2_qp *qp) { int ret; - do { - spin_lock_irq(&c2dev->qp_table.lock); - ret = idr_get_new_above(&c2dev->qp_table.idr, qp, - c2dev->qp_table.last++, &qp->qpn); - spin_unlock_irq(&c2dev->qp_table.lock); - } while ((ret == -EAGAIN) && - idr_pre_get(&c2dev->qp_table.idr, GFP_KERNEL)); - return ret; + idr_preload(GFP_KERNEL); + spin_lock_irq(&c2dev->qp_table.lock); + + ret = idr_alloc(&c2dev->qp_table.idr, qp, c2dev->qp_table.last++, 0, + GFP_NOWAIT); + if (ret >= 0) + qp->qpn = ret; + + spin_unlock_irq(&c2dev->qp_table.lock); + idr_preload_end(); + return ret < 0 ? ret : 0; } static void c2_free_qpn(struct c2_dev *c2dev, int qpn)