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?
Thanks, Ranjani