DMA, CMA, coherence and performance

Steven Bell botsnlinux at gmail.com
Mon Jan 6 16:56:22 EST 2014


>> 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?

On Mon, Jan 6, 2014 at 1:29 AM, saumendra dash <saumendradash at gmail.com> wrote:
>
> 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/

I am using dma_map_single, but it doesn't allocate any memory.  From
what I understand, it takes a pointer to a buffer and performs the
necessary cache flushes or invalidations to make sure that the memory
is safe to DMA.  Is there a correct way to allocate large buffers for
streaming DMA?  Right now, I'm allocating memory with get_free_pages,
but that is prone to fail on large allocations, and only works up to
4MB on my system (i.e get_free_pages order 10).

>From reading LDD3 and DMA-API.txt, DMA pools are for allocating "small
dma-coherent memory regions".  LDD3 specifically states that pools are
useful where the driver needs regions smaller than 1 page.  Since I
want large, non-coherent buffers, I don't see how this helps.

Steven



More information about the Kernelnewbies mailing list