Subject: Re: DMA to User-Space

From: Tonyliu <[email-masked]>
Date: Wed, 04 Nov 2009 10:19:12 +0800

Jonathan Haws wrote:
> All,
>
> I have what may be an unconventional question:
>
> Our application consists of data being captured by an FPGA, processed, and transferred to SDRAM.  I simply give the FPGA an address of where I want it stored in SDRAM and it simply DMAs the data over and interrupts me when finished.  I then take that data and store it to disk.
>
> I have code in user space that handles all of the writing to disk nicely and fast enough for my application (I am capturing data at about 35-40 Mbytes/sec).
>
> My question is this:  is it possible to give a user-space pointer to the FPGA to DMA to?  It seems like I would have problems with alignment, address manipulation, and a whole slew of other issues.
>   
> What would be the best way to accomplish something like that?  I want to handle all the disk access in user-space, but I do not want to have to copy 40 MB/s from kernel space to user-space either.
>   
You can maintain a DMA buffer in kernel, then mmap to user space. And 
maybe you need some handshake between FPGA and the apps to balance input 
datas  with datas to disk.
> I can maintain an allocated, DMA-safe buffer in kernel space if needed.  Can I simply get a user-space pointer to that buffer?  What calls are needed to translate addresses?
>   
Use remap_pfn_range()  in your kernel DMA buffer manipulation driver 
.mmap() handler to export DMA  buffer address to user space.

Tony
> Thanks for the help!  I am still a newbie when it comes to kernel programming, so I really appreciate the help!
>
> Jonathan
>
>
>
> _______________________________________________
> Linuxppc-dev mailing list
> [email-masked]
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>
>   

-- 
Tony Liu | Liu Bo
-------------------------------------------------------------
WIND RIVER | China Development Center
Tel: 86-10-8477-8542 ext: 8542 |  Fax: 86-10-64790367
(M): 86-136-7117-3612
Address: 15/F, Wangjing TowerB, Chaoyang District, Beijing, P.R.China