I am trying to use DMA engine in linux kernel.
My machine is x86 64-bit platform and I just want to offload simple memcpy operation to DMA engine. I was wondering if the following sequence is appropriate to active DMA engine and make it to do memcpy operation.
dmaengine_get();
dma_cap_zero(mask);
dma_cap_set(DMA_MEMCPY,mask);
chan = dma_request_channel(mask,NULL,NULL);
if(chan)
printk(KERN_ALERT "dma channel %s\n", dma_chan_name(ptr_DP->chan));
cookie_temp = dma_async_memcpy_pg_to_pg(chan, dest_pg, 0, src_pg, 0, 0x1000);
if(cookie_temp)
printk(KERN_ALERT "copy pass?\n")
.....
.....
curr_stat = dma_async_is_tx_complete(chan, cookie_temp, NULL, NULL);
printk(KERN_ALERT "check DMA stat (%d)\n", curr_stat);
/*
tx=async_memcpy(pages, pages, 0, 0, 4096, NULL);
printk(KERN_ALERT "DMA descriptor = %p\n",tx);
if(tx)
printk(KERN_ALERT "Working!\n");
else
printk(KERN_ALERT "No luck...\n");
*/
- Get dmaengine with
dmaengine_get
- Request channel with
dma_request_channel(mask, fn, fn_param)
- Use
dma_async_memcpy_pg_to_pg
to do page-to-page memcpy operation - Use
dma_async_is_tx_complete
to check if copy operation is completed
Edited 7/7 7:21PM
I checked DMA channel can be found by dma_find_channel()
.
But still my kernel does not work very well with dma_async_memcpy_pg_to_pg
...
When I check current status of DMA channel by dma_async_is_tx_complete
,
most of time it is still in progress status.
This is kind of weird because I am just copying one page ...