myri10ge: use pci_map_page to prepare the dmatest buffer

Allocate a specific page and use pci_map_page for dma test instead
of relying on another existing buffer.

Signed-off-by: Brice Goglin <brice@myri.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
This commit is contained in:
Brice Goglin 2007-03-07 20:00:45 +01:00 коммит произвёл Jeff Garzik
Родитель 355c7265f4
Коммит 34fdccea93
1 изменённых файлов: 16 добавлений и 6 удалений

Просмотреть файл

@ -717,6 +717,8 @@ static int myri10ge_reset(struct myri10ge_priv *mgp)
int status; int status;
size_t bytes; size_t bytes;
u32 len; u32 len;
struct page *dmatest_page;
dma_addr_t dmatest_bus;
/* try to send a reset command to the card to see if it /* try to send a reset command to the card to see if it
* is alive */ * is alive */
@ -726,6 +728,11 @@ static int myri10ge_reset(struct myri10ge_priv *mgp)
dev_err(&mgp->pdev->dev, "failed reset\n"); dev_err(&mgp->pdev->dev, "failed reset\n");
return -ENXIO; return -ENXIO;
} }
dmatest_page = alloc_page(GFP_KERNEL);
if (!dmatest_page)
return -ENOMEM;
dmatest_bus = pci_map_page(mgp->pdev, dmatest_page, 0, PAGE_SIZE,
DMA_BIDIRECTIONAL);
/* Now exchange information about interrupts */ /* Now exchange information about interrupts */
@ -764,8 +771,8 @@ static int myri10ge_reset(struct myri10ge_priv *mgp)
len = mgp->tx.boundary; len = mgp->tx.boundary;
cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->rx_done.bus); cmd.data0 = MYRI10GE_LOWPART_TO_U32(dmatest_bus);
cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->rx_done.bus); cmd.data1 = MYRI10GE_HIGHPART_TO_U32(dmatest_bus);
cmd.data2 = len * 0x10000; cmd.data2 = len * 0x10000;
status = myri10ge_send_cmd(mgp, MXGEFW_DMA_TEST, &cmd, 0); status = myri10ge_send_cmd(mgp, MXGEFW_DMA_TEST, &cmd, 0);
if (status == 0) if (status == 0)
@ -774,8 +781,8 @@ static int myri10ge_reset(struct myri10ge_priv *mgp)
else else
dev_warn(&mgp->pdev->dev, "DMA read benchmark failed: %d\n", dev_warn(&mgp->pdev->dev, "DMA read benchmark failed: %d\n",
status); status);
cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->rx_done.bus); cmd.data0 = MYRI10GE_LOWPART_TO_U32(dmatest_bus);
cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->rx_done.bus); cmd.data1 = MYRI10GE_HIGHPART_TO_U32(dmatest_bus);
cmd.data2 = len * 0x1; cmd.data2 = len * 0x1;
status = myri10ge_send_cmd(mgp, MXGEFW_DMA_TEST, &cmd, 0); status = myri10ge_send_cmd(mgp, MXGEFW_DMA_TEST, &cmd, 0);
if (status == 0) if (status == 0)
@ -785,8 +792,8 @@ static int myri10ge_reset(struct myri10ge_priv *mgp)
dev_warn(&mgp->pdev->dev, "DMA write benchmark failed: %d\n", dev_warn(&mgp->pdev->dev, "DMA write benchmark failed: %d\n",
status); status);
cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->rx_done.bus); cmd.data0 = MYRI10GE_LOWPART_TO_U32(dmatest_bus);
cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->rx_done.bus); cmd.data1 = MYRI10GE_HIGHPART_TO_U32(dmatest_bus);
cmd.data2 = len * 0x10001; cmd.data2 = len * 0x10001;
status = myri10ge_send_cmd(mgp, MXGEFW_DMA_TEST, &cmd, 0); status = myri10ge_send_cmd(mgp, MXGEFW_DMA_TEST, &cmd, 0);
if (status == 0) if (status == 0)
@ -796,6 +803,9 @@ static int myri10ge_reset(struct myri10ge_priv *mgp)
dev_warn(&mgp->pdev->dev, dev_warn(&mgp->pdev->dev,
"DMA read/write benchmark failed: %d\n", status); "DMA read/write benchmark failed: %d\n", status);
pci_unmap_page(mgp->pdev, dmatest_bus, PAGE_SIZE, DMA_BIDIRECTIONAL);
put_page(dmatest_page);
memset(mgp->rx_done.entry, 0, bytes); memset(mgp->rx_done.entry, 0, bytes);
/* reset mcp/driver shared state back to 0 */ /* reset mcp/driver shared state back to 0 */