Skip to content

Commit a41ef05

Browse files
davejiangjonmason
authored andcommitted
NTB: Default to CPU memcpy for performance
Disable DMA usage by default, since the CPU provides much better performance with write combining. Provide a module parameter to enable DMA usage when offloading the memcpy is preferred. Signed-off-by: Dave Jiang <[email protected]> Signed-off-by: Allen Hubbe <[email protected]> Signed-off-by: Jon Mason <[email protected]>
1 parent 06917f7 commit a41ef05

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

drivers/ntb/ntb_transport.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ static unsigned int copy_bytes = 1024;
8888
module_param(copy_bytes, uint, 0644);
8989
MODULE_PARM_DESC(copy_bytes, "Threshold under which NTB will use the CPU to copy instead of DMA");
9090

91+
static bool use_dma;
92+
module_param(use_dma, bool, 0644);
93+
MODULE_PARM_DESC(use_dma, "Use DMA engine to perform large data copy");
94+
9195
static struct dentry *nt_debugfs_dir;
9296

9397
struct ntb_queue_entry {
@@ -1589,10 +1593,15 @@ ntb_transport_create_queue(void *data, struct device *client_dev,
15891593
dma_cap_zero(dma_mask);
15901594
dma_cap_set(DMA_MEMCPY, dma_mask);
15911595

1592-
qp->dma_chan = dma_request_channel(dma_mask, ntb_dma_filter_fn,
1593-
(void *)(unsigned long)node);
1594-
if (!qp->dma_chan)
1595-
dev_info(&pdev->dev, "Unable to allocate DMA channel, using CPU instead\n");
1596+
if (use_dma) {
1597+
qp->dma_chan = dma_request_channel(dma_mask, ntb_dma_filter_fn,
1598+
(void *)(unsigned long)node);
1599+
if (!qp->dma_chan)
1600+
dev_info(&pdev->dev, "Unable to allocate DMA channel\n");
1601+
} else {
1602+
qp->dma_chan = NULL;
1603+
}
1604+
dev_dbg(&pdev->dev, "Using %s memcpy\n", qp->dma_chan ? "DMA" : "CPU");
15961605

15971606
for (i = 0; i < NTB_QP_DEF_NUM_ENTRIES; i++) {
15981607
entry = kzalloc_node(sizeof(*entry), GFP_ATOMIC, node);

0 commit comments

Comments
 (0)