Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 184953
b: refs/heads/master
c: 8698d3f
h: refs/heads/master
i:
  184951: 09d1077
v: v3
  • Loading branch information
Alexander Chiang authored and Roland Dreier committed Feb 24, 2010
1 parent 63bbc0d commit 4fba7af
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: dc2ed5e3c963490a4fe934b482537d1274961ecb
refs/heads/master: 8698d3feccda66fcb52748e7c7690bd1003f7849
50 changes: 44 additions & 6 deletions trunk/drivers/infiniband/core/user_mad.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,28 @@ static ssize_t show_abi_version(struct class *class, char *buf)
}
static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);

static dev_t overflow_maj;
static DECLARE_BITMAP(overflow_map, IB_UMAD_MAX_PORTS);
static int find_overflow_devnum(void)
{
int ret;

if (!overflow_maj) {
ret = alloc_chrdev_region(&overflow_maj, 0, IB_UMAD_MAX_PORTS * 2,
"infiniband_mad");
if (ret) {
printk(KERN_ERR "user_mad: couldn't register dynamic device number\n");
return ret;
}
}

ret = find_first_zero_bit(overflow_map, IB_UMAD_MAX_PORTS);
if (ret >= IB_UMAD_MAX_PORTS)
return -1;

return ret;
}

static int ib_umad_init_port(struct ib_device *device, int port_num,
struct ib_umad_port *port)
{
Expand All @@ -981,11 +1003,19 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
devnum = find_first_zero_bit(dev_map, IB_UMAD_MAX_PORTS);
if (devnum >= IB_UMAD_MAX_PORTS) {
spin_unlock(&port_lock);
return -1;
devnum = find_overflow_devnum();
if (devnum < 0)
return -1;

spin_lock(&port_lock);
port->dev_num = devnum + IB_UMAD_MAX_PORTS;
base = devnum + overflow_maj;
set_bit(devnum, overflow_map);
} else {
port->dev_num = devnum;
base = devnum + base_dev;
set_bit(devnum, dev_map);
}
port->dev_num = devnum;
base = devnum + base_dev;
set_bit(devnum, dev_map);
spin_unlock(&port_lock);

port->ib_dev = device;
Expand Down Expand Up @@ -1042,7 +1072,10 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,

err_cdev:
cdev_del(&port->cdev);
clear_bit(devnum, dev_map);
if (port->dev_num < IB_UMAD_MAX_PORTS)
clear_bit(devnum, dev_map);
else
clear_bit(devnum, overflow_map);

return -1;
}
Expand Down Expand Up @@ -1079,7 +1112,10 @@ static void ib_umad_kill_port(struct ib_umad_port *port)

mutex_unlock(&port->file_mutex);

clear_bit(port->dev_num, dev_map);
if (port->dev_num < IB_UMAD_MAX_PORTS)
clear_bit(port->dev_num, dev_map);
else
clear_bit(port->dev_num - IB_UMAD_MAX_PORTS, overflow_map);
}

static void ib_umad_add_one(struct ib_device *device)
Expand Down Expand Up @@ -1187,6 +1223,8 @@ static void __exit ib_umad_cleanup(void)
ib_unregister_client(&umad_client);
class_destroy(umad_class);
unregister_chrdev_region(base_dev, IB_UMAD_MAX_PORTS * 2);
if (overflow_maj)
unregister_chrdev_region(overflow_maj, IB_UMAD_MAX_PORTS * 2);
}

module_init(ib_umad_init);
Expand Down

0 comments on commit 4fba7af

Please sign in to comment.