Skip to contentSkip to conversation

InfiniBand fixes for 2.6.14

GIT PULL Roland Dreier 3 participants 5 messages Sep 28, 2005 – Sep 29, 2005 InfiniBand

lore
Share & tools
lore
#0 lore raw

Linus, please pull from

master.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband.git for-linus

This tree is also available from kernel.org mirrors at:

rsync://rsync.kernel.org/pub/scm/linux/kernel/git/roland/infiniband.git for-linus

This will pull the following changes (full patch below):

Jack Morgenstein:
[IB] mthca: fix hw_ver value returned from mthca_query_device

Michael S. Tsirkin:
[IB] mthca: fix off by one in clr_int calculation [IB] mthca: Fix off by one bug in mthca_map_cmd
[IB] mthca: Round up number of slots in HCA context memory table

Roland Dreier:
[IB] mthca: Fix doorbell record resource leak
[IB] uverbs: Close some exploitable races

 drivers/infiniband/core/uverbs.h             |    1 
 drivers/infiniband/core/uverbs_cmd.c         |  122 ++++++++++++++------------
 drivers/infiniband/core/uverbs_main.c        |   27 ++++--
 drivers/infiniband/hw/mthca/mthca_cmd.c      |    4 -
 drivers/infiniband/hw/mthca/mthca_eq.c       |    2 
 drivers/infiniband/hw/mthca/mthca_memfree.c  |   19 +++-
 drivers/infiniband/hw/mthca/mthca_provider.c |    2 
 include/rdma/ib_verbs.h                      |    1 
 8 files changed, 105 insertions(+), 73 deletions(-)
drivers/infiniband/core/uverbs.h +1 -0
@@ -69,6 +69,7 @@ struct ib_uverbs_event_file {
 
 struct ib_uverbs_file {
 	struct kref				ref;
+	struct semaphore			mutex;
 	struct ib_uverbs_device		       *device;
 	struct ib_ucontext		       *ucontext;
 	struct ib_event_handler			event_handler;
drivers/infiniband/core/uverbs_cmd.c +67 -55

255 lines not on this page · raw message

drivers/infiniband/core/uverbs_main.c +19 -8
@@ -448,7 +448,9 @@ static ssize_t ib_uverbs_write(struct fi
 	if (hdr.in_words * 4 != count)
 		return -EINVAL;
 
-	if (hdr.command < 0 || hdr.command >= ARRAY_SIZE(uverbs_cmd_table))
+	if (hdr.command < 0				||
+	    hdr.command >= ARRAY_SIZE(uverbs_cmd_table) ||
+	    !uverbs_cmd_table[hdr.command])
 		return -EINVAL;
 
 	if (!file->ucontext                               &&
@@ -484,27 +486,29 @@ static int ib_uverbs_open(struct inode *
 	file = kmalloc(sizeof *file +
 		       (dev->num_comp - 1) * sizeof (struct ib_uverbs_event_file),
 		       GFP_KERNEL);
-	if (!file)
-		return -ENOMEM;
+	if (!file) {
+		ret = -ENOMEM;
+		goto err;
+	}
 
 	file->device = dev;
 	kref_init(&file->ref);
+	init_MUTEX(&file->mutex);
 
 	file->ucontext = NULL;
 
+	kref_get(&file->ref);
 	ret = ib_uverbs_event_init(&file->async_file, file);
 	if (ret)
-		goto err;
+		goto err_kref;
 
 	file->async_file.is_async = 1;
 
-	kref_get(&file->ref);
-
 	for (i = 0; i < dev->num_comp; ++i) {
+		kref_get(&file->ref);
 		ret = ib_uverbs_event_init(&file->comp_file[i], file);
 		if (ret)
 			goto err_async;
-		kref_get(&file->ref);
 		file->comp_file[i].is_async = 0;
 	}
 
@@ -524,9 +528,16 @@ err_async:
 
 	ib_uverbs_event_release(&file->async_file);
 
-err:
+err_kref:
+	/*
+	 * One extra kref_put() because we took a reference before the
+	 * event file creation that failed and got us here.
+	 */
+	kref_put(&file->ref, ib_uverbs_release_file);
 	kref_put(&file->ref, ib_uverbs_release_file);
 
+err:
+	module_put(dev->ib_dev->owner);
 	return ret;
 }
 
drivers/infiniband/hw/mthca/mthca_cmd.c +2 -2
@@ -605,7 +605,7 @@ static int mthca_map_cmd(struct mthca_de
 			err = -EINVAL;
 			goto out;
 		}
-		for (i = 0; i < mthca_icm_size(&iter) / (1 << lg); ++i, ++nent) {
+		for (i = 0; i < mthca_icm_size(&iter) / (1 << lg); ++i) {
 			if (virt != -1) {
 				pages[nent * 2] = cpu_to_be64(virt);
 				virt += 1 << lg;
@@ -616,7 +616,7 @@ static int mthca_map_cmd(struct mthca_de
 			ts += 1 << (lg - 10);
 			++tc;
 
-			if (nent == MTHCA_MAILBOX_SIZE / 16) {
+			if (++nent == MTHCA_MAILBOX_SIZE / 16) {
 				err = mthca_cmd(dev, mailbox->dma, nent, 0, op,
 						CMD_TIME_CLASS_B, status);
 				if (err || *status)
drivers/infiniband/hw/mthca/mthca_eq.c +1 -1
@@ -836,7 +836,7 @@ int __devinit mthca_init_eq_table(struct
 		dev->eq_table.clr_mask =
 			swab32(1 << (dev->eq_table.inta_pin & 31));
 		dev->eq_table.clr_int  = dev->clr_base +
-			(dev->eq_table.inta_pin < 31 ? 4 : 0);
+			(dev->eq_table.inta_pin < 32 ? 4 : 0);
 	}
 
 	dev->eq_table.arm_mask = 0;
drivers/infiniband/hw/mthca/mthca_memfree.c +14 -5
@@ -290,7 +290,7 @@ struct mthca_icm_table *mthca_alloc_icm_
 	int i;
 	u8 status;
 
-	num_icm = obj_size * nobj / MTHCA_TABLE_CHUNK_SIZE;
+	num_icm = (obj_size * nobj + MTHCA_TABLE_CHUNK_SIZE - 1) / MTHCA_TABLE_CHUNK_SIZE;
 
 	table = kmalloc(sizeof *table + num_icm * sizeof *table->icm, GFP_KERNEL);
 	if (!table)
@@ -529,12 +529,25 @@ int mthca_alloc_db(struct mthca_dev *dev
 			goto found;
 		}
 
+	for (i = start; i != end; i += dir)
+		if (!dev->db_tab->page[i].db_rec) {
+			page = dev->db_tab->page + i;
+			goto alloc;
+		}
+
 	if (dev->db_tab->max_group1 >= dev->db_tab->min_group2 - 1) {
 		ret = -ENOMEM;
 		goto out;
 	}
 
+	if (group == 0)
+		++dev->db_tab->max_group1;
+	else
+		--dev->db_tab->min_group2;
+
 	page = dev->db_tab->page + end;
+
+alloc:
 	page->db_rec = dma_alloc_coherent(&dev->pdev->dev, 4096,
 					  &page->mapping, GFP_KERNEL);
 	if (!page->db_rec) {
@@ -554,10 +567,6 @@ int mthca_alloc_db(struct mthca_dev *dev
 	}
 
 	bitmap_zero(page->used, MTHCA_DB_REC_PER_PAGE);
-	if (group == 0)
-		++dev->db_tab->max_group1;
-	else
-		--dev->db_tab->min_group2;
 
 found:
 	j = find_first_zero_bit(page->used, MTHCA_DB_REC_PER_PAGE);
drivers/infiniband/hw/mthca/mthca_provider.c +1 -1
@@ -84,7 +84,7 @@ static int mthca_query_device(struct ib_
 	props->vendor_id           = be32_to_cpup((__be32 *) (out_mad->data + 36)) &
 		0xffffff;
 	props->vendor_part_id      = be16_to_cpup((__be16 *) (out_mad->data + 30));
-	props->hw_ver              = be16_to_cpup((__be16 *) (out_mad->data + 32));
+	props->hw_ver              = be32_to_cpup((__be32 *) (out_mad->data + 32));
 	memcpy(&props->sys_image_guid, out_mad->data +  4, 8);
 	memcpy(&props->node_guid,      out_mad->data + 12, 8);
 
include/rdma/ib_verbs.h +0 -1
@@ -665,7 +665,6 @@ struct ib_ucontext {
 	struct list_head	qp_list;
 	struct list_head	srq_list;
 	struct list_head	ah_list;
-	spinlock_t              lock;
 };
 
 struct ib_uobject {
#1 lore raw
Quoted 3 lines · Roland Dreier

Linus, please pull from

master.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband.git for-linus

Hm, I complained about this last time, with no response...

I didn't think that git pulls were going to be allowed from subsystem maintainers after -rc1 came out. After that, patches by email were required to be sent, not git pulls. This does cause a bit more work for the maintainer, but it ensures that they only send the patches they really want to get in.

At least that was what I thought we decided on at the kernel summit...

thanks,

greg k-h

#2 lore raw
Quoted 7 lines · Greg KH
Quoted 3 lines · Roland Dreier

Linus, please pull from

master.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband.git for-linus

Hm, I complained about this last time, with no response...

Quoted 7 lines

I didn't think that git pulls were going to be allowed from subsystem maintainers after -rc1 came out. After that, patches by email were required to be sent, not git pulls. This does cause a bit more work for the maintainer, but it ensures that they only send the patches they really want to get in.

At least that was what I thought we decided on at the kernel summit...

That is not what Linus said on LKML only a week or two ago. He said git pulls are just fine. It is the content of the git pull that matters. It has to be bug fixes only. As Linus said, and I couldn't agree more, it would be silly to limit the method of patch submission given only the content is meant to be limited.

Best regards,

Anton

Signature · 4 lines
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/
#3 lore raw
In reply to Greg KH

Greg> I didn't think that git pulls were going to be allowed from Greg> subsystem maintainers after -rc1 came out. After that, Greg> patches by email were required to be sent, not git pulls. Greg> This does cause a bit more work for the maintainer, but it Greg> ensures that they only send the patches they really want to Greg> get in.

I specifically asked Linus about this a couple of weeks ago, and he said that bug-fix-only git merges are file. See http://lkml.org/lkml/2005/9/13/277

- R.

#4 lore raw
Quoted 9 lines · Roland Dreier

Greg> I didn't think that git pulls were going to be allowed from Greg> subsystem maintainers after -rc1 came out. After that, Greg> patches by email were required to be sent, not git pulls. Greg> This does cause a bit more work for the maintainer, but it Greg> ensures that they only send the patches they really want to Greg> get in.

I specifically asked Linus about this a couple of weeks ago, and he said that bug-fix-only git merges are file. See http://lkml.org/lkml/2005/9/13/277

Ah, thanks for pointing me to that, I missed that.

greg k-h