Browse Source

[mtnic] Switch to malloc_dma() and free_dma()

alloc_memblock() and free_memblock() are internal.

Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Piotr Jaroszyński 14 years ago
parent
commit
b1fa4378d1
1 changed files with 29 additions and 29 deletions
  1. 29
    29
      src/drivers/net/mtnic.c

+ 29
- 29
src/drivers/net/mtnic.c View File

76
 static int
76
 static int
77
 mtnic_alloc_aligned(unsigned int size, void **va, unsigned long *pa, unsigned int alignment)
77
 mtnic_alloc_aligned(unsigned int size, void **va, unsigned long *pa, unsigned int alignment)
78
 {
78
 {
79
-	*va = alloc_memblock(size, alignment);
79
+	*va = malloc_dma(size, alignment);
80
 	if (!*va) {
80
 	if (!*va) {
81
 		return -EADDRINUSE;
81
 		return -EADDRINUSE;
82
 	}
82
 	}
212
 					  (void *)&ring->db, &ring->db_dma, 32);
212
 					  (void *)&ring->db, &ring->db_dma, 32);
213
 		if (err) {
213
 		if (err) {
214
 			DBG("Failed allocating Rx ring doorbell record\n");
214
 			DBG("Failed allocating Rx ring doorbell record\n");
215
-			free_memblock(ring->buf, ring->buf_size);
215
+			free_dma(ring->buf, ring->buf_size);
216
 			return -EADDRINUSE;
216
 			return -EADDRINUSE;
217
 		}
217
 		}
218
 
218
 
230
 		err = mtnic_alloc_iobuf ( priv, ring, DEF_IOBUF_SIZE );
230
 		err = mtnic_alloc_iobuf ( priv, ring, DEF_IOBUF_SIZE );
231
 		if (err) {
231
 		if (err) {
232
 			DBG("ERROR Allocating io buffer\n");
232
 			DBG("ERROR Allocating io buffer\n");
233
-			free_memblock(ring->buf, ring->buf_size);
233
+			free_dma(ring->buf, ring->buf_size);
234
 			return -EADDRINUSE;
234
 			return -EADDRINUSE;
235
 		}
235
 		}
236
 
236
 
251
 					priv->mtnic->fw.txcq_db_offset, PAGE_SIZE);
251
 					priv->mtnic->fw.txcq_db_offset, PAGE_SIZE);
252
 		if (!ring->txcq_db) {
252
 		if (!ring->txcq_db) {
253
 			DBG("Couldn't map txcq doorbell, aborting...\n");
253
 			DBG("Couldn't map txcq doorbell, aborting...\n");
254
-			free_memblock(ring->buf, ring->buf_size);
254
+			free_dma(ring->buf, ring->buf_size);
255
 			return -EADDRINUSE;
255
 			return -EADDRINUSE;
256
 		}
256
 		}
257
 	}
257
 	}
296
 				  (void *)&cq->buf, &cq->dma, PAGE_SIZE);
296
 				  (void *)&cq->buf, &cq->dma, PAGE_SIZE);
297
 	if (err) {
297
 	if (err) {
298
 		DBG("Failed allocating CQ buffer\n");
298
 		DBG("Failed allocating CQ buffer\n");
299
-		free_memblock(cq->db, sizeof(struct mtnic_cq_db_record));
299
+		free_dma(cq->db, sizeof(struct mtnic_cq_db_record));
300
 		return -EADDRINUSE;
300
 		return -EADDRINUSE;
301
 	}
301
 	}
302
 	memset(cq->buf, 0, cq->buf_size);
302
 	memset(cq->buf, 0, cq->buf_size);
370
 	return 0;
370
 	return 0;
371
 
371
 
372
 cq1_error:
372
 cq1_error:
373
-	free_memblock(priv->cq[1].buf, priv->cq[1].buf_size);
374
-	free_memblock(priv->cq[1].db, sizeof(struct mtnic_cq_db_record));
373
+	free_dma(priv->cq[1].buf, priv->cq[1].buf_size);
374
+	free_dma(priv->cq[1].db, sizeof(struct mtnic_cq_db_record));
375
 
375
 
376
 rx_error:
376
 rx_error:
377
-	free_memblock(priv->rx_ring.buf, priv->rx_ring.buf_size);
378
-	free_memblock(priv->rx_ring.db, sizeof(struct mtnic_cq_db_record));
377
+	free_dma(priv->rx_ring.buf, priv->rx_ring.buf_size);
378
+	free_dma(priv->rx_ring.db, sizeof(struct mtnic_cq_db_record));
379
 	mtnic_free_io_buffers(&priv->rx_ring);
379
 	mtnic_free_io_buffers(&priv->rx_ring);
380
 cq0_error:
380
 cq0_error:
381
-	free_memblock(priv->cq[0].buf, priv->cq[0].buf_size);
382
-	free_memblock(priv->cq[0].db, sizeof(struct mtnic_cq_db_record));
381
+	free_dma(priv->cq[0].buf, priv->cq[0].buf_size);
382
+	free_dma(priv->cq[0].db, sizeof(struct mtnic_cq_db_record));
383
 
383
 
384
 	return -EADDRINUSE;
384
 	return -EADDRINUSE;
385
 }
385
 }
1159
 
1159
 
1160
 eq_error:
1160
 eq_error:
1161
 	iounmap(mtnic->eq_db);
1161
 	iounmap(mtnic->eq_db);
1162
-	free_memblock(mtnic->eq.buf, mtnic->eq.buf_size);
1162
+	free_dma(mtnic->eq.buf, mtnic->eq.buf_size);
1163
 map_extra_error:
1163
 map_extra_error:
1164
 	ufree((intptr_t)mtnic->fw.extra_pages.buf);
1164
 	ufree((intptr_t)mtnic->fw.extra_pages.buf);
1165
 map_fw_error:
1165
 map_fw_error:
1167
 
1167
 
1168
 cmd_error:
1168
 cmd_error:
1169
 	iounmap(mtnic->hcr);
1169
 	iounmap(mtnic->hcr);
1170
-	free_memblock(mtnic->cmd.buf, PAGE_SIZE);
1170
+	free_dma(mtnic->cmd.buf, PAGE_SIZE);
1171
 
1171
 
1172
 	return -EADDRINUSE;
1172
 	return -EADDRINUSE;
1173
 }
1173
 }
1465
 
1465
 
1466
 allocation_error:
1466
 allocation_error:
1467
 
1467
 
1468
-	free_memblock(priv->tx_ring.buf, priv->tx_ring.buf_size);
1468
+	free_dma(priv->tx_ring.buf, priv->tx_ring.buf_size);
1469
 	iounmap(priv->tx_ring.txcq_db);
1469
 	iounmap(priv->tx_ring.txcq_db);
1470
-	free_memblock(priv->cq[1].buf, priv->cq[1].buf_size);
1471
-	free_memblock(priv->cq[1].db, sizeof(struct mtnic_cq_db_record));
1472
-	free_memblock(priv->rx_ring.buf, priv->rx_ring.buf_size);
1473
-	free_memblock(priv->rx_ring.db, sizeof(struct mtnic_cq_db_record));
1474
-	free_memblock(priv->cq[0].buf, priv->cq[0].buf_size);
1475
-	free_memblock(priv->cq[0].db, sizeof(struct mtnic_cq_db_record));
1470
+	free_dma(priv->cq[1].buf, priv->cq[1].buf_size);
1471
+	free_dma(priv->cq[1].db, sizeof(struct mtnic_cq_db_record));
1472
+	free_dma(priv->rx_ring.buf, priv->rx_ring.buf_size);
1473
+	free_dma(priv->rx_ring.db, sizeof(struct mtnic_cq_db_record));
1474
+	free_dma(priv->cq[0].buf, priv->cq[0].buf_size);
1475
+	free_dma(priv->cq[0].db, sizeof(struct mtnic_cq_db_record));
1476
 
1476
 
1477
 	mtnic_free_io_buffers(&priv->rx_ring);
1477
 	mtnic_free_io_buffers(&priv->rx_ring);
1478
 
1478
 
1625
 		mdelay ( 10 );
1625
 		mdelay ( 10 );
1626
 
1626
 
1627
 		/* free memory */
1627
 		/* free memory */
1628
-		free_memblock(priv->tx_ring.buf, priv->tx_ring.buf_size);
1628
+		free_dma(priv->tx_ring.buf, priv->tx_ring.buf_size);
1629
 		iounmap(priv->tx_ring.txcq_db);
1629
 		iounmap(priv->tx_ring.txcq_db);
1630
-		free_memblock(priv->cq[1].buf, priv->cq[1].buf_size);
1631
-		free_memblock(priv->cq[1].db, sizeof(struct mtnic_cq_db_record));
1632
-		free_memblock(priv->rx_ring.buf, priv->rx_ring.buf_size);
1633
-		free_memblock(priv->rx_ring.db, sizeof(struct mtnic_cq_db_record));
1634
-		free_memblock(priv->cq[0].buf, priv->cq[0].buf_size);
1635
-		free_memblock(priv->cq[0].db, sizeof(struct mtnic_cq_db_record));
1630
+		free_dma(priv->cq[1].buf, priv->cq[1].buf_size);
1631
+		free_dma(priv->cq[1].db, sizeof(struct mtnic_cq_db_record));
1632
+		free_dma(priv->rx_ring.buf, priv->rx_ring.buf_size);
1633
+		free_dma(priv->rx_ring.db, sizeof(struct mtnic_cq_db_record));
1634
+		free_dma(priv->cq[0].buf, priv->cq[0].buf_size);
1635
+		free_dma(priv->cq[0].db, sizeof(struct mtnic_cq_db_record));
1636
 
1636
 
1637
 		/* Free RX buffers */
1637
 		/* Free RX buffers */
1638
 		mtnic_free_io_buffers(&priv->rx_ring);
1638
 		mtnic_free_io_buffers(&priv->rx_ring);
1682
 		DBG("Error Releasing resources %d\n", err);
1682
 		DBG("Error Releasing resources %d\n", err);
1683
 	}
1683
 	}
1684
 
1684
 
1685
-	free_memblock(mtnic->cmd.buf, PAGE_SIZE);
1685
+	free_dma(mtnic->cmd.buf, PAGE_SIZE);
1686
 	iounmap(mtnic->hcr);
1686
 	iounmap(mtnic->hcr);
1687
 	ufree((intptr_t)mtnic->fw.fw_pages.buf);
1687
 	ufree((intptr_t)mtnic->fw.fw_pages.buf);
1688
 	ufree((intptr_t)mtnic->fw.extra_pages.buf);
1688
 	ufree((intptr_t)mtnic->fw.extra_pages.buf);
1689
-	free_memblock(mtnic->eq.buf, mtnic->eq.buf_size);
1689
+	free_dma(mtnic->eq.buf, mtnic->eq.buf_size);
1690
 	iounmap(mtnic->eq_db);
1690
 	iounmap(mtnic->eq_db);
1691
 
1691
 
1692
 
1692
 

Loading…
Cancel
Save