david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[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>
This commit is contained in:
Piotr Jaroszyński 2010-07-28 20:32:46 +02:00 committed by Michael Brown
parent 6e4573bcd0
commit b1fa4378d1
1 changed files with 29 additions and 29 deletions

View File

@ -76,7 +76,7 @@ FILE_LICENCE ( GPL2_ONLY );
static int static int
mtnic_alloc_aligned(unsigned int size, void **va, unsigned long *pa, unsigned int alignment) mtnic_alloc_aligned(unsigned int size, void **va, unsigned long *pa, unsigned int alignment)
{ {
*va = alloc_memblock(size, alignment); *va = malloc_dma(size, alignment);
if (!*va) { if (!*va) {
return -EADDRINUSE; return -EADDRINUSE;
} }
@ -212,7 +212,7 @@ mtnic_alloc_ring(struct mtnic_port *priv, struct mtnic_ring *ring,
(void *)&ring->db, &ring->db_dma, 32); (void *)&ring->db, &ring->db_dma, 32);
if (err) { if (err) {
DBG("Failed allocating Rx ring doorbell record\n"); DBG("Failed allocating Rx ring doorbell record\n");
free_memblock(ring->buf, ring->buf_size); free_dma(ring->buf, ring->buf_size);
return -EADDRINUSE; return -EADDRINUSE;
} }
@ -230,7 +230,7 @@ mtnic_alloc_ring(struct mtnic_port *priv, struct mtnic_ring *ring,
err = mtnic_alloc_iobuf ( priv, ring, DEF_IOBUF_SIZE ); err = mtnic_alloc_iobuf ( priv, ring, DEF_IOBUF_SIZE );
if (err) { if (err) {
DBG("ERROR Allocating io buffer\n"); DBG("ERROR Allocating io buffer\n");
free_memblock(ring->buf, ring->buf_size); free_dma(ring->buf, ring->buf_size);
return -EADDRINUSE; return -EADDRINUSE;
} }
@ -251,7 +251,7 @@ mtnic_alloc_ring(struct mtnic_port *priv, struct mtnic_ring *ring,
priv->mtnic->fw.txcq_db_offset, PAGE_SIZE); priv->mtnic->fw.txcq_db_offset, PAGE_SIZE);
if (!ring->txcq_db) { if (!ring->txcq_db) {
DBG("Couldn't map txcq doorbell, aborting...\n"); DBG("Couldn't map txcq doorbell, aborting...\n");
free_memblock(ring->buf, ring->buf_size); free_dma(ring->buf, ring->buf_size);
return -EADDRINUSE; return -EADDRINUSE;
} }
} }
@ -296,7 +296,7 @@ mtnic_alloc_cq(struct net_device *dev, int num, struct mtnic_cq *cq,
(void *)&cq->buf, &cq->dma, PAGE_SIZE); (void *)&cq->buf, &cq->dma, PAGE_SIZE);
if (err) { if (err) {
DBG("Failed allocating CQ buffer\n"); DBG("Failed allocating CQ buffer\n");
free_memblock(cq->db, sizeof(struct mtnic_cq_db_record)); free_dma(cq->db, sizeof(struct mtnic_cq_db_record));
return -EADDRINUSE; return -EADDRINUSE;
} }
memset(cq->buf, 0, cq->buf_size); memset(cq->buf, 0, cq->buf_size);
@ -370,16 +370,16 @@ mtnic_alloc_resources(struct net_device *dev)
return 0; return 0;
cq1_error: cq1_error:
free_memblock(priv->cq[1].buf, priv->cq[1].buf_size); free_dma(priv->cq[1].buf, priv->cq[1].buf_size);
free_memblock(priv->cq[1].db, sizeof(struct mtnic_cq_db_record)); free_dma(priv->cq[1].db, sizeof(struct mtnic_cq_db_record));
rx_error: rx_error:
free_memblock(priv->rx_ring.buf, priv->rx_ring.buf_size); free_dma(priv->rx_ring.buf, priv->rx_ring.buf_size);
free_memblock(priv->rx_ring.db, sizeof(struct mtnic_cq_db_record)); free_dma(priv->rx_ring.db, sizeof(struct mtnic_cq_db_record));
mtnic_free_io_buffers(&priv->rx_ring); mtnic_free_io_buffers(&priv->rx_ring);
cq0_error: cq0_error:
free_memblock(priv->cq[0].buf, priv->cq[0].buf_size); free_dma(priv->cq[0].buf, priv->cq[0].buf_size);
free_memblock(priv->cq[0].db, sizeof(struct mtnic_cq_db_record)); free_dma(priv->cq[0].db, sizeof(struct mtnic_cq_db_record));
return -EADDRINUSE; return -EADDRINUSE;
} }
@ -1159,7 +1159,7 @@ int mtnic_init_card(struct mtnic *mtnic)
eq_error: eq_error:
iounmap(mtnic->eq_db); iounmap(mtnic->eq_db);
free_memblock(mtnic->eq.buf, mtnic->eq.buf_size); free_dma(mtnic->eq.buf, mtnic->eq.buf_size);
map_extra_error: map_extra_error:
ufree((intptr_t)mtnic->fw.extra_pages.buf); ufree((intptr_t)mtnic->fw.extra_pages.buf);
map_fw_error: map_fw_error:
@ -1167,7 +1167,7 @@ map_fw_error:
cmd_error: cmd_error:
iounmap(mtnic->hcr); iounmap(mtnic->hcr);
free_memblock(mtnic->cmd.buf, PAGE_SIZE); free_dma(mtnic->cmd.buf, PAGE_SIZE);
return -EADDRINUSE; return -EADDRINUSE;
} }
@ -1465,14 +1465,14 @@ cq_error:
allocation_error: allocation_error:
free_memblock(priv->tx_ring.buf, priv->tx_ring.buf_size); free_dma(priv->tx_ring.buf, priv->tx_ring.buf_size);
iounmap(priv->tx_ring.txcq_db); iounmap(priv->tx_ring.txcq_db);
free_memblock(priv->cq[1].buf, priv->cq[1].buf_size); free_dma(priv->cq[1].buf, priv->cq[1].buf_size);
free_memblock(priv->cq[1].db, sizeof(struct mtnic_cq_db_record)); free_dma(priv->cq[1].db, sizeof(struct mtnic_cq_db_record));
free_memblock(priv->rx_ring.buf, priv->rx_ring.buf_size); free_dma(priv->rx_ring.buf, priv->rx_ring.buf_size);
free_memblock(priv->rx_ring.db, sizeof(struct mtnic_cq_db_record)); free_dma(priv->rx_ring.db, sizeof(struct mtnic_cq_db_record));
free_memblock(priv->cq[0].buf, priv->cq[0].buf_size); free_dma(priv->cq[0].buf, priv->cq[0].buf_size);
free_memblock(priv->cq[0].db, sizeof(struct mtnic_cq_db_record)); free_dma(priv->cq[0].db, sizeof(struct mtnic_cq_db_record));
mtnic_free_io_buffers(&priv->rx_ring); mtnic_free_io_buffers(&priv->rx_ring);
@ -1625,14 +1625,14 @@ mtnic_close(struct net_device *dev)
mdelay ( 10 ); mdelay ( 10 );
/* free memory */ /* free memory */
free_memblock(priv->tx_ring.buf, priv->tx_ring.buf_size); free_dma(priv->tx_ring.buf, priv->tx_ring.buf_size);
iounmap(priv->tx_ring.txcq_db); iounmap(priv->tx_ring.txcq_db);
free_memblock(priv->cq[1].buf, priv->cq[1].buf_size); free_dma(priv->cq[1].buf, priv->cq[1].buf_size);
free_memblock(priv->cq[1].db, sizeof(struct mtnic_cq_db_record)); free_dma(priv->cq[1].db, sizeof(struct mtnic_cq_db_record));
free_memblock(priv->rx_ring.buf, priv->rx_ring.buf_size); free_dma(priv->rx_ring.buf, priv->rx_ring.buf_size);
free_memblock(priv->rx_ring.db, sizeof(struct mtnic_cq_db_record)); free_dma(priv->rx_ring.db, sizeof(struct mtnic_cq_db_record));
free_memblock(priv->cq[0].buf, priv->cq[0].buf_size); free_dma(priv->cq[0].buf, priv->cq[0].buf_size);
free_memblock(priv->cq[0].db, sizeof(struct mtnic_cq_db_record)); free_dma(priv->cq[0].db, sizeof(struct mtnic_cq_db_record));
/* Free RX buffers */ /* Free RX buffers */
mtnic_free_io_buffers(&priv->rx_ring); mtnic_free_io_buffers(&priv->rx_ring);
@ -1682,11 +1682,11 @@ mtnic_disable(struct pci_device *pci)
DBG("Error Releasing resources %d\n", err); DBG("Error Releasing resources %d\n", err);
} }
free_memblock(mtnic->cmd.buf, PAGE_SIZE); free_dma(mtnic->cmd.buf, PAGE_SIZE);
iounmap(mtnic->hcr); iounmap(mtnic->hcr);
ufree((intptr_t)mtnic->fw.fw_pages.buf); ufree((intptr_t)mtnic->fw.fw_pages.buf);
ufree((intptr_t)mtnic->fw.extra_pages.buf); ufree((intptr_t)mtnic->fw.extra_pages.buf);
free_memblock(mtnic->eq.buf, mtnic->eq.buf_size); free_dma(mtnic->eq.buf, mtnic->eq.buf_size);
iounmap(mtnic->eq_db); iounmap(mtnic->eq_db);