Skip to contentSkip to conversation

IB: Keep MAD work completion valid

PATCH New Roland Dreier 1 participant 6 messages Apr 1, 2005 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 IB: Keep MAD work completion valid

From: Sean Hefty <[email protected]>

Replace the *wc field in ib_mad_recv_wc from pointing to a structure on the stack to one allocated with the received MAD buffer. This allows a client to access the *wc field after their receive completion handler has returned.

drivers/infiniband/core/mad.c +2 -1
@@ -1600,7 +1600,8 @@
 			 DMA_FROM_DEVICE);
 
 	/* Setup MAD receive work completion from "normal" work completion */
-	recv->header.recv_wc.wc = wc;
+	recv->header.wc = *wc;
+	recv->header.recv_wc.wc = &recv->header.wc;
 	recv->header.recv_wc.mad_len = sizeof(struct ib_mad);
 	recv->header.recv_wc.recv_buf.mad = &recv->mad.mad;
 	recv->header.recv_wc.recv_buf.grh = &recv->grh;
drivers/infiniband/core/mad_priv.h +1 -0
@@ -69,6 +69,7 @@
 struct ib_mad_private_header {
 	struct ib_mad_list_head mad_list;
 	struct ib_mad_recv_wc recv_wc;
+	struct ib_wc wc;
 	DECLARE_PCI_UNMAP_ADDR(mapping)
 } __attribute__ ((packed));
 
#2 lore raw

PATCH 3/6 IB: Fix FMR pool crash

Mask bits correctly from jhash result in ib_fmr_hash() so that the computed bucket index is within our hash table. This fixes an SDP crash.

drivers/infiniband/core/fmr_pool.c +2 -3
@@ -103,9 +103,8 @@
 
 static inline u32 ib_fmr_hash(u64 first_page)
 {
-	return jhash_2words((u32) first_page,
-			    (u32) (first_page >> 32),
-			    0);
+	return jhash_2words((u32) first_page, (u32) (first_page >> 32), 0) &
+		(IB_FMR_HASH_SIZE - 1);
 }
 
 /* Caller must hold pool_lock */
#3 lore raw

PATCH 4/6 IB: Trivial FMR printk cleanup

From: Libor Michalek <[email protected]>

Add missing newline in printk.

drivers/infiniband/core/fmr_pool.c +1 -1
@@ -442,7 +442,7 @@
 		list_add(&fmr->list, &pool->free_list);
 		spin_unlock_irqrestore(&pool->pool_lock, flags);
 
-		printk(KERN_WARNING "fmr_map returns %d",
+		printk(KERN_WARNING "fmr_map returns %d\n",
 		       result);
 
 		return ERR_PTR(result);
#4 lore raw

PATCH 5/6 IB: Fix user MAD registrations with class 0

Fix handling of MAD agent registrations with mgmt_class == 0. In this case ib_umad should pass a NULL registration request to the MAD core rather than a request with mgmt_class set to 0.

drivers/infiniband/core/user_mad.c +8 -6
@@ -389,15 +389,17 @@
 	goto out;
 
 found:
-	req.mgmt_class         = ureq.mgmt_class;
-	req.mgmt_class_version = ureq.mgmt_class_version;
-	memcpy(req.method_mask, ureq.method_mask, sizeof req.method_mask);
-	memcpy(req.oui,         ureq.oui,         sizeof req.oui);
+	if (ureq.mgmt_class) {
+		req.mgmt_class         = ureq.mgmt_class;
+		req.mgmt_class_version = ureq.mgmt_class_version;
+		memcpy(req.method_mask, ureq.method_mask, sizeof req.method_mask);
+		memcpy(req.oui,         ureq.oui,         sizeof req.oui);
+	}
 
 	agent = ib_register_mad_agent(file->port->ib_dev, file->port->port_num,
 				      ureq.qpn ? IB_QPT_GSI : IB_QPT_SMI,
-				      &req, 0, send_handler, recv_handler,
-				      file);
+				      ureq.mgmt_class ? &req : NULL,
+				      0, send_handler, recv_handler, file);
 	if (IS_ERR(agent)) {
 		ret = PTR_ERR(agent);
 		goto out;
#5 lore raw

PATCH 6/6 IB: Remove incorrect comments

From: Hal Rosenstock <[email protected]>

Eliminate unneeded and misleading comments

drivers/infiniband/core/agent.c +0 -2
@@ -129,7 +129,6 @@
 		goto out;
 	agent_send_wr->mad = mad_priv;
 
-	/* PCI mapping */
 	gather_list.addr = dma_map_single(mad_agent->device->dma_device,
 					  &mad_priv->mad,
 					  sizeof(mad_priv->mad),
@@ -261,7 +260,6 @@
 	list_del(&agent_send_wr->send_list);
 	spin_unlock_irqrestore(&port_priv->send_list_lock, flags);
 
-	/* Unmap PCI */
 	dma_unmap_single(mad_agent->device->dma_device,
 			 pci_unmap_addr(agent_send_wr, mapping),
 			 sizeof(agent_send_wr->mad->mad),
drivers/infiniband/core/mad.c +0 -1
@@ -2283,7 +2283,6 @@
 		/* Remove from posted receive MAD list */
 		list_del(&mad_list->list);
 
-		/* Undo PCI mapping */
 		dma_unmap_single(qp_info->port_priv->device->dma_device,
 				 pci_unmap_addr(&recv->header, mapping),
 				 sizeof(struct ib_mad_private) -