[alsa-devel] Query regarding snd_pcm_lib_preallocate_pages_for_all()

Pharaoh . pharaoh137 at gmail.com
Wed Nov 14 13:13:21 CET 2007


On Nov 14, 2007 1:44 PM, Takashi Iwai <tiwai at suse.de> wrote:

> At Wed, 14 Nov 2007 00:12:07 +0530,
> Pharaoh . wrote:
> >
> > Hi,
> >
> > I am trying to use snd_pcm_lib_preallocate_pages_for_all() on an arm
> based
> > platform for preallocating the DMA buffer.
> > I am using it as
> >
> > snd_pcm_lib_preallocate_pages_for_all(pcm,
> >             SNDRV_DMA_TYPE_DEV,
> >             NULL,
> >             64 * 1024, 64 * 1024);
> >
> > since I dont know what should be passed as the 3'rd param. I tried
> passing
> > my device pointer i.e. card->dev after
> > correctly populating it but I get an error as 'DMA coherent mask in not
> set'
> > and buffer is not allocated.
>
> For ARM, avoid the present buffer-preallocation and mmap functions in
> ALSA core.  Instead you can allocate the buffers directly via normal
> dma_alloc_coherent() in your driver.  And, mmap it via
> dma_mmap_coherent() by defining the own mmap callback for PCM ops.
>
> See other arm/* drivers for rerecence.
>
>
> Takashi
>

Yes, I am using my own buffer preallocation scheme now. I allocate a 128K
buffer using dma_alloc_coherent in probe and free it only in remove i.e. at
rmmod time.

I dont think keeping a huge buffer like this till driver removal is a good
idea but when I allocate/deallocate it in hw_params/hw_free respectively, it
is causing fragmentation and sometimes the allocation fails. Do you think
anything better can
be done?

-pharaoh.


More information about the Alsa-devel mailing list