From patchwork Tue Feb 2 19:09:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Chiang X-Patchwork-Id: 76479 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o12JAkT7031411 for ; Tue, 2 Feb 2010 19:10:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932300Ab0BBTKb (ORCPT ); Tue, 2 Feb 2010 14:10:31 -0500 Received: from g4t0017.houston.hp.com ([15.201.24.20]:16855 "EHLO g4t0017.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932226Ab0BBTJH (ORCPT ); Tue, 2 Feb 2010 14:09:07 -0500 Received: from g4t0018.houston.hp.com (g4t0018.houston.hp.com [16.234.32.27]) by g4t0017.houston.hp.com (Postfix) with ESMTP id 7840238448; Tue, 2 Feb 2010 19:09:06 +0000 (UTC) Received: from ldl (ldl.fc.hp.com [15.11.146.30]) by g4t0018.houston.hp.com (Postfix) with ESMTP id 520DC10011; Tue, 2 Feb 2010 19:09:06 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl (Postfix) with ESMTP id 395A6CF000A; Tue, 2 Feb 2010 12:09:06 -0700 (MST) Received: from ldl ([127.0.0.1]) by localhost (ldl.fc.hp.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BycekPpoE5ev; Tue, 2 Feb 2010 12:09:06 -0700 (MST) Received: from eh.fc.hp.com (eh.fc.hp.com [15.11.146.105]) by ldl (Postfix) with ESMTP id 23AEFCF0007; Tue, 2 Feb 2010 12:09:06 -0700 (MST) Received: from bob.kio (localhost [127.0.0.1]) by eh.fc.hp.com (Postfix) with ESMTP id 11DCB261D3; Tue, 2 Feb 2010 12:09:06 -0700 (MST) Subject: [PATCH v2 16/18] IB/ucm: increase maximum devices supported To: rdreier@cisco.com From: Alex Chiang Cc: linux-rdma@vger.kernel.org, justin.chen@hp.com, linux-kernel@vger.kernel.org Date: Tue, 02 Feb 2010 12:09:06 -0700 Message-ID: <20100202190905.28217.97347.stgit@bob.kio> In-Reply-To: <20100202185235.28217.64521.stgit@bob.kio> References: <20100202185235.28217.64521.stgit@bob.kio> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 02 Feb 2010 19:10:48 +0000 (UTC) diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index 06c50d8..1203ca4 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c @@ -1215,7 +1215,10 @@ static void ib_ucm_release_dev(struct device *dev) ucm_dev = container_of(dev, struct ib_ucm_device, dev); cdev_del(&ucm_dev->cdev); - clear_bit(ucm_dev->devnum, dev_map); + if (ucm_dev->devnum < IB_UCM_MAX_DEVICES) + clear_bit(ucm_dev->devnum, dev_map); + else + clear_bit(ucm_dev->devnum - IB_UCM_MAX_DEVICES, dev_map); kfree(ucm_dev); } @@ -1237,6 +1240,28 @@ static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); +static dev_t oflo_maj; +static DECLARE_BITMAP(oflo_map, IB_UCM_MAX_DEVICES); +static int find_oflo_devnum(void) +{ + int ret; + + if (!oflo_maj) { + ret = alloc_chrdev_region(&oflo_maj, 0, IB_UCM_MAX_DEVICES, + "infiniband_cm"); + if (ret) { + printk(KERN_ERR "ucm: couldn't register dynamic device number\n"); + return ret; + } + } + + ret = find_first_zero_bit(oflo_map, IB_UCM_MAX_DEVICES); + if (ret >= IB_UCM_MAX_DEVICES) + return -1; + + return ret; +} + static void ib_ucm_add_one(struct ib_device *device) { int devnum; @@ -1254,12 +1279,19 @@ static void ib_ucm_add_one(struct ib_device *device) ucm_dev->ib_dev = device; devnum = find_first_zero_bit(dev_map, IB_UCM_MAX_DEVICES); - if (devnum >= IB_UCM_MAX_DEVICES) - goto err; - - ucm_dev->devnum = devnum; - base = devnum + IB_UCM_BASE_DEV; - set_bit(devnum, dev_map); + if (devnum >= IB_UCM_MAX_DEVICES) { + devnum = find_oflo_devnum(); + if (devnum < 0) + goto err; + + ucm_dev->devnum = devnum + IB_UCM_MAX_DEVICES; + base = devnum + oflo_maj; + set_bit(devnum, oflo_map); + } else { + ucm_dev->devnum = devnum; + base = devnum + IB_UCM_BASE_DEV; + set_bit(devnum, dev_map); + } cdev_init(&ucm_dev->cdev, &ucm_fops); ucm_dev->cdev.owner = THIS_MODULE; @@ -1285,7 +1317,10 @@ err_dev: device_unregister(&ucm_dev->dev); err_cdev: cdev_del(&ucm_dev->cdev); - clear_bit(devnum, dev_map); + if (ucm_dev->devnum < IB_UCM_MAX_DEVICES) + clear_bit(devnum, dev_map); + else + clear_bit(devnum, oflo_map); err: kfree(ucm_dev); return; @@ -1344,6 +1379,8 @@ static void __exit ib_ucm_cleanup(void) ib_unregister_client(&ucm_client); class_remove_file(&cm_class, &class_attr_abi_version); unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES); + if (oflo_maj) + unregister_chrdev_region(oflo_maj, IB_UCM_MAX_DEVICES); idr_destroy(&ctx_id_table); }