<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 20, 2016 at 12:26 PM, Greg KH <span dir="ltr"><<a href="mailto:greg@kroah.com" target="_blank">greg@kroah.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div class="HOEnZb"><div class="h5">On Tue, Dec 20, 2016 at 12:15:22PM +0200, Ran Shalit wrote:<br>
> On Tue, Dec 20, 2016 at 11:38 AM, Greg KH <<a href="mailto:greg@kroah.com">greg@kroah.com</a>> wrote:<br>
> > On Mon, Dec 19, 2016 at 06:08:47PM +0200, Ran Shalit wrote:<br>
> >> Hello,<br>
> >><br>
> >> I want to use DMA from userspace.<br>
> ><br>
> > Why?<br>
><br>
> Hi Greg,<br>
><br>
> We want that a userspace layer (a library) will do some HW related issues.<br>
> We have a memory mapped space (from FPGA), so we think it will be<br>
> easier, and I think also more correct way , that we create the driver,<br>
> and interact hadrware using the mapped memory space, and also do the<br>
> protocols in userspace. The only thing that is less easy in userspace<br>
> is using interrupt, and dma. but that is also possible if we just wrap<br>
> the dma, and interrupt in a character device (or use uio as you<br>
> suggested below).<br>
> ><br>
> >> I already use dma in kernel, and now I want can create a character<br>
> >> device which will be responsible for this.<br>
> ><br>
> > Why?<br>
> ><br>
> >> The only problem is that I want to use the same memory which was<br>
> >> allocated in kernel with dma_alloc_coherent.<br>
> ><br>
> > Why?<br>
><br>
> in kernel we use dma_alloc_coherent, which returns contiguous memory.<br>
> As I understand, we can mmap in userspace the returned physical<br>
> address, and use the returned virtual address in userspace.<br>
><br>
><br>
> ><br>
> >> Is it correct to use mmap in order to use the phsyical memory which<br>
> >> was allocated with dma_alloc_coherent ?<br>
> >><br>
> >> If it's that simple it can be surely helpful, and the simple driver<br>
> >> which wraps dma_alloc_coherent can do the job for dmaing from<br>
> >> userspace.<br>
> ><br>
> > Have you looked at the uio driver interface?<br>
> ><br>
> > But again, why? What problem are you trying to solve here?<br>
><br>
> We need to do some interaction with HW , but since most of the HW is<br>
> mapped to physical address (FPGA), it seem simpler to do that in<br>
> userspace (HW library), instead of doing this in kernel. What do you<br>
> think ?<br>
<br>
</div></div>I think you should use the UIO driver api, as that's exactly what it was<br>
written for. Have you looked at it yet? It handles your interrupt<br>
logic for you.<br>
<br></blockquote><div>Hello,</div><div><br></div><div>If I may please ask, I made some reading about uio, but didn't yet understand what's the benefit of using uio instead of creating a character device ? </div><div><br></div><div>Thanks,</div><div>Ran</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
thanks,<br>
<br>
greg k-h<br>
</blockquote></div><br></div></div>