[alsa-devel] DMA Physical Address through "snd_pcm_lib_malloc_pages"
Hello,
I am trying to allocate memory for DMA buffer through "snd_pcm_lib_malloc_pages" in hw_params callout function, with prior use of "snd_pcm_lib_preallocate_pages_for_all". The chapter on PCM Interface in "writing an ALSA driver" states that if the standard function "snd_pcm_lib_malloc_pages" is use for allocating the DMA buffers then the DMA fields of dma_addr, dma_area, dma_bytes are set by the ALSA middle layer.
However my code walk through didn't point me to the area where this physical memory setting is done. My DMA channel is not serving a PCI device. I would be very grateful if any of you guys can point me to the code where this settings get done by calling "snd_pcm_lib_malloc_pages". Going through the code for a few devices registered under "pci" I found that the call to "snd_pcm_lib_malloc_pages" is followed by call to "snd_pcm_sgbuf_get_addr" to get the physical address. Also a call to "__pa" is done in the "parisc/harmony.c".
Do I have to set the dma parameters in the runtime structure even after allocating memory using "snd_pcm_lib_malloc_pages"?
Regards; Aadish
At Thu, 24 Jun 2010 03:50:17 +0530, Adish Kuvelker wrote:
Hello,
I am trying to allocate memory for DMA buffer through "snd_pcm_lib_malloc_pages" in hw_params callout function, with prior use of "snd_pcm_lib_preallocate_pages_for_all". The chapter on PCM Interface in "writing an ALSA driver" states that if the standard function "snd_pcm_lib_malloc_pages" is use for allocating the DMA buffers then the DMA fields of dma_addr, dma_area, dma_bytes are set by the ALSA middle layer.
However my code walk through didn't point me to the area where this physical memory setting is done. My DMA channel is not serving a PCI device. I would be very grateful if any of you guys can point me to the code where this settings get done by calling "snd_pcm_lib_malloc_pages".
snd_pcm_lib_*_pages() works only with the preallocated buffers, and the pre-allocation can be done with the generic struct device, as long as the device (bus) supports dma_alloc_coherent() properly.
But this can be pretty arch-specific, so better to clarify more your hardware if you need detailed answers...
Takashi
Hello Takashi,
I am developing a DMA Controller driver to service the PCM out data to the Audio controller on the arm-based ATLASIII procesor. In case you need any more information on the architecture I can pass.
Since the DMA isn't on PCI bus I am pre-allocation continuous memero using the "snd_pcm_lib_preallocate_pages_for_all" passing SNDDRV_DMA_TYPE_DEV and "snd_dma_continuous_data" as appropriate parameters.
Would I still have to set the dma_addr value in my driver?
Regards; Aadish On Thu, Jun 24, 2010 at 12:07 PM, Takashi Iwai tiwai@suse.de wrote:
At Thu, 24 Jun 2010 03:50:17 +0530, Adish Kuvelker wrote:
Hello,
I am trying to allocate memory for DMA buffer through "snd_pcm_lib_malloc_pages" in hw_params callout function, with prior use of "snd_pcm_lib_preallocate_pages_for_all". The chapter on PCM Interface in "writing an ALSA driver" states that if the standard function "snd_pcm_lib_malloc_pages" is use for allocating the DMA buffers then the DMA fields of dma_addr, dma_area, dma_bytes are set by the ALSA middle layer.
However my code walk through didn't point me to the area where this physical memory setting is done. My DMA channel is not serving a PCI device. I would be very grateful if any of you guys can point me to the code where this settings get done by calling "snd_pcm_lib_malloc_pages".
snd_pcm_lib_*_pages() works only with the preallocated buffers, and the pre-allocation can be done with the generic struct device, as long as the device (bus) supports dma_alloc_coherent() properly.
But this can be pretty arch-specific, so better to clarify more your hardware if you need detailed answers...
Takashi
At Thu, 24 Jun 2010 12:38:35 +0530, Adish Kuvelker wrote:
Hello Takashi,
I am developing a DMA Controller driver to service the PCM out data to the Audio controller on the arm-based ATLASIII procesor. In case you need any more information on the architecture I can pass.
Since the DMA isn't on PCI bus I am pre-allocation continuous memero using the "snd_pcm_lib_preallocate_pages_for_all" passing SNDDRV_DMA_TYPE_DEV and "snd_dma_continuous_data" as appropriate parameters.
snd_dma_continuous_data() is only for SNDRV_DMA_TYPE_CONTINUOUS. In this case, the pages aren't for DMA.
For SNDRV_DMA_TYPE_DEV, simply pass the device pointer you use.
Takashi
Hello,
If I use "SNDRV_DMA_TYPE_CONTINUOUS" as a parameter to pre-allocate function to get contiguous locations of memory and use the function snd_dma_continuous_data() would that be correct setting for my case? Where are the parameters of dma_addr and dma_area written to the runtime structure?
Regards; Aadish
On Thu, Jun 24, 2010 at 12:45 PM, Takashi Iwai tiwai@suse.de wrote:
At Thu, 24 Jun 2010 12:38:35 +0530, Adish Kuvelker wrote:
Hello Takashi,
I am developing a DMA Controller driver to service the PCM out data to the Audio controller on the arm-based ATLASIII procesor. In case you need any more information on the architecture I can pass.
Since the DMA isn't on PCI bus I am pre-allocation continuous memero using the "snd_pcm_lib_preallocate_pages_for_all" passing SNDDRV_DMA_TYPE_DEV and "snd_dma_continuous_data" as appropriate parameters.
snd_dma_continuous_data() is only for SNDRV_DMA_TYPE_CONTINUOUS. In this case, the pages aren't for DMA.
For SNDRV_DMA_TYPE_DEV, simply pass the device pointer you use.
Takashi
At Thu, 24 Jun 2010 12:52:47 +0530, Adish Kuvelker wrote:
Hello,
If I use "SNDRV_DMA_TYPE_CONTINUOUS" as a parameter to pre-allocate function to get contiguous locations of memory and use the function snd_dma_continuous_data() would that be correct setting for my case?
I guess no. As mentioned, it's no DMA memory, i.e. simple pages allocated via __get_free_pages() and co.
Where are the parameters of dma_addr and dma_area written to the runtime structure?
These are available only for pages properly allocated for DMA.
Takashi
Regards; Aadish
On Thu, Jun 24, 2010 at 12:45 PM, Takashi Iwai tiwai@suse.de wrote:
At Thu, 24 Jun 2010 12:38:35 +0530, Adish Kuvelker wrote:
Hello Takashi,
I am developing a DMA Controller driver to service the PCM out data to the Audio controller on the arm-based ATLASIII procesor. In case you need any more information on the architecture I can pass.
Since the DMA isn't on PCI bus I am pre-allocation continuous memero using the "snd_pcm_lib_preallocate_pages_for_all" passing SNDDRV_DMA_TYPE_DEV and "snd_dma_continuous_data" as appropriate parameters.
snd_dma_continuous_data() is only for SNDRV_DMA_TYPE_CONTINUOUS. In this case, the pages aren't for DMA.
For SNDRV_DMA_TYPE_DEV, simply pass the device pointer you use.
Takashi
Hello Takashi,
I'm sorry as this is getting bit confusing for me. Playing the PCM data I would want to pass the starting physical address of this location to the DMA start address. Now can I access "dma_addr" directly for this purpose? Do I still have to allocate DMA memory or will just passing of this dma_addr as source address suffice?
I am new to ALSA framework and it's getting a bit confusing to me.
Regards; Aadish
On Thu, Jun 24, 2010 at 1:14 PM, Takashi Iwai tiwai@suse.de wrote:
At Thu, 24 Jun 2010 12:52:47 +0530, Adish Kuvelker wrote:
Hello,
If I use "SNDRV_DMA_TYPE_CONTINUOUS" as a parameter to pre-allocate function to get contiguous locations of memory and use the function snd_dma_continuous_data() would that be correct setting for my case?
I guess no. As mentioned, it's no DMA memory, i.e. simple pages allocated via __get_free_pages() and co.
Where are the parameters of dma_addr and dma_area written to the runtime structure?
These are available only for pages properly allocated for DMA.
Takashi
Regards; Aadish
On Thu, Jun 24, 2010 at 12:45 PM, Takashi Iwai tiwai@suse.de wrote:
At Thu, 24 Jun 2010 12:38:35 +0530, Adish Kuvelker wrote:
Hello Takashi,
I am developing a DMA Controller driver to service the PCM out data to the Audio controller on the arm-based ATLASIII procesor. In case you need any more information on the architecture I can pass.
Since the DMA isn't on PCI bus I am pre-allocation continuous memero using the "snd_pcm_lib_preallocate_pages_for_all" passing SNDDRV_DMA_TYPE_DEV and "snd_dma_continuous_data" as appropriate parameters.
snd_dma_continuous_data() is only for SNDRV_DMA_TYPE_CONTINUOUS. In this case, the pages aren't for DMA.
For SNDRV_DMA_TYPE_DEV, simply pass the device pointer you use.
Takashi
Hello Takashi,
I called the function snd_pcm_lib_preallocate_pages_for_all passing SNDRV_DMA_TYPE_DEV and pointer to struct device as parameters. This doesn't crash. However with SNDRV_DMA_TYPE_CONTINUOUS it did crash.
I have used the function "snd_pcm_lib_malloc_pages" in the hw_params callout to allocate DMA memory. I hope this is the right way of doing the DMA allocation.
With this above configuration can I stay assured that "dma_addr" will give me the physical address of the buffer?
Regards; Aadish
On Thu, Jun 24, 2010 at 1:57 PM, Adish Kuvelker adkuvi@gmail.com wrote:
Hello Takashi,
I'm sorry as this is getting bit confusing for me. Playing the PCM data I would want to pass the starting physical address of this location to the DMA start address. Now can I access "dma_addr" directly for this purpose? Do I still have to allocate DMA memory or will just passing of this dma_addr as source address suffice?
I am new to ALSA framework and it's getting a bit confusing to me.
Regards; Aadish
On Thu, Jun 24, 2010 at 1:14 PM, Takashi Iwai tiwai@suse.de wrote:
At Thu, 24 Jun 2010 12:52:47 +0530, Adish Kuvelker wrote:
Hello,
If I use "SNDRV_DMA_TYPE_CONTINUOUS" as a parameter to pre-allocate function to get contiguous locations of memory and use the function snd_dma_continuous_data() would that be correct setting for my case?
I guess no. As mentioned, it's no DMA memory, i.e. simple pages allocated via __get_free_pages() and co.
Where are the parameters of dma_addr and dma_area written to the runtime structure?
These are available only for pages properly allocated for DMA.
Takashi
Regards; Aadish
On Thu, Jun 24, 2010 at 12:45 PM, Takashi Iwai tiwai@suse.de wrote:
At Thu, 24 Jun 2010 12:38:35 +0530, Adish Kuvelker wrote:
Hello Takashi,
I am developing a DMA Controller driver to service the PCM out data to the Audio controller on the arm-based ATLASIII procesor. In case you need any more information on the architecture I can pass.
Since the DMA isn't on PCI bus I am pre-allocation continuous memero using the "snd_pcm_lib_preallocate_pages_for_all" passing SNDDRV_DMA_TYPE_DEV and "snd_dma_continuous_data" as appropriate parameters.
snd_dma_continuous_data() is only for SNDRV_DMA_TYPE_CONTINUOUS. In this case, the pages aren't for DMA.
For SNDRV_DMA_TYPE_DEV, simply pass the device pointer you use.
Takashi
participants (2)
-
Adish Kuvelker
-
Takashi Iwai