Skip to contentSkip to conversation

amso1100 - Use dma_alloc_coherent instead of kmalloc/dma_map_single.

PATCH Applied Steve Wise 2 participants 4 messages Oct 27, 2006

Subsystems (3)
lore
Share & tools
lore

Steve Wise

author
#0 lore raw

PATCH v2 1/2 amso1100 - Use dma_alloc_coherent instead of kmalloc/dma_map_single.

v2 of this patch fixes a compiler warning I missed...

Steve.

-----

The Ammasso driver needs to use dma_alloc_coherent() for allocating memory that will be used by the HW for dma.

---

 drivers/infiniband/hw/amso1100/c2_alloc.c |   13 +++----
 drivers/infiniband/hw/amso1100/c2_cq.c    |   18 +++-------
 drivers/infiniband/hw/amso1100/c2_rnic.c  |   52 ++++++++++++-----------------
 3 files changed, 33 insertions(+), 50 deletions(-)
drivers/infiniband/hw/amso1100/c2_alloc.c +6 -7
index 028a60b..1d30ef7 100644
@@ -42,13 +42,14 @@ static int c2_alloc_mqsp_chunk(struct c2
 {
 	int i;
 	struct sp_chunk *new_head;
+	dma_addr_t dma_addr;
 
-	new_head = (struct sp_chunk *) __get_free_page(gfp_mask);
+	new_head = dma_alloc_coherent(&c2dev->pcidev->dev, PAGE_SIZE, 
+				      &dma_addr, gfp_mask); 
 	if (new_head == NULL)
 		return -ENOMEM;
 
-	new_head->dma_addr = dma_map_single(c2dev->ibdev.dma_device, new_head,
-					    PAGE_SIZE, DMA_FROM_DEVICE);
+	new_head->dma_addr = dma_addr;
 	pci_unmap_addr_set(new_head, mapping, new_head->dma_addr);
 
 	new_head->next = NULL;
@@ -80,10 +81,8 @@ void c2_free_mqsp_pool(struct c2_dev *c2
 
 	while (root) {
 		next = root->next;
-		dma_unmap_single(c2dev->ibdev.dma_device,
-				 pci_unmap_addr(root, mapping), PAGE_SIZE,
-			         DMA_FROM_DEVICE);
-		__free_page((struct page *) root);
+		dma_free_coherent(&c2dev->pcidev->dev, PAGE_SIZE, root, 
+				  pci_unmap_addr(root, mapping));
 		root = next;
 	}
 }
drivers/infiniband/hw/amso1100/c2_cq.c +6 -12
index 9d7bcc5..05c9154 100644
@@ -246,20 +246,17 @@ int c2_arm_cq(struct ib_cq *ibcq, enum i
 
 static void c2_free_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq)
 {
-
-	dma_unmap_single(c2dev->ibdev.dma_device, pci_unmap_addr(mq, mapping),
-			 mq->q_size * mq->msg_size, DMA_FROM_DEVICE);
-	free_pages((unsigned long) mq->msg_pool.host,
-		   get_order(mq->q_size * mq->msg_size));
+	dma_free_coherent(&c2dev->pcidev->dev, mq->q_size * mq->msg_size,
+			  mq->msg_pool.host, pci_unmap_addr(mq, mapping));
 }
 
 static int c2_alloc_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq, int q_size,
 			   int msg_size)
 {
-	unsigned long pool_start;
+	u8 *pool_start;
 
-	pool_start = __get_free_pages(GFP_KERNEL,
-				      get_order(q_size * msg_size));
+	pool_start = dma_alloc_coherent(&c2dev->pcidev->dev, q_size * msg_size,
+					&mq->host_dma, GFP_KERNEL);
 	if (!pool_start)
 		return -ENOMEM;
 
@@ -267,13 +264,10 @@ static int c2_alloc_cq_buf(struct c2_dev
 		       0,		/* index (currently unknown) */
 		       q_size,
 		       msg_size,
-		       (u8 *) pool_start,
+		       pool_start,
 		       NULL,	/* peer (currently unknown) */
 		       C2_MQ_HOST_TARGET);
 
-	mq->host_dma = dma_map_single(c2dev->ibdev.dma_device,
-				      (void *)pool_start,
-				      q_size * msg_size, DMA_FROM_DEVICE);
 	pci_unmap_addr_set(mq, mapping, mq->host_dma);
 
 	return 0;
drivers/infiniband/hw/amso1100/c2_rnic.c +21 -31

85 lines not on this page · raw message

author
#1 lore raw

PATCH v2 2/2 amso1100 - Fix incorrect pr_debug().

pr_debug() was printing the wrong stuff.

---

 drivers/infiniband/hw/amso1100/c2_rnic.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/amso1100/c2_rnic.c +2 -2
index 6d82464..e1d31fb 100644
@@ -545,8 +545,8 @@ int c2_rnic_init(struct c2_dev *c2dev)
 		goto bail2;
 	}
 	pci_unmap_addr_set(&c2dev->aeq, mapping, c2dev->aeq.host_dma);
-	pr_debug("%s aeq va %p dma %llx\n", __FUNCTION__, q1_pages,
-		 (unsigned long long) c2dev->rep_vq.host_dma);
+	pr_debug("%s aeq va %p dma %llx\n", __FUNCTION__, q2_pages,
+		 (unsigned long long) c2dev->aeq.host_dma);
 	c2_mq_rep_init(&c2dev->aeq,
 		       2,
 		       qsize,
#2 lore raw

Re: [PATCH 2.6.19-rc3 v2 2/2] amso1100 - Fix incorrect pr_debug().

Applied, thanks.