How to use Linux dmaengine (via SDMA) to do memory-to-memory copy?

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use Linux dmaengine (via SDMA) to do memory-to-memory copy?

Jump to solution
5,193 Views
bikenomad
Contributor III

I'm writing a Linux kernel driver that must transfer up to 512KB of data from an FPGA (connected via the i.mx53's EIM) to a memory buffer.

I have it working with memcpy() right now, but need to use DMA to offload the copying from the CPU.

The FPGA has been mapped such that it can be read as a 512KB contiguous region of memory, and the EIM is set up so that it does not do burst/page accesses to the FPGA.

The 512KB destination buffer has been allocated using dma_alloc_coherent(), and the FPGA's read address range has been made available using dev_ioremap_nocache().

I  would like to use the generic Linux DMA layer (the dmaengine) rather than talk to the imx-sdma driver for best portability in the future.

 

However, my attempts to get DMA working have been met with kernel crashes and/or a lack of access to the FPGA (I have an oscilloscope connected that will show when the FPGA RAM addresses are accessed).

 

I'm using the 2.6.38 kernel, if it matters.

 

I've attached a greatly simplified version of my code (with error handling and other stuff removed) that shows the DMA-related operations.

 

Could anyone suggest a fix that might get this working?

 

Thanks...

Original Attachment has been moved to: dma_example.c.zip

Labels (2)
Tags (4)
1 Solution
459 Views
bikenomad
Contributor III

I gave up and moved to the 2.6.35 kernel maintenance branch from the Freescale git repository.

I used the sample SDMA test driver code from the imx-test package as an example, and got it working.

The downside is that my code is now using the Freescale-specific mxc_dma routines, which are even more unstable than the Linux-standard dmaengine layer. So if we ever have to move off 2.6.35 for any reason, we'll have to port the driver again.

View solution in original post

0 Kudos
4 Replies
459 Views
bikenomad
Contributor III

I actually had some problems with doing multiple-buffer transfers, and will try re-doing the code to just set up a single transfer and then start the next chunk when the prior chunk has finished (triggering from the callback).

0 Kudos
459 Views
sedat_altun
Contributor III

Hi Mr. Konz,

We are also try to transfer data from FPGA to cpu memory. We are using imx-tespackage from 3.0.35. And using the mxc_memcopy_test.c code. I just replace wbuf with FPGA Physical address but I got core dump, unable to handle paging request at address FPGA Phyical address. I couldnt find any solution if you can help us we will be very appreciated.

I will be very appreciated if you send us the sample code of SDMA.

Thank you very much.

0 Kudos
460 Views
bikenomad
Contributor III

I gave up and moved to the 2.6.35 kernel maintenance branch from the Freescale git repository.

I used the sample SDMA test driver code from the imx-test package as an example, and got it working.

The downside is that my code is now using the Freescale-specific mxc_dma routines, which are even more unstable than the Linux-standard dmaengine layer. So if we ever have to move off 2.6.35 for any reason, we'll have to port the driver again.

View solution in original post

0 Kudos
459 Views
DraganOstojic
Contributor V

Ned, can you post your sample dma code? I also want to accelerate memcpy() with dma on imx? Can you also post the link to sample SDMA test driver code from the imx-test package?

0 Kudos