On Wed, Oct 03, 2018 at 11:17:39AM -0400, Dennis Dalessandro wrote: > On 10/2/2018 4:13 AM, Leon Romanovsky wrote: > > From: Leon Romanovsky <leonro@xxxxxxxxxxxx> > > > > Replace custom code to allocate indexes to generic kernel API. > > > > Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx> > > --- > > drivers/infiniband/core/uverbs_main.c | 12 ++++++------ > > 1 file changed, 6 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c > > index 12d8f8097574..74a420eba04f 100644 > > --- a/drivers/infiniband/core/uverbs_main.c > > +++ b/drivers/infiniband/core/uverbs_main.c > > @@ -73,7 +73,7 @@ enum { > > static dev_t dynamic_uverbs_dev; > > static struct class *uverbs_class; > > -static DECLARE_BITMAP(dev_map, IB_UVERBS_MAX_DEVICES); > > +static DEFINE_IDA(uverbs_ida); > > static ssize_t (*uverbs_cmd_table[])(struct ib_uverbs_file *file, > > const char __user *buf, int in_len, > > @@ -1267,11 +1267,11 @@ static void ib_uverbs_add_one(struct ib_device *device) > > rcu_assign_pointer(uverbs_dev->ib_dev, device); > > uverbs_dev->num_comp_vectors = device->num_comp_vectors; > > - devnum = find_first_zero_bit(dev_map, IB_UVERBS_MAX_DEVICES); > > - if (devnum >= IB_UVERBS_MAX_DEVICES) > > + devnum = ida_alloc_max(&uverbs_ida, IB_UVERBS_MAX_DEVICES - 1, > > + GFP_KERNEL); > > + if (devnum < 0) > > So is it OK if the value we get back is 0? find_first_zero_bit() returns 0 for "first uverbs" too, so no change here. diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 50152c1b1004..3c41e975b572 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c @@ -1038,6 +1038,7 @@ static void ib_uverbs_add_one(struct ib_device *device) INIT_LIST_HEAD(&uverbs_dev->uverbs_events_file_list); devnum = find_first_zero_bit(dev_map, IB_UVERBS_MAX_DEVICES); + printk(KERN_ERR "LR: %d\n", devnum); if (devnum >= IB_UVERBS_MAX_DEVICES) goto err; uverbs_dev->devnum = devnum; And the corresponding dmesg: [ 29.726666] mlx5_ib: Mellanox Connect-IB Infiniband driver v5.0-0 [ 29.727389] mlx5_ib: Mellanox Connect-IB Infiniband driver v5.0-0 [ 30.081904] LR: 0 [ 30.545240] LR: 1 Thanks > > -Denny
Attachment:
signature.asc
Description: PGP signature