Commit 64dc81fc authored by Roland Dreier's avatar Roland Dreier Committed by Linus Torvalds

[PATCH] IB/mthca: Use dma_alloc_coherent instead of pci_alloc_consistent

Switch all allocations of coherent memory from pci_alloc_consistent() to
dma_alloc_coherent(), so that we can pass GFP_KERNEL.  This should help when
the system is low on memory.
Signed-off-by: default avatarRoland Dreier <roland@topspin.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent bb2af78b
...@@ -636,7 +636,7 @@ static void mthca_free_cq_buf(struct mthca_dev *dev, struct mthca_cq *cq) ...@@ -636,7 +636,7 @@ static void mthca_free_cq_buf(struct mthca_dev *dev, struct mthca_cq *cq)
int size; int size;
if (cq->is_direct) if (cq->is_direct)
pci_free_consistent(dev->pdev, dma_free_coherent(&dev->pdev->dev,
(cq->ibcq.cqe + 1) * MTHCA_CQ_ENTRY_SIZE, (cq->ibcq.cqe + 1) * MTHCA_CQ_ENTRY_SIZE,
cq->queue.direct.buf, cq->queue.direct.buf,
pci_unmap_addr(&cq->queue.direct, pci_unmap_addr(&cq->queue.direct,
...@@ -645,7 +645,7 @@ static void mthca_free_cq_buf(struct mthca_dev *dev, struct mthca_cq *cq) ...@@ -645,7 +645,7 @@ static void mthca_free_cq_buf(struct mthca_dev *dev, struct mthca_cq *cq)
size = (cq->ibcq.cqe + 1) * MTHCA_CQ_ENTRY_SIZE; size = (cq->ibcq.cqe + 1) * MTHCA_CQ_ENTRY_SIZE;
for (i = 0; i < (size + PAGE_SIZE - 1) / PAGE_SIZE; ++i) for (i = 0; i < (size + PAGE_SIZE - 1) / PAGE_SIZE; ++i)
if (cq->queue.page_list[i].buf) if (cq->queue.page_list[i].buf)
pci_free_consistent(dev->pdev, PAGE_SIZE, dma_free_coherent(&dev->pdev->dev, PAGE_SIZE,
cq->queue.page_list[i].buf, cq->queue.page_list[i].buf,
pci_unmap_addr(&cq->queue.page_list[i], pci_unmap_addr(&cq->queue.page_list[i],
mapping)); mapping));
...@@ -668,8 +668,8 @@ static int mthca_alloc_cq_buf(struct mthca_dev *dev, int size, ...@@ -668,8 +668,8 @@ static int mthca_alloc_cq_buf(struct mthca_dev *dev, int size,
npages = 1; npages = 1;
shift = get_order(size) + PAGE_SHIFT; shift = get_order(size) + PAGE_SHIFT;
cq->queue.direct.buf = pci_alloc_consistent(dev->pdev, cq->queue.direct.buf = dma_alloc_coherent(&dev->pdev->dev,
size, &t); size, &t, GFP_KERNEL);
if (!cq->queue.direct.buf) if (!cq->queue.direct.buf)
return -ENOMEM; return -ENOMEM;
...@@ -707,7 +707,8 @@ static int mthca_alloc_cq_buf(struct mthca_dev *dev, int size, ...@@ -707,7 +707,8 @@ static int mthca_alloc_cq_buf(struct mthca_dev *dev, int size,
for (i = 0; i < npages; ++i) { for (i = 0; i < npages; ++i) {
cq->queue.page_list[i].buf = cq->queue.page_list[i].buf =
pci_alloc_consistent(dev->pdev, PAGE_SIZE, &t); dma_alloc_coherent(&dev->pdev->dev, PAGE_SIZE,
&t, GFP_KERNEL);
if (!cq->queue.page_list[i].buf) if (!cq->queue.page_list[i].buf)
goto err_free; goto err_free;
......
...@@ -501,8 +501,8 @@ static int __devinit mthca_create_eq(struct mthca_dev *dev, ...@@ -501,8 +501,8 @@ static int __devinit mthca_create_eq(struct mthca_dev *dev,
eq_context = MAILBOX_ALIGN(mailbox); eq_context = MAILBOX_ALIGN(mailbox);
for (i = 0; i < npages; ++i) { for (i = 0; i < npages; ++i) {
eq->page_list[i].buf = pci_alloc_consistent(dev->pdev, eq->page_list[i].buf = dma_alloc_coherent(&dev->pdev->dev,
PAGE_SIZE, &t); PAGE_SIZE, &t, GFP_KERNEL);
if (!eq->page_list[i].buf) if (!eq->page_list[i].buf)
goto err_out_free; goto err_out_free;
...@@ -582,7 +582,7 @@ static int __devinit mthca_create_eq(struct mthca_dev *dev, ...@@ -582,7 +582,7 @@ static int __devinit mthca_create_eq(struct mthca_dev *dev,
err_out_free: err_out_free:
for (i = 0; i < npages; ++i) for (i = 0; i < npages; ++i)
if (eq->page_list[i].buf) if (eq->page_list[i].buf)
pci_free_consistent(dev->pdev, PAGE_SIZE, dma_free_coherent(&dev->pdev->dev, PAGE_SIZE,
eq->page_list[i].buf, eq->page_list[i].buf,
pci_unmap_addr(&eq->page_list[i], pci_unmap_addr(&eq->page_list[i],
mapping)); mapping));
......
...@@ -934,7 +934,8 @@ static int mthca_alloc_wqe_buf(struct mthca_dev *dev, ...@@ -934,7 +934,8 @@ static int mthca_alloc_wqe_buf(struct mthca_dev *dev,
mthca_dbg(dev, "Creating direct QP of size %d (shift %d)\n", mthca_dbg(dev, "Creating direct QP of size %d (shift %d)\n",
size, shift); size, shift);
qp->queue.direct.buf = pci_alloc_consistent(dev->pdev, size, &t); qp->queue.direct.buf = dma_alloc_coherent(&dev->pdev->dev, size,
&t, GFP_KERNEL);
if (!qp->queue.direct.buf) if (!qp->queue.direct.buf)
goto err_out; goto err_out;
...@@ -973,7 +974,8 @@ static int mthca_alloc_wqe_buf(struct mthca_dev *dev, ...@@ -973,7 +974,8 @@ static int mthca_alloc_wqe_buf(struct mthca_dev *dev,
for (i = 0; i < npages; ++i) { for (i = 0; i < npages; ++i) {
qp->queue.page_list[i].buf = qp->queue.page_list[i].buf =
pci_alloc_consistent(dev->pdev, PAGE_SIZE, &t); dma_alloc_coherent(&dev->pdev->dev, PAGE_SIZE,
&t, GFP_KERNEL);
if (!qp->queue.page_list[i].buf) if (!qp->queue.page_list[i].buf)
goto err_out_free; goto err_out_free;
...@@ -996,13 +998,12 @@ static int mthca_alloc_wqe_buf(struct mthca_dev *dev, ...@@ -996,13 +998,12 @@ static int mthca_alloc_wqe_buf(struct mthca_dev *dev,
err_out_free: err_out_free:
if (qp->is_direct) { if (qp->is_direct) {
pci_free_consistent(dev->pdev, size, dma_free_coherent(&dev->pdev->dev, size, qp->queue.direct.buf,
qp->queue.direct.buf,
pci_unmap_addr(&qp->queue.direct, mapping)); pci_unmap_addr(&qp->queue.direct, mapping));
} else } else
for (i = 0; i < npages; ++i) { for (i = 0; i < npages; ++i) {
if (qp->queue.page_list[i].buf) if (qp->queue.page_list[i].buf)
pci_free_consistent(dev->pdev, PAGE_SIZE, dma_free_coherent(&dev->pdev->dev, PAGE_SIZE,
qp->queue.page_list[i].buf, qp->queue.page_list[i].buf,
pci_unmap_addr(&qp->queue.page_list[i], pci_unmap_addr(&qp->queue.page_list[i],
mapping)); mapping));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment