From patchwork Wed Mar 27 13:18:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 2350651 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 3C305DFE82 for ; Wed, 27 Mar 2013 13:19:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750960Ab3C0NTW (ORCPT ); Wed, 27 Mar 2013 09:19:22 -0400 Received: from mail-oa0-f43.google.com ([209.85.219.43]:58713 "EHLO mail-oa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752498Ab3C0NSV (ORCPT ); Wed, 27 Mar 2013 09:18:21 -0400 Received: by mail-oa0-f43.google.com with SMTP id l10so8705302oag.2 for ; Wed, 27 Mar 2013 06:18:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=EbAP5AqGTCz5s1XEFa7YbuYUL28PhT+EzeYwsoQ7LbE=; b=VUCaEq87QD7o2aGioShaFRfFFIzMch9zxblcqIPpeyLuK3AN17EMg0cbrsRhW0twXa 2A3a2PWUfIBKU6crRXqmI3ImCVDVohxQogbtFYvG2LUfvWuTfoGsxY+D5wExuVOFABtk w7sa7LjfIKb8ar5Fyde62I6ApVU9uvKaTTsFS1FLDa9zEvL6L1f6Y3dzgExw0btkQS2F aRhqSjcBSeoW7xzQYMnjOHHxGpWrE3x8LV/qkBGvZPE4NDIpooLBwhzD1ZSVBiYQiuLi wb1TDF0Mk2akt/QoIFhvNeun2RUtwyYUIEvcvBFSKkDquKfVilk2RwsYsKajb/HOwPBT EO8g== X-Received: by 10.60.2.164 with SMTP id 4mr14989992oev.85.1364390301020; Wed, 27 Mar 2013 06:18:21 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-107-015-113-143.nc.res.rr.com. [107.15.113.143]) by mx.google.com with ESMTPS id zc8sm14103721obc.8.2013.03.27.06.18.19 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 27 Mar 2013 06:18:20 -0700 (PDT) From: Jeff Layton To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, tj@kernel.org, Jack Morgenstein , Or Gerlitz , Roland Dreier , linux-rdma@vger.kernel.org Subject: [PATCH v1 3/6] mlx4: convert to using idr_alloc_cyclic Date: Wed, 27 Mar 2013 09:18:05 -0400 Message-Id: <1364390288-30968-4-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1364390288-30968-1-git-send-email-jlayton@redhat.com> References: <1364390288-30968-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQmctH2gdtD48rclsuOVEMfzQaBgaU77rFWajCNREWDPnR/L3uguK5Ccbwb7dqSe/DUVgBuL Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org (Note: compile tested only) Signed-off-by: Jeff Layton Cc: Tejun Heo Cc: Jack Morgenstein Cc: Or Gerlitz Cc: Roland Dreier Cc: linux-rdma@vger.kernel.org --- drivers/infiniband/hw/mlx4/cm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/hw/mlx4/cm.c b/drivers/infiniband/hw/mlx4/cm.c index add98d0..524e168 100644 --- a/drivers/infiniband/hw/mlx4/cm.c +++ b/drivers/infiniband/hw/mlx4/cm.c @@ -204,7 +204,6 @@ static struct id_map_entry * id_map_alloc(struct ib_device *ibdev, int slave_id, u32 sl_cm_id) { int ret; - static int next_id; struct id_map_entry *ent; struct mlx4_ib_sriov *sriov = &to_mdev(ibdev)->sriov; @@ -223,9 +222,8 @@ id_map_alloc(struct ib_device *ibdev, int slave_id, u32 sl_cm_id) idr_preload(GFP_KERNEL); spin_lock(&to_mdev(ibdev)->sriov.id_map_lock); - ret = idr_alloc(&sriov->pv_id_table, ent, next_id, 0, GFP_NOWAIT); + ret = idr_alloc_cyclic(&sriov->pv_id_table, ent, 0, 0, GFP_NOWAIT); if (ret >= 0) { - next_id = max(ret + 1, 0); ent->pv_cm_id = (u32)ret; sl_id_map_add(ibdev, ent); list_add_tail(&ent->list, &sriov->cm_list); @@ -361,7 +359,7 @@ void mlx4_ib_cm_paravirt_init(struct mlx4_ib_dev *dev) spin_lock_init(&dev->sriov.id_map_lock); INIT_LIST_HEAD(&dev->sriov.cm_list); dev->sriov.sl_id_map = RB_ROOT; - idr_init(&dev->sriov.pv_id_table); + idr_init_cyclic(&dev->sriov.pv_id_table, 0); } /* slave = -1 ==> all slaves */