IB/amso1100: Use dma_alloc_coherent() instead of kmalloc/dma_map_single
The Ammasso driver needs to use dma_alloc_coherent() for allocating memory that will be used by the HW for dma. Signed-off-by: Steve Wise <swise@opengridcomputing.com> Signed-off-by: Roland Dreier <rolandd@cisco.com>
This commit is contained in:
committed by
Roland Dreier
parent
04d03bc576
commit
8de94ce19d
@@ -42,13 +42,14 @@ static int c2_alloc_mqsp_chunk(struct c2_dev *c2dev, gfp_t gfp_mask,
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct sp_chunk *new_head;
|
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)
|
if (new_head == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
new_head->dma_addr = dma_map_single(c2dev->ibdev.dma_device, new_head,
|
new_head->dma_addr = dma_addr;
|
||||||
PAGE_SIZE, DMA_FROM_DEVICE);
|
|
||||||
pci_unmap_addr_set(new_head, mapping, new_head->dma_addr);
|
pci_unmap_addr_set(new_head, mapping, new_head->dma_addr);
|
||||||
|
|
||||||
new_head->next = NULL;
|
new_head->next = NULL;
|
||||||
@@ -80,10 +81,8 @@ void c2_free_mqsp_pool(struct c2_dev *c2dev, struct sp_chunk *root)
|
|||||||
|
|
||||||
while (root) {
|
while (root) {
|
||||||
next = root->next;
|
next = root->next;
|
||||||
dma_unmap_single(c2dev->ibdev.dma_device,
|
dma_free_coherent(&c2dev->pcidev->dev, PAGE_SIZE, root,
|
||||||
pci_unmap_addr(root, mapping), PAGE_SIZE,
|
pci_unmap_addr(root, mapping));
|
||||||
DMA_FROM_DEVICE);
|
|
||||||
__free_page((struct page *) root);
|
|
||||||
root = next;
|
root = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -246,20 +246,17 @@ int c2_arm_cq(struct ib_cq *ibcq, enum ib_cq_notify notify)
|
|||||||
|
|
||||||
static void c2_free_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq)
|
static void c2_free_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq)
|
||||||
{
|
{
|
||||||
|
dma_free_coherent(&c2dev->pcidev->dev, mq->q_size * mq->msg_size,
|
||||||
dma_unmap_single(c2dev->ibdev.dma_device, pci_unmap_addr(mq, mapping),
|
mq->msg_pool.host, 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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int c2_alloc_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq, int q_size,
|
static int c2_alloc_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq, int q_size,
|
||||||
int msg_size)
|
int msg_size)
|
||||||
{
|
{
|
||||||
unsigned long pool_start;
|
u8 *pool_start;
|
||||||
|
|
||||||
pool_start = __get_free_pages(GFP_KERNEL,
|
pool_start = dma_alloc_coherent(&c2dev->pcidev->dev, q_size * msg_size,
|
||||||
get_order(q_size * msg_size));
|
&mq->host_dma, GFP_KERNEL);
|
||||||
if (!pool_start)
|
if (!pool_start)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@@ -267,13 +264,10 @@ static int c2_alloc_cq_buf(struct c2_dev *c2dev, struct c2_mq *mq, int q_size,
|
|||||||
0, /* index (currently unknown) */
|
0, /* index (currently unknown) */
|
||||||
q_size,
|
q_size,
|
||||||
msg_size,
|
msg_size,
|
||||||
(u8 *) pool_start,
|
pool_start,
|
||||||
NULL, /* peer (currently unknown) */
|
NULL, /* peer (currently unknown) */
|
||||||
C2_MQ_HOST_TARGET);
|
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);
|
pci_unmap_addr_set(mq, mapping, mq->host_dma);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -517,14 +517,12 @@ int c2_rnic_init(struct c2_dev *c2dev)
|
|||||||
/* Initialize the Verbs Reply Queue */
|
/* Initialize the Verbs Reply Queue */
|
||||||
qsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q1_QSIZE));
|
qsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q1_QSIZE));
|
||||||
msgsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q1_MSGSIZE));
|
msgsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q1_MSGSIZE));
|
||||||
q1_pages = kmalloc(qsize * msgsize, GFP_KERNEL);
|
q1_pages = dma_alloc_coherent(&c2dev->pcidev->dev, qsize * msgsize,
|
||||||
|
&c2dev->rep_vq.host_dma, GFP_KERNEL);
|
||||||
if (!q1_pages) {
|
if (!q1_pages) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto bail1;
|
goto bail1;
|
||||||
}
|
}
|
||||||
c2dev->rep_vq.host_dma = dma_map_single(c2dev->ibdev.dma_device,
|
|
||||||
(void *)q1_pages, qsize * msgsize,
|
|
||||||
DMA_FROM_DEVICE);
|
|
||||||
pci_unmap_addr_set(&c2dev->rep_vq, mapping, c2dev->rep_vq.host_dma);
|
pci_unmap_addr_set(&c2dev->rep_vq, mapping, c2dev->rep_vq.host_dma);
|
||||||
pr_debug("%s rep_vq va %p dma %llx\n", __FUNCTION__, q1_pages,
|
pr_debug("%s rep_vq va %p dma %llx\n", __FUNCTION__, q1_pages,
|
||||||
(unsigned long long) c2dev->rep_vq.host_dma);
|
(unsigned long long) c2dev->rep_vq.host_dma);
|
||||||
@@ -540,14 +538,12 @@ int c2_rnic_init(struct c2_dev *c2dev)
|
|||||||
/* Initialize the Asynchronus Event Queue */
|
/* Initialize the Asynchronus Event Queue */
|
||||||
qsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q2_QSIZE));
|
qsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q2_QSIZE));
|
||||||
msgsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q2_MSGSIZE));
|
msgsize = be32_to_cpu(readl(mmio_regs + C2_REGS_Q2_MSGSIZE));
|
||||||
q2_pages = kmalloc(qsize * msgsize, GFP_KERNEL);
|
q2_pages = dma_alloc_coherent(&c2dev->pcidev->dev, qsize * msgsize,
|
||||||
|
&c2dev->aeq.host_dma, GFP_KERNEL);
|
||||||
if (!q2_pages) {
|
if (!q2_pages) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto bail2;
|
goto bail2;
|
||||||
}
|
}
|
||||||
c2dev->aeq.host_dma = dma_map_single(c2dev->ibdev.dma_device,
|
|
||||||
(void *)q2_pages, qsize * msgsize,
|
|
||||||
DMA_FROM_DEVICE);
|
|
||||||
pci_unmap_addr_set(&c2dev->aeq, mapping, c2dev->aeq.host_dma);
|
pci_unmap_addr_set(&c2dev->aeq, mapping, c2dev->aeq.host_dma);
|
||||||
pr_debug("%s aeq va %p dma %llx\n", __FUNCTION__, q1_pages,
|
pr_debug("%s aeq va %p dma %llx\n", __FUNCTION__, q1_pages,
|
||||||
(unsigned long long) c2dev->rep_vq.host_dma);
|
(unsigned long long) c2dev->rep_vq.host_dma);
|
||||||
@@ -597,17 +593,13 @@ int c2_rnic_init(struct c2_dev *c2dev)
|
|||||||
bail4:
|
bail4:
|
||||||
vq_term(c2dev);
|
vq_term(c2dev);
|
||||||
bail3:
|
bail3:
|
||||||
dma_unmap_single(c2dev->ibdev.dma_device,
|
dma_free_coherent(&c2dev->pcidev->dev,
|
||||||
pci_unmap_addr(&c2dev->aeq, mapping),
|
c2dev->aeq.q_size * c2dev->aeq.msg_size,
|
||||||
c2dev->aeq.q_size * c2dev->aeq.msg_size,
|
q2_pages, pci_unmap_addr(&c2dev->aeq, mapping));
|
||||||
DMA_FROM_DEVICE);
|
|
||||||
kfree(q2_pages);
|
|
||||||
bail2:
|
bail2:
|
||||||
dma_unmap_single(c2dev->ibdev.dma_device,
|
dma_free_coherent(&c2dev->pcidev->dev,
|
||||||
pci_unmap_addr(&c2dev->rep_vq, mapping),
|
c2dev->rep_vq.q_size * c2dev->rep_vq.msg_size,
|
||||||
c2dev->rep_vq.q_size * c2dev->rep_vq.msg_size,
|
q1_pages, pci_unmap_addr(&c2dev->rep_vq, mapping));
|
||||||
DMA_FROM_DEVICE);
|
|
||||||
kfree(q1_pages);
|
|
||||||
bail1:
|
bail1:
|
||||||
c2_free_mqsp_pool(c2dev, c2dev->kern_mqsp_pool);
|
c2_free_mqsp_pool(c2dev, c2dev->kern_mqsp_pool);
|
||||||
bail0:
|
bail0:
|
||||||
@@ -640,19 +632,17 @@ void c2_rnic_term(struct c2_dev *c2dev)
|
|||||||
/* Free the verbs request allocator */
|
/* Free the verbs request allocator */
|
||||||
vq_term(c2dev);
|
vq_term(c2dev);
|
||||||
|
|
||||||
/* Unmap and free the asynchronus event queue */
|
/* Free the asynchronus event queue */
|
||||||
dma_unmap_single(c2dev->ibdev.dma_device,
|
dma_free_coherent(&c2dev->pcidev->dev,
|
||||||
pci_unmap_addr(&c2dev->aeq, mapping),
|
c2dev->aeq.q_size * c2dev->aeq.msg_size,
|
||||||
c2dev->aeq.q_size * c2dev->aeq.msg_size,
|
c2dev->aeq.msg_pool.host,
|
||||||
DMA_FROM_DEVICE);
|
pci_unmap_addr(&c2dev->aeq, mapping));
|
||||||
kfree(c2dev->aeq.msg_pool.host);
|
|
||||||
|
|
||||||
/* Unmap and free the verbs reply queue */
|
/* Free the verbs reply queue */
|
||||||
dma_unmap_single(c2dev->ibdev.dma_device,
|
dma_free_coherent(&c2dev->pcidev->dev,
|
||||||
pci_unmap_addr(&c2dev->rep_vq, mapping),
|
c2dev->rep_vq.q_size * c2dev->rep_vq.msg_size,
|
||||||
c2dev->rep_vq.q_size * c2dev->rep_vq.msg_size,
|
c2dev->rep_vq.msg_pool.host,
|
||||||
DMA_FROM_DEVICE);
|
pci_unmap_addr(&c2dev->rep_vq, mapping));
|
||||||
kfree(c2dev->rep_vq.msg_pool.host);
|
|
||||||
|
|
||||||
/* Free the MQ shared pointer pool */
|
/* Free the MQ shared pointer pool */
|
||||||
c2_free_mqsp_pool(c2dev, c2dev->kern_mqsp_pool);
|
c2_free_mqsp_pool(c2dev, c2dev->kern_mqsp_pool);
|
||||||
|
Reference in New Issue
Block a user