DMA, CMA, coherence and performance

saumendra dash saumendradash at gmail.com
Mon Jan 6 04:29:32 EST 2014


For streaming DMA, you can use the function dma_map_single().
Alternatively, you can create your own DMA pool using dma_pool_create(),
and allocate memory from that using dma_pool_alloc(().

The later case will be more suitable for you, since you want a 8MB DMA
buffer for your DMA.
Hope that helps/

Thanks,
Saumendra


On Mon, Jan 6, 2014 at 11:48 AM, Steven Bell <botsnlinux at gmail.com> wrote:

>
> On Sun, Jan 5, 2014 at 8:02 AM, Peter Teoh <htmldeveloper at gmail.com>wrote:
>
>> I think this discussion should help you:
>>
>> http://e2e.ti.com/support/embedded/linux/f/354/t/89419.aspx
>>
>> other failures:
>>
>> http://stackoverflow.com/questions/14625919/allocating-a-large-dma-buffer
>>
>> and some guideline here:
>>
>> https://www.kernel.org/doc/Documentation/DMA-API.txt
>>
>> https://lkml.org/lkml/2011/3/25/19
>>
>> As I don't have any specific crashdump or error information, nothing I
>> can comment further about your problem.   It is quite difficult to make
>> general comment.
>>
>>
>>
>> On Fri, Jan 3, 2014 at 7:20 AM, Steven Bell <botsnlinux at gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I'm working on a device driver for a video device which continuously
>>> reads and writes image frames using DMA. The frames are fairly large, in
>>> the range of 2-8MB, and I would like the buffers for them to be contiguous
>>> because of my hardware. My understanding is that using the contiguous
>>> memory allocator is the current "right way" to get the buffers, and that
>>> CMA operates entirely behind the scenes when calls are made to
>>> dma_alloc_coherent().
>>>
>>> However, it seems that for this system, a streaming DMA setup would be
>>> more appropriate.  The buffer gets filled with data once, handed to the
>>> device, and then isn't touched again until it gets reused with new data.
>>> The resources I've read have hinted that streaming DMA has some performance
>>> benefits over coherent DMA, so this seems like the way to go.  But I
>>> haven't seen any discussion of how to use CMA with streaming DMA (or
>>> whether such a thing is even necessary).
>>>
>>> Does the CMA also work behind get_free_pages, or other kernel memory
>>> allocation methods?  Does it matter?  The kernel newbies page on memory
>>> allocation (http://kernelnewbies.org/KernelMemoryAllocation) says that
>>> get_free_pages up to about 8MB are ok.  Is that a generalization based on
>>> typical memory fragmentation, or a guarantee?
>>>
>>> Thanks,
>>> Steven
>>>
>>> _______________________________________________
>>> Kernelnewbies mailing list
>>> Kernelnewbies at kernelnewbies.org
>>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>>
>>>
>>
>>
>> --
>> Regards,
>> Peter Teoh
>>
>
> Thanks for the reply and the links.  Unfortunately, they don't really
> answer my basic question - which is a general conceptual question, not a
> specific error or problem that I'm running into.
>
> I want to allocate a contiguous 8MB buffer and use it for streaming DMA.
> I don't need or want a coherent buffer, since I'm using streaming DMA, and
> so dma_alloc_coherent() seems like the wrong method to use.  Is that true,
> or should I use it anyway?  If not, what method do I use?
>
> The DMA-API and DMA-API-HOWTO documents don't seem to say anything about
> allocating memory for streaming DMA operations.  Have I missed something?
>
> Thanks,
> Steven
>
>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140106/d4595c6f/attachment-0001.html 


More information about the Kernelnewbies mailing list