Skip to content

Commit

Permalink
NTB: correct dmaengine_get/put usage
Browse files Browse the repository at this point in the history
dmaengine_get() causes the initialization of the per-cpu channel tables.
It needs to be called prior to dma_find_channel().

Initial version by Dan Williams <dan.j.williams@intel.com>

Signed-off-by: Jon Mason <jon.mason@intel.com>
  • Loading branch information
Jon Mason committed Nov 20, 2013
1 parent fca4d51 commit 9468119
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/ntb/ntb_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -1419,11 +1419,12 @@ ntb_transport_create_queue(void *data, struct pci_dev *pdev,
qp->tx_handler = handlers->tx_handler;
qp->event_handler = handlers->event_handler;

dmaengine_get();
qp->dma_chan = dma_find_channel(DMA_MEMCPY);
if (!qp->dma_chan)
if (!qp->dma_chan) {
dmaengine_put();
dev_info(&pdev->dev, "Unable to allocate DMA channel, using CPU instead\n");
else
dmaengine_get();
}

for (i = 0; i < NTB_QP_DEF_NUM_ENTRIES; i++) {
entry = kzalloc(sizeof(struct ntb_queue_entry), GFP_ATOMIC);
Expand Down Expand Up @@ -1464,6 +1465,8 @@ ntb_transport_create_queue(void *data, struct pci_dev *pdev,
err1:
while ((entry = ntb_list_rm(&qp->ntb_rx_free_q_lock, &qp->rx_free_q)))
kfree(entry);
if (qp->dma_chan)
dmaengine_put();
set_bit(free_queue, &nt->qp_bitmap);
err:
return NULL;
Expand Down

0 comments on commit 9468119

Please sign in to comment.