[alsa-devel] [PATCH 1/4] ALSA: memalloc: Allow NULL device for SNDRV_DMA_TYPE_CONTINOUS type

Takashi Iwai tiwai at suse.de
Tue Nov 5 19:46:26 CET 2019


On Tue, 05 Nov 2019 19:17:40 +0100,
Sridharan, Ranjani wrote:
> 
>     > >
>     > Hi Takashi,
>     >
>     > I have a question about the usage of snd_dma_alloc_pages() with the
>     > SNDRV_DMA_TYPE_DEV type. I am working on adding a platform-device for
>     > audio which is a child device of the top-level PCI device in SOF.
>     > When I use the handle for the platform-device as the "dev" argument for
>     > snd_dma_alloc_pages(), the dma alloc fails on some platforms (ex: Ice
>     > Lake). But it works fine if I use the top-level PCI device instead.
>     > Why would that be? Are there any restrictions to what devices can be
>     > used for dma alloc?
>    
>     This pretty much depends on the device.  Basically the ALSA memalloc
>     stuff simply calls dma_alloc_coherent() if the buffer type is
>     SNDRV_DMA_TYPE_DEV, and the rest goes deeply into the code in
>     kernel/dma/*.
>    
>     My wild guess is that the significant difference in your case is about
>     the DMA coherence mask set on the device.  As default the platform
>     device keeps 32bit DMA while the modern PCI drivers often sets up
>     64bit DMA mask.
> 
> Thanks, Takashi. So, in this case, would you recommend to always use the PCI
> device for dma alloc?

Yes, if the PCI bus is used in the backend, using the PCI device is a
better choice.


Takashi


More information about the Alsa-devel mailing list